TracktionEngine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
tracktion::engine::InputDeviceInstance Class Referenceabstract

An instance of an InputDevice that's available to an Edit. More...

#include <tracktion_InputDevice.h>

Inherits juce::ValueTree::Listener.

Classes

struct  Consumer
 Base class for classes that want to listen to an InputDevice and get a callback for each block of input. More...
 
struct  Destination
 
struct  DestinationList
 
struct  MidiInputDestination
 
class  RecordingContext
 Base class for RecordingContexts. More...
 
struct  RecordingParameters
 
struct  StopRecordingParameters
 The params passed to stopRecording. More...
 
struct  VirtualMidiInputDestination
 
struct  WaveInputDestination
 

Public Types

using PreparedContext = std::vector< tl::expected< std::unique_ptr< RecordingContext >, juce::String > >
 An array of either valid RecordingContexts or an error message if the recording couldn't be started.
 

Public Member Functions

 InputDeviceInstance (InputDevice &, EditPlaybackContext &)
 
 ~InputDeviceInstance () override
 Destructor.
 
InputDevicegetInputDevice () noexcept
 Returns the InputDevice this instance belongs to.
 
juce::Array< EditItemIDgetTargets () const
 Returns the targets this instance is assigned to.
 
tl::expected< Destination *, juce::String > setTarget (EditItemID targetID, bool moveToTrack, juce::UndoManager *, std::optional< int > index=std::nullopt)
 Assigns this input to either an AudioTrack or a ClipSlot.
 
juce::Result removeTarget (EditItemID targetID, juce::UndoManager *)
 Removes the destination with the given targetID.
 
virtual bool isLivePlayEnabled (const Track &) const
 Whether the track should monitor the input or not.
 
virtual bool isRecordingActive () const
 Returns true if recording is enabled and the input is connected to any target.
 
virtual bool isRecordingActive (EditItemID) const
 Returns true if recording is enabled and the input is connected the given target.
 
virtual bool isRecordingQueuedToStop (EditItemID)=0
 Returns true if the async stopRecording function has been used and this target is waiting to stop.
 
bool isRecordingEnabled (EditItemID) const
 Returns true if recording is enabled for the given target.
 
void setRecordingEnabled (EditItemID, bool)
 Enabled/disables recording for a given target.
 
virtual bool shouldTrackContentsBeMuted (const Track &)
 Should return true if this input is currently actively recording into a track and it wants the existing track contents to be muted.
 
virtual PreparedContext prepareToRecord (RecordingParameters)=0
 Prepares a recording operation.
 
virtual std::vector< std::unique_ptr< RecordingContext > > startRecording (std::vector< std::unique_ptr< RecordingContext > >)=0
 Starts a recording.
 
virtual void prepareToStopRecording (std::vector< EditItemID > targetsToStop)=0
 Stops a recording from receiving any more input.
 
virtual tl::expected< Clip::Array, juce::String > stopRecording (StopRecordingParameters)=0
 Stops a recording.
 
virtual void stopRecording (StopRecordingParameters, std::function< void(tl::expected< Clip::Array, juce::String >)>)=0
 Stops a recording asyncronously.
 
virtual bool isRecording (EditItemID)=0
 Returns true if there are any active recordings for this device.
 
virtual bool isRecording ()=0
 Returns true if there are any active recordings for this device.
 
virtual juce::File getRecordingFile (EditItemID) const
 Returns the File that the given target is currently recording to.
 
virtual std::shared_ptr< choc::fifo::SingleReaderSingleWriterFIFO< juce::MidiMessage > > getRecordingNotes (EditItemID) const
 Returns a fifo of recorded MIDInotes that can be used for drawing UI components.
 
virtual TimePosition getPunchInTime (EditItemID)=0
 Returns the time that a given target started recording.
 
virtual juce::Array< Clip * > applyRetrospectiveRecord (bool armedOnly)=0
 Takes the retrospective buffer and creates clips from it, as if recording had been triggered in the past and stopped at the time of calling this function.
 
virtual void addConsumer (Consumer *)=0
 Base classes should override this to add any Consumers internally.
 
virtual void removeConsumer (Consumer *)=0
 Base classes should override this to remove the Consumer internally.
 

Public Attributes

juce::ValueTree state
 
InputDeviceowner
 The state of this instance.
 
EditPlaybackContextcontext
 The EditPlaybackContext this instance belongs to.
 
Editedit
 The Edit this instance belongs to.
 
