TracktionEngine
Public Member Functions | Static Public Member Functions | List of all members
tracktion::graph::PlayHead Class Reference

Converts a monotonically increasing reference range in to a timeline range. More...

Public Member Functions

 PlayHead () noexcept
 Creates a PlayHead. More...
 
void setPosition (int64_t newPosition)
 Sets the timeline position of the play head and if it is different logs a user interaction. More...
 
void play (juce::Range< int64_t > rangeToPlay, bool looped)
 Plays a range in a loop. More...
 
void play ()
 Starts playback from the last position. More...
 
void playSyncedToRange (juce::Range< int64_t > rangeToPlay)
 Takes the play position directly from the playout range. More...
 
void stop ()
 Stops the play head. More...
 
int64_t getPosition () const
 Returns the current timeline position. More...
 
int64_t getUnloopedPosition () const
 Returns the current timeline position ignoring any loop range which might have been set. More...
 
void overridePosition (int64_t newPosition)
 Adjust position without triggering a 'user interaction' change. More...
 
bool isPlaying () const noexcept
 Returns true is the play head is currently playing. More...
 
bool isStopped () const noexcept
 Returns true is the play head is currently stopped. More...
 
bool isLooping () const noexcept
 Returns true is the play head is in loop mode. More...
 
bool isRollingIntoLoop () const noexcept
 Returns true is the play head is looping but playing before the loop start position. More...
 
juce::Range< int64_t > getLoopRange () const noexcept
 Returns the looped playback range. More...
 
void setLoopRange (bool loop, juce::Range< int64_t > loopRange, bool updatePosition=true)
 Sets a playback range and whether to loop or not. More...
 
void setRollInToLoop (int64_t playbackPosition)
 Puts the play head in to roll in to loop mode. More...
 
void setUserIsDragging (bool)
 Sets the user dragging which logs a user interaction and enables scrubbing mode. More...
 
bool isUserDragging () const
 Returns true if the user is dragging. More...
 
std::chrono::system_clock::time_point getLastUserInteractionTime () const
 Returns the time of the last user interaction, either a setPosition or setUserIsDragging call. More...
 
void setScrubbingBlockLength (int64_t numSamples)
 Sets the length of the small looped blocks to play while scrubbing. More...
 
int64_t getScrubbingBlockLength () const
 Returns the length of the small looped blocks to play while scrubbing. More...
 
int64_t referenceSamplePositionToTimelinePosition (int64_t referenceSamplePosition) const
 Converts a reference sample position to a timeline position. More...
 
int64_t referenceSamplePositionToTimelinePositionUnlooped (int64_t referenceSamplePosition) const
 Converts a reference sample position to a timeline position as if there was no looping set. More...
 
juce::Range< int64_t > referenceSampleRangeToSourceRangeUnlooped (juce::Range< int64_t > sourceReferenceSampleRange) const
 Converts a reference sample range to a timeline range as if there was no looping set. More...
 
void setReferenceSampleRange (juce::Range< int64_t > sampleRange)
 Sets the reference sample count, adjusting the timeline if the play head is playing. More...
 
juce::Range< int64_t > getReferenceSampleRange () const
 Returns the reference sample count. More...
 
int64_t getPlayoutSyncPosition () const
 Returns the playout sync position. More...
 

Static Public Member Functions

static int64_t linearPositionToLoopPosition (int64_t position, juce::Range< int64_t > loopRange)
 Converts a linear timeline position to a position wrapped in the loop. More...
 

Detailed Description

Converts a monotonically increasing reference range in to a timeline range.

This can then get converted to a real-time range using the playback sample rate. This also handles looping and scrubbing and keeps track of when the play position was last set.

Constructor & Destructor Documentation

◆ PlayHead()

tracktion::graph::PlayHead::PlayHead ( )
noexcept

Creates a PlayHead.

Member Function Documentation

◆ setPosition()

void tracktion::graph::PlayHead::setPosition ( int64_t  newPosition)

Sets the timeline position of the play head and if it is different logs a user interaction.

References getPosition(), and overridePosition().

Referenced by play(), setLoopRange(), and stop().

◆ play() [1/2]

void tracktion::graph::PlayHead::play ( juce::Range< int64_t >  rangeToPlay,
bool  looped 
)

Plays a range in a loop.

References setPosition().

◆ play() [2/2]

void tracktion::graph::PlayHead::play ( )

Starts playback from the last position.

References getPosition(), and setPosition().

Referenced by playSyncedToRange().

◆ playSyncedToRange()

void tracktion::graph::PlayHead::playSyncedToRange ( juce::Range< int64_t >  rangeToPlay)

Takes the play position directly from the playout range.

This is for rendering, where there will be no master stream to sync to. N.B. this disables looping.

References play().

Referenced by tracktion::engine::benchmark_utilities::prepareRenderAndDestroy().

◆ stop()

void tracktion::graph::PlayHead::stop ( )

Stops the play head.

References getPosition(), and setPosition().

◆ getPosition()

int64_t tracktion::graph::PlayHead::getPosition ( ) const

Returns the current timeline position.

