TracktionEngine
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
tracktion::engine::TransportControl Class Reference

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

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

Classes

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

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

Engineengine
 The Engine this Edit belongs to. More...
 
Editedit
 The Edit this transport belongs to. More...
 
juce::ValueTree state
 The state of this transport. More...
 
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()

tracktion::engine::TransportControl::TransportControl ( Edit ,
const juce::ValueTree &   
)

Constructs a TransportControl for an Edit.

◆ ~TransportControl()

tracktion::engine::TransportControl::~TransportControl ( )
override

Destructor.

Member Function Documentation

◆ play()

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

◆ playSectionAndReset()

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

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

◆ record()

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

Starts recording.

This will also start playback if stopped.

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 tracktion::engine::TransportControl::stop ( bool  discardRecordings,
bool  clearDevices,
bool  canSendMMCStop = true,
bool  invertReturnToStartPosSelection = false 
)

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
invertReturnToStartPosSelectionIf true, the return to start behaviour will be inverted

◆ stopIfRecording()

void tracktion::engine::TransportControl::stopIfRecording ( )

Stops playback only if recording is currently in progress.

See also
isRecording

◆ applyRetrospectiveRecord()

juce::Result tracktion::engine::TransportControl::applyRetrospectiveRecord ( )

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

◆ getRetrospectiveRecordAsAudioFiles()

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

Perfoms a retrospective record operation and returns any new files.

◆ syncToEdit()

void tracktion::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 tracktion::engine::TransportControl::isPlaying ( ) const

Returns true if the transport is playing.

(This is also true during recording).

◆ isRecording()

bool tracktion::engine::TransportControl::isRecording ( ) const

Returns true if recording is in progress.

◆ isSafeRecording()

bool tracktion::engine::TransportControl::isSafeRecording ( ) const

Returns true if safe-recording is in progress.

◆ isStopping()

bool tracktion::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.

◆ getTimeWhenStarted()

TimePosition tracktion::engine::TransportControl::getTimeWhenStarted ( ) const

Returns the time when the transport was started.

◆ getCurrentPosition()

double tracktion::engine::TransportControl::getCurrentPosition ( ) 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

◆ getPosition()

TimePosition tracktion::engine::TransportControl::getPosition ( ) const

◆ setCurrentPosition()

void tracktion::engine::TransportControl::setCurrentPosition ( double  time)

Sets a new transport position.

◆ setPosition()

void tracktion::engine::TransportControl::setPosition ( TimePosition  )

◆ setUserDragging()

void tracktion::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 tracktion::engine::TransportControl::isUserDragging ( ) const
noexcept

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

See also
setUserDragging

◆ isPositionUpdatingFromPlayhead()

bool tracktion::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).

◆ setLoopIn()

void tracktion::engine::TransportControl::setLoopIn ( TimePosition  )

Sets the loop in position.

◆ setLoopOut()

void tracktion::engine::TransportControl::setLoopOut ( TimePosition  )

Sets a loop out position.

◆ setLoopPoint1()

void tracktion::engine::TransportControl::setLoopPoint1 ( TimePosition  )

Sets a loop point 1 position.

◆ setLoopPoint2()

void tracktion::engine::TransportControl::setLoopPoint2 ( TimePosition  )

Sets a loop point 2 position.

◆ setLoopRange()

void tracktion::engine::TransportControl::setLoopRange ( TimeRange  )

Sets the loop points from a given range.

◆ getLoopRange()

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

Returns the loop range.

The loop range is between the two loop points.

◆ setSnapType()

void tracktion::engine::TransportControl::setSnapType ( TimecodeSnapType  )

Sets a snap type to use.

◆ getSnapType()

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

Returns the current snap type.

◆ getCurrentPlaybackContext()

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

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

◆ isPlayContextActive()

bool tracktion::engine::TransportControl::isPlayContextActive ( ) const

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

◆ ensureContextAllocated()

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

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

◆ freePlaybackContext()

void tracktion::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 tracktion::engine::TransportControl::triggerClearDevicesOnStop ( )

Triggers a graph rebuild when playback stops.

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

◆ forceOrphanFreezeAndProxyFilesPurge()

void tracktion::engine::TransportControl::forceOrphanFreezeAndProxyFilesPurge ( )

Triggers a cleanup of any unused freeze and proxy files.

◆ setRewindButtonDown()

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

Starts/stops a rewind operation.

◆ setFastForwardButtonDown()

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

Starts/stops a fast-forward operation.

◆ nudgeLeft()

void tracktion::engine::TransportControl::nudgeLeft ( )

Moves the transport back slightly.

◆ nudgeRight()

void tracktion::engine::TransportControl::nudgeRight ( )

Moves the transport forwards slightly.

◆ editHasChanged()

void tracktion::engine::TransportControl::editHasChanged ( )

Triggers a playback graph rebuild.

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

◆ isAllowedToReallocate()

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

Returns true if no ReallocationInhibitors currently exist.

◆ getAllActiveTransports()

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

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

◆ getNumPlayingTransports()

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

Returns the number of Edits currently playing.

◆ stopAllTransports()

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

Stops all TransportControl[s] in the Engine playing.

See also
stop.

◆ restartAllTransports()

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

Restarts all TransportControl[s] in the Edit.

See also
stop.

◆ addListener()

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

Adds a Listener.

◆ removeListener()

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

Removes a Listener.

◆ callRecordingAboutToStopListeners()

void tracktion::engine::TransportControl::callRecordingAboutToStopListeners ( InputDeviceInstance )

◆ callRecordingFinishedListeners()

void tracktion::engine::TransportControl::callRecordingFinishedListeners ( InputDeviceInstance ,
juce::ReferenceCountedArray< Clip recordedClips 
)

Member Data Documentation

◆ engine

Engine& tracktion::engine::TransportControl::engine

The Engine this Edit belongs to.

◆ edit

Edit& tracktion::engine::TransportControl::edit

The Edit this transport belongs to.

See also
Edit::getTransport.

◆ state

juce::ValueTree tracktion::engine::TransportControl::state

The state of this transport.

◆ position

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

.

◆ loopPoint1

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

◆ loopPoint2

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

◆ scrubInterval

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

◆ snapToTimecode

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

.

◆ looping

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

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