DestinationList destinations { *this, state }
 The list of assigned destinations.
 

Protected Member Functions

void valueTreePropertyChanged (juce::ValueTree &, const juce::Identifier &) override
 
void valueTreeChildAdded (juce::ValueTree &, juce::ValueTree &) override
 
void valueTreeChildRemoved (juce::ValueTree &, juce::ValueTree &, int) override
 
ClipSlotgetFreeSlot (AudioTrack &)
 

Detailed Description

An instance of an InputDevice that's available to an Edit.

Whereas InputDevice[s] are Engine level objects, instances apply to an Edit and can therefore be assigned to slots/tracks etc.

See also
EditInputDevices

Member Typedef Documentation

◆ PreparedContext

using tracktion::engine::InputDeviceInstance::PreparedContext = std::vector<tl::expected<std::unique_ptr<RecordingContext>, juce::String> >

An array of either valid RecordingContexts or an error message if the recording couldn't be started.

See also

Constructor & Destructor Documentation

◆ InputDeviceInstance()

tracktion::engine::InputDeviceInstance::InputDeviceInstance ( InputDevice ,
EditPlaybackContext  
)

◆ ~InputDeviceInstance()

tracktion::engine::InputDeviceInstance::~InputDeviceInstance ( )
override

Destructor.

Member Function Documentation

◆ getInputDevice()

InputDevice & tracktion::engine::InputDeviceInstance::getInputDevice ( )
noexcept

◆ getTargets()

juce::Array< EditItemID > tracktion::engine::InputDeviceInstance::getTargets ( ) const

Returns the targets this instance is assigned to.

◆ setTarget()

tl::expected< Destination *, juce::String > tracktion::engine::InputDeviceInstance::setTarget ( EditItemID  targetID,
bool  moveToTrack,
juce::UndoManager *  ,
std::optional< int >  index = std::nullopt 
)

Assigns this input to either an AudioTrack or a ClipSlot.

◆ removeTarget()

juce::Result tracktion::engine::InputDeviceInstance::removeTarget ( EditItemID  targetID,
juce::UndoManager *   
)

Removes the destination with the given targetID.

◆ isLivePlayEnabled()

virtual bool tracktion::engine::InputDeviceInstance::isLivePlayEnabled ( const Track ) const
virtual

Whether the track should monitor the input or not.

◆ isRecordingActive() [1/2]

virtual bool tracktion::engine::InputDeviceInstance::isRecordingActive ( ) const
virtual

Returns true if recording is enabled and the input is connected to any target.

◆ isRecordingActive() [2/2]

virtual bool tracktion::engine::InputDeviceInstance::isRecordingActive ( EditItemID  ) const
virtual

Returns true if recording is enabled and the input is connected the given target.

◆ isRecordingQueuedToStop()

virtual bool tracktion::engine::InputDeviceInstance::isRecordingQueuedToStop ( EditItemID  )
pure virtual

Returns true if the async stopRecording function has been used and this target is waiting to stop.

◆ isRecordingEnabled()

bool tracktion::engine::InputDeviceInstance::isRecordingEnabled ( EditItemID  ) const

Returns true if recording is enabled for the given target.

◆ setRecordingEnabled()

void tracktion::engine::InputDeviceInstance::setRecordingEnabled ( EditItemID  ,
bool   
)

Enabled/disables recording for a given target.

If the transport is currently recording, this will start a punch-in recording.

◆ shouldTrackContentsBeMuted()

virtual bool tracktion::engine::InputDeviceInstance::shouldTrackContentsBeMuted ( const Track )
virtual

Should return true if this input is currently actively recording into a track and it wants the existing track contents to be muted.

◆ prepareToRecord()

virtual PreparedContext tracktion::engine::InputDeviceInstance::prepareToRecord ( RecordingParameters  )
pure virtual

Prepares a recording operation.

Parameters
RecordingParametersDetermines the destinations and punch ranges
Returns
An array of either valid RecordingContexts or error messages

◆ startRecording()

virtual std::vector< std::unique_ptr< RecordingContext > > tracktion::engine::InputDeviceInstance::startRecording ( std::vector< std::unique_ptr< RecordingContext > >  )
pure virtual

Starts a recording.

Parameters
Theprepared recording contexts to start.
Returns
Any recording contexts that couldn't be started by this device. E.g. If the contexts are mixed MIDI and audio and this is an audio device, it will returns the MIDI contexts to pass to a MIDI device.

