TracktionEngine
Loading...
Searching...
No Matches
engine::TransportControl Class Reference

Controls the transport of an Edit's playback. More...

#include <tracktion_TransportControl.h>

Inherits juce::ChangeBroadcaster, and juce::Timer.

Classes

struct  ReallocationInhibitor
 Prevents the nodes being regenerated while one of these exists, e.g. More...
struct  ScopedPlaybackRestarter
 Is an Edit is playing back, this resumes playback when destroyed. More...
struct  ScopedContextAllocator
 Frees the playback context and then re-allocates it upon destruction. More...
struct  Listener
 Listener interface to be notified of changes to the transport. More...

Public Member Functions

 TransportControl (Edit &, const juce::ValueTree &)
 Constructs a TransportControl for an Edit.
 ~TransportControl () override
 Destructor.
void play (bool justSendMMCIfEnabled)
 Starts playback of an Edit.
void playFromStart (bool justSendMMCIfEnabled)
 Sets the position to the startPosition and begins playback from there.
void playSectionAndReset (TimeRange rangeToPlay)
 Plays a section of an Edit then stops playback, useful for previewing clips.
void record (bool justSendMMCIfEnabled, bool allowRecordingIfNoInputsArmed=false)
 Starts recording.
void stop (bool discardRecordings, bool clearDevices, bool canSendMMCStop=true)
 Stops recording, creating clips of newyly recorded files/MIDI data.
void stopIfRecording ()
 Stops playback only if recording is currently in progress.
void stopRecording (bool discardRecordings=false)
 Stops recording without stopping playback.
juce::Result applyRetrospectiveRecord (bool armedOnly)
 Applys a retrospective record to any assigned input devices, creating clips for any historical input.
juce::Array< juce::File > getRetrospectiveRecordAsAudioFiles ()
 Perfoms a retrospective record operation and returns any new files.
void syncToEdit (Edit *editToSyncTo, bool syncToTargetLoopLength)
 Syncs this Edit's playback to another Edit.
bool isPlaying () const
 Returns true if the transport is playing.
bool isRecording () const
 Returns true if recording is in progress.
bool isSafeRecording () const
 Returns true if safe-recording is in progress.
bool isStopping () const
 Returns true if the transport is currently being stopped.
bool isRecordingStopping () const
 Returns true if a recording is currently being stopped.
TimePosition getTimeWhenStarted () const
 Returns the time when the transport was started.
TimePosition getPosition () const
 Returns the current transport position.
void setPosition (TimePosition)
 Sets a new transport position.
void setPosition (TimePosition timeToMoveTo, TimePosition timeToPerformJump)
 Sets a new transport position to take effect at a given time.
void jumpTo (TimePosition)
 Moves the transport as a user's jump, e.g.
void setUserDragging (bool)
 Signifies a scrub-drag operation has started/stopped.
bool isUserDragging () const noexcept
 Returns true if a drag/scrub operation has been enabled.
bool isPositionUpdatingFromPlayhead () const
 Returns true if the current position change was triggered from an update directly from the playhead (rather than a call to setCurrentPosition).
void setLoopIn (TimePosition)
 Sets the loop in position.
void setLoopOut (TimePosition)
 Sets a loop out position.
void setLoopPoint1 (TimePosition)
 Sets a loop point 1 position.
void setLoopPoint2 (TimePosition)
 Sets a loop point 2 position.
void setLoopRange (TimeRange)
 Sets the loop points from a given range.
TimeRange getLoopRange () const noexcept
 Returns the loop range.
void setSnapType (TimecodeSnapType)
 Sets a snap type to use.
TimecodeSnapType getSnapType () const noexcept
 Returns the current snap type.
EditPlaybackContext * getCurrentPlaybackContext () const
 Returns the active EditPlaybackContext if this Edit is attached to the DeviceManager for playback.
MonotonicBeat getLastContextMonotonicBeat () const
bool isPlayContextActive () const
 Returns true if this Edit is attached to the DeviceManager for playback.
void ensureContextAllocated (bool alwaysReallocate=false)
 Ensures an active EditPlaybackContext has been created so this Edit can be played back.
void freePlaybackContext ()
 Detaches the current EditPlaybackContext, removing it from the DeviceManager.
void triggerClearDevicesOnStop ()
 Triggers a graph rebuild when playback stops.
void forceOrphanFreezeAndProxyFilesPurge ()
 Triggers a cleanup of any unused freeze and proxy files.
void setRewindButtonDown (bool isDown)
 Starts/stops a rewind operation.
void setFastForwardButtonDown (bool isDown)
 Starts/stops a fast-forward operation.
void nudgeLeft ()
 Moves the transport back slightly.
void nudgeRight ()
 Moves the transport forwards slightly.
