11namespace tracktion {
inline namespace engine
25 : playHeadState (phs),
27 tempoPosition (
std::make_unique<tempo::Sequence::Position> (seq))
33 if (sampleRate != newSampleRate)
38 if (updateContinuityFlags == UpdateContinuityFlags::yes)
39 playHeadState.
update (newReferenceSampleRange);
41 sampleRate = newSampleRate;
43 referenceSampleRange = newReferenceSampleRange;
46 jassert (! splitTimelineRange.isSplit);
47 timelineSampleRange = splitTimelineRange.timelineRange1;
51 editTimeRange = timeRangeFromSamples (timelineSampleRange, sampleRate);
56 tempoPosition->set (editTimeRange.getStart());
57 const auto beatStart = tempoPosition->getBeats();
58 tempoPosition->set (editTimeRange.getEnd());
59 const auto beatEnd = tempoPosition->getBeats();
60 editBeatRange = { beatStart, beatEnd };
62 if (updateContinuityFlags == UpdateContinuityFlags::no)
70 referenceSampleRange.
getEnd(),
71 { oldSyncPoint.monotonicBeat.v + editBeatRange.getLength() },
72 TimePosition::fromSamples (unloopTimelineSample, sampleRate),
73 editTimeRange.getEnd(),
77 oldSyncPoint.
time = editTimeRange.getStart();
78 oldSyncPoint.beat = beatStart;
79 syncRange.store ({ oldSyncPoint, newSyncPoint });
87 playbackSpeedRatio = newRatio;
92 if (tempoSequence == ts)
100 tempoPosition.reset();
105 return tempoSequence;
110 return tempoPosition.get();
120 return syncRange.load();
123void ProcessState::setSyncRange (
SyncRange r)
125 syncRange.store (std::move (r));
138 return tempoPosition->getKey();
145 return processState->playbackSpeedRatio;
151 return tempoPosition->getTimeOfNextChange();
159 return tempoPosition->getBeatOfNextChange();
164void TracktionEngineNode::setProcessState (
ProcessState& newProcessState)
166 processState = &newProcessState;
constexpr ValueType getEnd() const noexcept
constexpr ValueType getLength() const noexcept
Holds a list of TempoSetting objects, to form a sequence of tempo changes.
std::optional< TimePosition > getTimeOfNextChange() const
May return the time of the next tempo or time sig change.
TracktionEngineNode(ProcessState &)
Creates a TracktionEngineNode.
double getPlaybackSpeedRatio() const
Returns the playback speed ratio of the current process block.
tempo::Key getKey() const
Returns the key of the current process block.
std::optional< BeatPosition > getBeatOfNextChange() const
May return the time of the next tempo or time sig change.
Determines how this block releates to other previous render blocks and if the play head has jumped in...
void update(juce::Range< int64_t > referenceSampleRange)
Call once per block to update the jumped state.
int64_t referenceSamplePositionToTimelinePositionUnlooped(int64_t referenceSamplePosition) const
Converts a reference sample position to a timeline position as if there was no looping set.
void setScrubbingBlockLength(int64_t numSamples)
Sets the length of the small looped blocks to play while scrubbing.
void setReferenceSampleRange(juce::Range< int64_t > sampleRange)
Sets the reference sample count, adjusting the timeline if the play head is playing.
TimePosition time
The Edit timeline time.
Holds a reference sample position and the Edit time and beat that it corresponds to.
SplitTimelineRange referenceSampleRangeToSplitTimelineRange(const PlayHead &playHead, juce::Range< int64_t > referenceSampleRange)
Converts a reference sample range to a TimelinePositionWindow which could have two time ranges if the...
Represents a duration in real-life time.
A Sequence::Position is an iterator through a Sequence.
Holds the state of a process call.
const tempo::Sequence::Position * getTempoSequencePosition() const
Returns the tempo::Sequence::Position this state uses.
void update(double sampleRate, juce::Range< int64_t > referenceSampleRange, UpdateContinuityFlags)
Updates the internal state based on a reference sample range.
std::function< void()> onContinuityUpdated
Callback which can be set to be called when the continuity changes.
UpdateContinuityFlags
An enum to indicate if the PlayHeadState continuity should be updated.
SyncPoint getSyncPoint() const
Returns the end of the SyncRange.
ProcessState(tracktion::graph::PlayHeadState &)
Creates a ProcessState.
SyncRange getSyncRange() const
Returns the SyncRange for the current audio block.
void setPlaybackSpeedRatio(double newRatio)
Sets a playback speed ratio.
const tempo::Sequence * getTempoSequence() const
Returns the tempo::Sequence this state has been initialised with one.
void setTempoSequence(const tempo::Sequence *)
Sets the TempoSequence this state utilises.