◆ prepareToStopRecording()

virtual void tracktion::engine::InputDeviceInstance::prepareToStopRecording ( std::vector< EditItemID targetsToStop)
pure virtual

Stops a recording from receiving any more input.

Because stopRecording is blocking, if you have many inputs recording, some inputs can continue to record whilst others are having their files closed. Calling this first prevents this.

Parameters
targetsToStopThe targets to stop, others will continue allowing you to punch out only specific targets. If this is empty, all active recordings will be stopped.

◆ stopRecording() [1/2]

virtual tl::expected< Clip::Array, juce::String > tracktion::engine::InputDeviceInstance::stopRecording ( StopRecordingParameters  )
pure virtual

Stops a recording.

Parameters
StopRecordingParametersdetermines how stopped recordings are treated.

◆ stopRecording() [2/2]

virtual void tracktion::engine::InputDeviceInstance::stopRecording ( StopRecordingParameters  ,
std::function< void(tl::expected< Clip::Array, juce::String >)>   
)
pure virtual

Stops a recording asyncronously.

This can be used to trigger a recording to stop at a time in the future. This function will return immidiately and call the provided callback when the recording actually stops.

Parameters
StopRecordingParametersDetermines how stopped recordings are treated.
recordingStoppedCallbackA callback to call when the recording stops.

◆ isRecording() [1/2]

virtual bool tracktion::engine::InputDeviceInstance::isRecording ( EditItemID  )
pure virtual

Returns true if there are any active recordings for this device.

◆ isRecording() [2/2]

virtual bool tracktion::engine::InputDeviceInstance::isRecording ( )
pure virtual

Returns true if there are any active recordings for this device.

◆ getRecordingFile()

virtual juce::File tracktion::engine::InputDeviceInstance::getRecordingFile ( EditItemID  ) const
virtual

Returns the File that the given target is currently recording to.

◆ getRecordingNotes()

virtual std::shared_ptr< choc::fifo::SingleReaderSingleWriterFIFO< juce::MidiMessage > > tracktion::engine::InputDeviceInstance::getRecordingNotes ( EditItemID  ) const
virtual

Returns a fifo of recorded MIDInotes that can be used for drawing UI components.

◆ getPunchInTime()

virtual TimePosition tracktion::engine::InputDeviceInstance::getPunchInTime ( EditItemID  )
pure virtual

Returns the time that a given target started recording.

◆ applyRetrospectiveRecord()

virtual juce::Array< Clip * > tracktion::engine::InputDeviceInstance::applyRetrospectiveRecord ( bool  armedOnly)
pure virtual

Takes the retrospective buffer and creates clips from it, as if recording had been triggered in the past and stopped at the time of calling this function.

◆ addConsumer()

virtual void tracktion::engine::InputDeviceInstance::addConsumer ( Consumer )
pure virtual

Base classes should override this to add any Consumers internally.

◆ removeConsumer()

virtual void tracktion::engine::InputDeviceInstance::removeConsumer ( Consumer )
pure virtual

Base classes should override this to remove the Consumer internally.

◆ valueTreePropertyChanged()

void tracktion::engine::InputDeviceInstance::valueTreePropertyChanged ( juce::ValueTree &  ,
const juce::Identifier &   
)
overrideprotected

◆ valueTreeChildAdded()

void tracktion::engine::InputDeviceInstance::valueTreeChildAdded ( juce::ValueTree &  ,
juce::ValueTree &   
)
overrideprotected

◆ valueTreeChildRemoved()

void tracktion::engine::InputDeviceInstance::valueTreeChildRemoved ( juce::ValueTree &  ,
juce::ValueTree &  ,
int   
)
overrideprotected

◆ getFreeSlot()

ClipSlot * tracktion::engine::InputDeviceInstance::getFreeSlot ( AudioTrack )
protected

Member Data Documentation

◆ state

juce::ValueTree tracktion::engine::InputDeviceInstance::state

◆ owner

InputDevice& tracktion::engine::InputDeviceInstance::owner

The state of this instance.

The InputDevice this is an instance of.

Referenced by getInputDevice().

◆ context

EditPlaybackContext& tracktion::engine::InputDeviceInstance::context

The EditPlaybackContext this instance belongs to.

◆ edit

Edit& tracktion::engine::InputDeviceInstance::edit

The Edit this instance belongs to.

◆ destinations

DestinationList tracktion::engine::InputDeviceInstance::destinations { *this, state }

The list of assigned destinations.


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