void editHasChanged ()
 Triggers a playback graph rebuild.
bool isAllowedToReallocate () const noexcept
 Returns true if no ReallocationInhibitors currently exist.
void addListener (Listener *l)
 Adds a Listener.
void removeListener (Listener *l)
 Removes a Listener.
void callRecordingAboutToStartListeners (InputDeviceInstance &, EditItemID)
void callRecordingAboutToStopListeners (InputDeviceInstance &, EditItemID)
void callRecordingFinishedListeners (InputDeviceInstance &, EditItemID, juce::ReferenceCountedArray< Clip >)

Static Public Member Functions

static juce::Array< TransportControl * > getAllActiveTransports (Engine &)
 Returns all the active TransportControl[s] in the Engine.
static int getNumPlayingTransports (Engine &)
 Returns the number of Edits currently playing.
static void stopAllTransports (Engine &, bool discardRecordings, bool clearDevices)
 Stops all TransportControl[s] in the Engine playing.
static std::vector< std::unique_ptr< ScopedContextAllocator > > restartAllTransports (Engine &, bool clearDevices)
 Restarts all TransportControl[s] in the Edit.

Public Attributes

Engine & engine
 The Engine this Edit belongs to.
Edit & edit
 The Edit this transport belongs to.
juce::ValueTree state
 The state of this transport.
juce::CachedValue< TimePosition > startPosition
 The position to start playing from.
juce::CachedValue< TimePosition > position
juce::CachedValue< TimePosition > loopPoint1
juce::CachedValue< TimePosition > loopPoint2
juce::CachedValue< TimeDuration > scrubInterval
juce::CachedValue< bool > snapToTimecode
juce::CachedValue< bool > looping

Detailed Description

Controls the transport of an Edit's playback.

This is responsible for starting/stopping playback and recording and changing the position etc. It deals with looping/fast forward etc. and is resonsible for managing the EditPlaybackContext which attaches the Edit to the DeviceManager.

It also has higher level user concepts such as dragging/scrubbing.

See also
EditPlaybackContext, DeviceManager

You shouldn't need to directly create one of these, create an Edit and then obtain it from there.

See also
Edit::getTransport

Constructor & Destructor Documentation

◆ TransportControl()

◆ ~TransportControl()

engine::TransportControl::~TransportControl ( )
override

Destructor.

Member Function Documentation

◆ play()

void engine::TransportControl::play ( bool justSendMMCIfEnabled)

Starts playback of an Edit.

Parameters
justSendMMCIfEnabledIf this is true, playback isn't actually started, an MMC message is just output and playback will start when the input MIDI device recieves one.

◆ playFromStart()

void engine::TransportControl::playFromStart ( bool justSendMMCIfEnabled)

Sets the position to the startPosition and begins playback from there.

◆ playSectionAndReset()

void engine::TransportControl::playSectionAndReset ( TimeRange rangeToPlay)

Plays a section of an Edit then stops playback, useful for previewing clips.

◆ record()

void engine::TransportControl::record ( bool justSendMMCIfEnabled,
bool allowRecordingIfNoInputsArmed = false )

Starts recording.

This will also start playback if stopped. The main difference between playback and recording is that if the playback is stopped, recording will pre-roll to count in. If playback is already playing, this will just start recording any armed inputs from the current time.

Parameters
justSendMMCIfEnabledIf this is true, playback isn't actually started, an MMC message is just output and recording will start when the input MIDI device recieves one.
allowRecordingIfNoInputsArmedIf true, no inputs need to actually be armed so you can live-punch on the fly.

◆ stop()

void engine::TransportControl::stop ( bool discardRecordings,
bool clearDevices,
bool canSendMMCStop = true )

Stops recording, creating clips of newyly recorded files/MIDI data.

Parameters
discardRecordingsIf true, recordings will be discarded
clearDevicesIf true, the playback graph will be cleared
canSendMMCStopIf true, an MMC stop message will also be sent

◆ stopIfRecording()

void engine::TransportControl::stopIfRecording ( )

Stops playback only if recording is currently in progress.

See also
isRecording

◆ stopRecording()

void engine::TransportControl::stopRecording ( bool discardRecordings = false)

Stops recording without stopping playback.

◆ applyRetrospectiveRecord()

juce::Result engine::TransportControl::applyRetrospectiveRecord ( bool armedOnly)

Applys a retrospective record to any assigned input devices, creating clips for any historical input.

◆ getRetrospectiveRecordAsAudioFiles()

juce::Array< juce::File > engine::TransportControl::getRetrospectiveRecordAsAudioFiles ( )

Perfoms a retrospective record operation and returns any new files.

◆ syncToEdit()

void engine::TransportControl::syncToEdit ( Edit * editToSyncTo,
bool syncToTargetLoopLength )

Syncs this Edit's playback to another Edit.

Parameters
editToSyncToThe Edit to sync playback to
syncToTargetLoopLengthIf true the sync interval will be the source's loop length, if false, it will be one bar

◆ isPlaying()

bool engine::TransportControl::isPlaying ( ) const

Returns true if the transport is playing.

(This is also true during recording).

Referenced by engine::TransportControl::ScopedPlaybackRestarter::ScopedPlaybackRestarter().

◆ isRecording()

bool engine::TransportControl::isRecording ( ) const

Returns true if recording is in progress.

◆ isSafeRecording()

bool engine::TransportControl::isSafeRecording ( ) const

Returns true if safe-recording is in progress.

◆ isStopping()

bool engine::TransportControl::isStopping ( ) const

Returns true if the transport is currently being stopped.

isPlaying will return false during this period but position changes etc. could still be sent out so this method lets you know if this.

◆ isRecordingStopping()

bool engine::TransportControl::isRecordingStopping ( ) const

Returns true if a recording is currently being stopped.

You can use this to determine if a clip being added is from a recording or not.

◆ getTimeWhenStarted()

TimePosition engine::TransportControl::getTimeWhenStarted ( ) const

Returns the time when the transport was started.

◆ getPosition()

TimePosition engine::TransportControl::getPosition ( ) const

Returns the current transport position.

N.B. This might be different from the actual audible time if the graph introduces latency.

See also
EditPlaybackContext::getAudibleTimelineTime, EditPlaybackContext::getLatencySamples

◆ setPosition() [1/2]

void engine::TransportControl::setPosition ( TimePosition )

Sets a new transport position.

◆ setPosition() [2/2]

void engine::TransportControl::setPosition ( TimePosition timeToMoveTo,
TimePosition timeToPerformJump )

Sets a new transport position to take effect at a given time.

◆ jumpTo()

void engine::TransportControl::jumpTo ( TimePosition )

Moves the transport as a user's jump, e.g.

to a marker. While playing, the EngineBehaviour can defer it (see EngineBehaviour::getTimeToJumpAt), otherwise it moves straight away.

◆ setUserDragging()

void engine::TransportControl::setUserDragging ( bool )

Signifies a scrub-drag operation has started/stopped.

While dragging, a short section of the play position is looped repeatedly.

◆ isUserDragging()

bool engine::TransportControl::isUserDragging ( ) const
noexcept

Returns true if a drag/scrub operation has been enabled.

See also
setUserDragging

◆ isPositionUpdatingFromPlayhead()

bool engine::TransportControl::isPositionUpdatingFromPlayhead ( ) const

Returns true if the current position change was triggered from an update directly from the playhead (rather than a call to setCurrentPosition).

References isPositionUpdatingFromPlayhead().

Referenced by isPositionUpdatingFromPlayhead().

◆ setLoopIn()

void engine::TransportControl::setLoopIn ( TimePosition )

Sets the loop in position.

References setLoopIn().

Referenced by setLoopIn().

◆ setLoopOut()

void engine::TransportControl::setLoopOut ( TimePosition )

Sets a loop out position.

References setLoopOut().

Referenced by setLoopOut().

◆ setLoopPoint1()

void engine::TransportControl::setLoopPoint1 ( TimePosition )

Sets a loop point 1 position.

References setLoopPoint1().

Referenced by setLoopPoint1().

◆ setLoopPoint2()

void engine::TransportControl::setLoopPoint2 ( TimePosition )

Sets a loop point 2 position.

References setLoopPoint2().

Referenced by setLoopPoint2().

◆ setLoopRange()

void engine::TransportControl::setLoopRange ( TimeRange )

Sets the loop points from a given range.

References setLoopRange().

Referenced by setLoopRange().

◆ getLoopRange()

TimeRange engine::TransportControl::getLoopRange ( ) const
noexcept

Returns the loop range.

The loop range is between the two loop points.

References getLoopRange().

Referenced by getLoopRange().

◆ setSnapType()

void engine::TransportControl::setSnapType ( TimecodeSnapType )

Sets a snap type to use.

References setSnapType().

Referenced by setSnapType().

◆ getSnapType()

TimecodeSnapType engine::TransportControl::getSnapType ( ) const
noexcept

Returns the current snap type.

References getSnapType().

Referenced by getSnapType().

◆ getCurrentPlaybackContext()

EditPlaybackContext * engine::TransportControl::getCurrentPlaybackContext ( ) const

Returns the active EditPlaybackContext if this Edit is attached to the DeviceManager for playback.

◆ getLastContextMonotonicBeat()

MonotonicBeat engine::TransportControl::getLastContextMonotonicBeat ( ) const