References referenceSamplePositionToTimelinePosition().

Referenced by play(), setLoopRange(), setPosition(), setReferenceSampleRange(), and stop().

◆ getUnloopedPosition()

int64_t tracktion::graph::PlayHead::getUnloopedPosition ( ) const

Returns the current timeline position ignoring any loop range which might have been set.

References referenceSamplePositionToTimelinePositionUnlooped().

◆ overridePosition()

void tracktion::graph::PlayHead::overridePosition ( int64_t  newPosition)

Adjust position without triggering a 'user interaction' change.

Use when the position change actually maintains continuity - e.g. a tempo change.

Referenced by setPosition().

◆ isPlaying()

bool tracktion::graph::PlayHead::isPlaying ( ) const
noexcept

Returns true is the play head is currently playing.

Referenced by tracktion::graph::PlayHeadState::update().

◆ isStopped()

bool tracktion::graph::PlayHead::isStopped ( ) const
noexcept

Returns true is the play head is currently stopped.

◆ isLooping()

bool tracktion::graph::PlayHead::isLooping ( ) const
noexcept

Returns true is the play head is in loop mode.

Referenced by tracktion::graph::PlayHeadState::update().

◆ isRollingIntoLoop()

bool tracktion::graph::PlayHead::isRollingIntoLoop ( ) const
noexcept

Returns true is the play head is looping but playing before the loop start position.

Referenced by tracktion::graph::PlayHeadState::update().

◆ getLoopRange()

juce::Range< int64_t > tracktion::graph::PlayHead::getLoopRange ( ) const
noexcept

Returns the looped playback range.

Referenced by setLoopRange(), and tracktion::graph::PlayHeadState::update().

◆ setLoopRange()

void tracktion::graph::PlayHead::setLoopRange ( bool  loop,
juce::Range< int64_t >  loopRange,
bool  updatePosition = true 
)

Sets a playback range and whether to loop or not.

References getLoopRange(), getPosition(), and setPosition().

◆ setRollInToLoop()

void tracktion::graph::PlayHead::setRollInToLoop ( int64_t  playbackPosition)

Puts the play head in to roll in to loop mode.

If this position is before the loop start position, the play head won't be wrapped to enable count in to loop recordings etc.

◆ setUserIsDragging()

void tracktion::graph::PlayHead::setUserIsDragging ( bool  b)

Sets the user dragging which logs a user interaction and enables scrubbing mode.

◆ isUserDragging()

bool tracktion::graph::PlayHead::isUserDragging ( ) const

Returns true if the user is dragging.

◆ getLastUserInteractionTime()

std::chrono::system_clock::time_point tracktion::graph::PlayHead::getLastUserInteractionTime ( ) const

Returns the time of the last user interaction, either a setPosition or setUserIsDragging call.

Referenced by tracktion::graph::PlayHeadState::update().

◆ setScrubbingBlockLength()

void tracktion::graph::PlayHead::setScrubbingBlockLength ( int64_t  numSamples)

Sets the length of the small looped blocks to play while scrubbing.

E.g. when the user is dragging.

Referenced by tracktion::graph::NodePlayer::prepareToPlay().

◆ getScrubbingBlockLength()

int64_t tracktion::graph::PlayHead::getScrubbingBlockLength ( ) const

Returns the length of the small looped blocks to play while scrubbing.

Referenced by referenceSamplePositionToTimelinePosition().

◆ referenceSamplePositionToTimelinePosition()

int64_t tracktion::graph::PlayHead::referenceSamplePositionToTimelinePosition ( int64_t  referenceSamplePosition) const

◆ referenceSamplePositionToTimelinePositionUnlooped()

int64_t tracktion::graph::PlayHead::referenceSamplePositionToTimelinePositionUnlooped ( int64_t  referenceSamplePosition) const

Converts a reference sample position to a timeline position as if there was no looping set.

Referenced by getUnloopedPosition(), and referenceSamplePositionToTimelinePosition().

◆ referenceSampleRangeToSourceRangeUnlooped()

juce::Range< int64_t > tracktion::graph::PlayHead::referenceSampleRangeToSourceRangeUnlooped ( juce::Range< int64_t >  sourceReferenceSampleRange) const

Converts a reference sample range to a timeline range as if there was no looping set.

◆ linearPositionToLoopPosition()

int64_t tracktion::graph::PlayHead::linearPositionToLoopPosition ( int64_t  position,
juce::Range< int64_t >  loopRange 
)
static

Converts a linear timeline position to a position wrapped in the loop.

Referenced by referenceSamplePositionToTimelinePosition().

◆ setReferenceSampleRange()

void tracktion::graph::PlayHead::setReferenceSampleRange ( juce::Range< int64_t >  sampleRange)

◆ getReferenceSampleRange()

juce::Range< int64_t > tracktion::graph::PlayHead::getReferenceSampleRange ( ) const

Returns the reference sample count.

◆ getPlayoutSyncPosition()

int64_t tracktion::graph::PlayHead::getPlayoutSyncPosition ( ) const

Returns the playout sync position.

For syncing a reference position to a timeline position.


The documentation for this class was generated from the following file: