TracktionEngine
Loading...
Searching...
No Matches
graph::PlayHead Class Reference

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

#include <tracktion_PlayHead.h>

Public Member Functions

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

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.

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()

graph::PlayHead::PlayHead ( )
noexcept

Creates a PlayHead.

References PlayHead().

Referenced by PlayHead().

Member Function Documentation

◆ setPosition()

void 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(), overridePosition(), and setPosition().

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

◆ play() [1/2]

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

Plays a range in a loop.

References play(), and setPosition().

Referenced by play(), play(), and playSyncedToRange().

◆ play() [2/2]

void graph::PlayHead::play ( )

Starts playback from the last position.

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

◆ playSyncedToRange()

void 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(), and playSyncedToRange().

Referenced by playSyncedToRange().

◆ stop()

void graph::PlayHead::stop ( )

Stops the play head.

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

Referenced by stop().

◆ getPosition()

int64_t graph::PlayHead::getPosition ( ) const

Returns the current timeline position.

References getPosition(), and referenceSamplePositionToTimelinePosition().

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

◆ getUnloopedPosition()

int64_t graph::PlayHead::getUnloopedPosition ( ) const

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

References getUnloopedPosition(), and referenceSamplePositionToTimelinePositionUnlooped().

Referenced by getUnloopedPosition().

◆ overridePosition()

void 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.

References overridePosition().

Referenced by overridePosition(), and setPosition().

◆ isPlaying()

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

Returns true is the play head is currently playing.

References isPlaying().

Referenced by isPlaying().

◆ isStopped()

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

Returns true is the play head is currently stopped.

References isStopped().

Referenced by isStopped().

◆ isLooping()

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

Returns true is the play head is in loop mode.

References isLooping().

Referenced by isLooping().

◆ isRollingIntoLoop()

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

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

References isRollingIntoLoop().

Referenced by isRollingIntoLoop().

◆ getLoopRange()

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

Returns the looped playback range.

References getLoopRange().

Referenced by getLoopRange(), and setLoopRange().

◆ setLoopRange()

void 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(), setLoopRange(), and setPosition().

Referenced by setLoopRange().

◆ setRollInToLoop()

void 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.

References setRollInToLoop().

Referenced by setRollInToLoop().

◆ setUserIsDragging()

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

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

References setUserIsDragging().

Referenced by setUserIsDragging().

◆ isUserDragging()

bool graph::PlayHead::isUserDragging ( ) const

Returns true if the user is dragging.

References isUserDragging().

Referenced by isUserDragging().

◆ getLastUserInteractionTime()

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

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

References getLastUserInteractionTime().

Referenced by getLastUserInteractionTime().

◆ setScrubbingBlockLength()

void 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.

References setScrubbingBlockLength().

Referenced by setScrubbingBlockLength().

◆ getScrubbingBlockLength()

int64_t graph::PlayHead::getScrubbingBlockLength ( ) const

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

References getScrubbingBlockLength().

Referenced by getScrubbingBlockLength(), and referenceSamplePositionToTimelinePosition().

◆ referenceSamplePositionToTimelinePosition()

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

◆ referenceSamplePositionToTimelinePositionUnlooped()

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

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

References referenceSamplePositionToTimelinePositionUnlooped().

Referenced by getUnloopedPosition(), referenceSamplePositionToTimelinePosition(), and referenceSamplePositionToTimelinePositionUnlooped().

◆ referenceSampleRangeToSourceRangeUnlooped()

juce::Range< int64_t > 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.

References referenceSampleRangeToSourceRangeUnlooped().

Referenced by referenceSampleRangeToSourceRangeUnlooped().

◆ linearPositionToLoopPosition()

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

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

References linearPositionToLoopPosition().

Referenced by linearPositionToLoopPosition(), and referenceSamplePositionToTimelinePosition().

◆ setReferenceSampleRange()

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

Sets the reference sample count, adjusting the timeline if the play head is playing.

References getPosition(), and setReferenceSampleRange().

Referenced by setReferenceSampleRange().

◆ getReferenceSampleRange()

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

Returns the reference sample count.

References getReferenceSampleRange().

Referenced by getReferenceSampleRange().

◆ getPlayoutSyncPosition()

int64_t graph::PlayHead::getPlayoutSyncPosition ( ) const

Returns the playout sync position.

For syncing a reference position to a timeline position.

References getPlayoutSyncPosition().

Referenced by getPlayoutSyncPosition().


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