Where the last freed playback context's monotonic beat count got to, so a new one carries on from it.

◆ isPlayContextActive()

bool engine::TransportControl::isPlayContextActive ( ) const

Returns true if this Edit is attached to the DeviceManager for playback.

Referenced by engine::TransportControl::ScopedContextAllocator::ScopedContextAllocator().

◆ ensureContextAllocated()

void engine::TransportControl::ensureContextAllocated ( bool alwaysReallocate = false)

Ensures an active EditPlaybackContext has been created so this Edit can be played back.

Parameters
alwaysReallocateIf true, this will always create a new playback graph.

◆ freePlaybackContext()

void engine::TransportControl::freePlaybackContext ( )

Detaches the current EditPlaybackContext, removing it from the DeviceManager.

Can be used to free up resources if you have multiple Edits open.

◆ triggerClearDevicesOnStop()

void engine::TransportControl::triggerClearDevicesOnStop ( )

Triggers a graph rebuild when playback stops.

Used internally to adjust latency in response to plugin reported latency changes.

◆ forceOrphanFreezeAndProxyFilesPurge()

void engine::TransportControl::forceOrphanFreezeAndProxyFilesPurge ( )

Triggers a cleanup of any unused freeze and proxy files.

◆ setRewindButtonDown()

void engine::TransportControl::setRewindButtonDown ( bool isDown)

Starts/stops a rewind operation.

◆ setFastForwardButtonDown()

void engine::TransportControl::setFastForwardButtonDown ( bool isDown)

Starts/stops a fast-forward operation.

◆ nudgeLeft()

void engine::TransportControl::nudgeLeft ( )

Moves the transport back slightly.

◆ nudgeRight()

void engine::TransportControl::nudgeRight ( )

Moves the transport forwards slightly.

◆ editHasChanged()

void engine::TransportControl::editHasChanged ( )

Triggers a playback graph rebuild.

Called internally by Edit objects to rebuild the node graph when things change.

◆ isAllowedToReallocate()

bool engine::TransportControl::isAllowedToReallocate ( ) const
noexcept

Returns true if no ReallocationInhibitors currently exist.

◆ getAllActiveTransports()

juce::Array< TransportControl * > engine::TransportControl::getAllActiveTransports ( Engine & )
static

Returns all the active TransportControl[s] in the Engine.

◆ getNumPlayingTransports()

int engine::TransportControl::getNumPlayingTransports ( Engine & )
static

Returns the number of Edits currently playing.

◆ stopAllTransports()

void engine::TransportControl::stopAllTransports ( Engine & ,
bool discardRecordings,
bool clearDevices )
static

Stops all TransportControl[s] in the Engine playing.

See also
stop.

◆ restartAllTransports()

std::vector< std::unique_ptr< ScopedContextAllocator > > engine::TransportControl::restartAllTransports ( Engine & ,
bool clearDevices )
static

Restarts all TransportControl[s] in the Edit.

See also
stop.

◆ addListener()

void engine::TransportControl::addListener ( Listener * l)

Adds a Listener.

◆ removeListener()

void engine::TransportControl::removeListener ( Listener * l)

Removes a Listener.

◆ callRecordingAboutToStartListeners()

void engine::TransportControl::callRecordingAboutToStartListeners ( InputDeviceInstance & ,
EditItemID  )

◆ callRecordingAboutToStopListeners()

void engine::TransportControl::callRecordingAboutToStopListeners ( InputDeviceInstance & ,
EditItemID  )

◆ callRecordingFinishedListeners()

void engine::TransportControl::callRecordingFinishedListeners ( InputDeviceInstance & ,
EditItemID ,
juce::ReferenceCountedArray< Clip >  )

References TransportControl().

Member Data Documentation

◆ engine

Engine& engine::TransportControl::engine

The Engine this Edit belongs to.

◆ edit

Edit& engine::TransportControl::edit

The Edit this transport belongs to.

See also
Edit::getTransport.

◆ state

juce::ValueTree engine::TransportControl::state

The state of this transport.

◆ startPosition

juce::CachedValue<TimePosition> engine::TransportControl::startPosition

The position to start playing from.

◆ position

juce::CachedValue<TimePosition> engine::TransportControl::position

.

◆ loopPoint1

juce::CachedValue<TimePosition> engine::TransportControl::loopPoint1

◆ loopPoint2

juce::CachedValue<TimePosition> engine::TransportControl::loopPoint2

◆ scrubInterval

juce::CachedValue<TimeDuration> engine::TransportControl::scrubInterval

◆ snapToTimecode

juce::CachedValue<bool> engine::TransportControl::snapToTimecode

.

◆ looping

juce::CachedValue<bool> engine::TransportControl::looping

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