TracktionEngine
Classes | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
tracktion::graph::Node Class Referenceabstract

Main graph Node processor class. More...

Inheritance diagram for tracktion::graph::Node:

Classes

struct  AudioAndMidiBuffer
 Contains the buffers for a processing operation. More...
 
struct  ProcessContext
 Struct to describe a single iteration of a process call. More...
 

Public Member Functions

 Node ()=default
 
virtual ~Node ()=default
 
void initialise (const PlaybackInitialisationInfo &)
 Call once after the graph has been constructed to initialise buffers etc. More...
 
void prepareForNextBlock (juce::Range< int64_t > referenceSampleRange)
 Call before processing the next block, used to reset the process status. More...
 
void process (choc::buffer::FrameCount numSamples, juce::Range< int64_t > referenceSampleRange)
 Call to process the node, which will in turn call the process method with the buffers to fill. More...
 
bool hasProcessed () const
 Returns true if this node has processed and its outputs can be retrieved. More...
 
AudioAndMidiBuffer getProcessedOutput ()
 Returns the processed audio and MIDI output. More...
 
virtual TransformResult transform (Node &, const std::vector< Node * > &, TransformCache &)
 Called after construction to give the node a chance to modify its topology. More...
 
virtual std::vector< Node * > getDirectInputNodes ()
 Should return all the inputs directly feeding in to this node. More...
 
virtual std::vector< Node * > getInternalNodes ()
 Can return Nodes that are internal to this Node but don't make up the main graph constructed from getDirectInputNodes(). More...
 
virtual NodeProperties getNodeProperties ()=0
 Should return the properties of the node. More...
 
virtual bool isReadyToProcess ()=0
 Should return true when this node is ready to be processed. More...
 
void retain ()
 Retains the buffers so they won't be deallocated after the Node has processed. More...
 
void release ()
 Releases the buffers allowing internal storage to be deallocated. More...
 
virtual size_t getAllocatedBytes () const
 

Public Attributes

void * internal = nullptr
 
int numOutputNodes = -1
 

Protected Member Functions

virtual void prepareToPlay (const PlaybackInitialisationInfo &)
 Called once before playback begins for each node. More...
 
virtual void prefetchBlock (juce::Range< int64_t >)
 Called before once on all Nodes before they are processed. More...
 
virtual void process (ProcessContext &)=0
 Called when the node is to be processed. More...
 
void setOptimisations (NodeOptimisations)
 This can be called to provide some hints about allocating or playing back a Node to improve efficiency. More...
 
void setAudioOutput (Node *sourceNode, const choc::buffer::ChannelArrayView< float > &)
 This can be called during your process function to set a view to the output. More...
 

Detailed Description

Main graph Node processor class.

Nodes are combined together to form a graph with a root Node which can then be initialsed and processed.

Subclasses should implement the various virtual methods but never call these directly. They will be called automatically by the non-virtual methods.

Constructor & Destructor Documentation

◆ Node()

tracktion::graph::Node::Node ( )
default

◆ ~Node()

virtual tracktion::graph::Node::~Node ( )
virtualdefault

Member Function Documentation

◆ initialise()

void Node::initialise ( const PlaybackInitialisationInfo info)

◆ prepareForNextBlock()

void Node::prepareForNextBlock ( juce::Range< int64_t >  referenceSampleRange)

Call before processing the next block, used to reset the process status.

References getDirectInputNodes(), prefetchBlock(), and retain().

◆ process() [1/2]

void Node::process ( choc::buffer::FrameCount  numSamples,
juce::Range< int64_t >  referenceSampleRange 
)

Call to process the node, which will in turn call the process method with the buffers to fill.

Parameters
numSamplesThe number of samples that need to be processed.
referenceSampleRangeThe monotonic stream time in samples. This will be passed to the ProcessContext during the process callback so nodes can use this to determine file reading positions etc. Some nodes may ignore this completely. N.B. the length of this may be different to the number of samples to be processed so don't rely on them being the same!

References tracktion::graph::NodeOptimisations::allocate, tracktion::graph::NodeOptimisations::clear, release(), and tracktion::graph::yes.

◆ hasProcessed()

bool Node::hasProcessed ( ) const

Returns true if this node has processed and its outputs can be retrieved.

Referenced by getProcessedOutput(), and tracktion::graph::LatencyNode::isReadyToProcess().

◆ getProcessedOutput()

Node::AudioAndMidiBuffer Node::getProcessedOutput ( )

Returns the processed audio and MIDI output.

Must only be called after hasProcessed returns true.

References hasProcessed().

Referenced by tracktion::graph::LatencyNode::process().

◆ transform()

virtual TransformResult tracktion::graph::Node::transform ( Node ,
const std::vector< Node * > &  ,
TransformCache  
)
virtual

Called after construction to give the node a chance to modify its topology.

This should return true if any changes were made to the topology as this indicates that the method may need to be called again after other nodes have had their toplogy changed.

Parameters
postOrderedNodesThis is an ordered list obtained from visiting all the Nodes and can be used for quicker introspection of the graph
TransformCacheA cache which can be used to speed up operations during the transform stage.
Returns
TransformResult The type of transformation that has taken place. If connections have been made AND nodes deleted, return nodesDeleted

Reimplemented in tracktion::graph::ReturnNode, tracktion::graph::SummingNode, and tracktion::graph::ConnectedNode.

References tracktion::graph::none.

◆ getDirectInputNodes()

virtual std::vector<Node*> tracktion::graph::Node::getDirectInputNodes ( )
virtual

Should return all the inputs directly feeding in to this node.

Reimplemented in tracktion::graph::ForwardingNode, tracktion::graph::SinkNode, tracktion::graph::ChannelRemappingNode, tracktion::graph::ReturnNode, tracktion::graph::SendNode, tracktion::graph::GainNode, tracktion::graph::FunctionNode, tracktion::graph::BasicSummingNode, tracktion::graph::SummingNode, tracktion::graph::LatencyNode, tracktion::graph::ConnectedNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TimedMutingNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::RackReturnNode, tracktion::engine::RackInstanceNode, tracktion::engine::PluginNode, tracktion::engine::PlayHeadPositionNode, tracktion::engine::ModifierNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::MelodyneNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::LevelMeasuringNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::InsertSendNode, tracktion::engine::InsertSendReturnDependencyNode, tracktion::engine::InsertReturnNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::ContainerClipNode, tracktion::engine::CombiningNode, and tracktion::engine::ClickNode.

Referenced by initialise(), tracktion::graph::test_utilities::logGraph(), prepareForNextBlock(), tracktion::graph::detail::VisitNodesWithRecordBFS::visit(), and tracktion::graph::detail::VisitNodesWithRecord::visit().

◆ getInternalNodes()

virtual std::vector<Node*> tracktion::graph::Node::getInternalNodes ( )
virtual

Can return Nodes that are internal to this Node but don't make up the main graph constructed from getDirectInputNodes().

Most uses cases won't need to implement this but it could be used in situations where sub-graphs are created and processed internally to a Node but other Nodes in a graph still need to have access to them. This call can make them visible.

Reimplemented in tracktion::engine::DynamicOffsetNode, tracktion::engine::ContainerClipNode, and tracktion::engine::CombiningNode.

◆ getNodeProperties()

virtual NodeProperties tracktion::graph::Node::getNodeProperties ( )
pure virtual

Should return the properties of the node.

This should not be called until after initialise.

Implemented in tracktion::graph::ForwardingNode, tracktion::graph::SinkNode, tracktion::graph::ChannelRemappingNode, tracktion::graph::ReturnNode, tracktion::graph::SendNode, tracktion::graph::GainNode, tracktion::graph::FunctionNode, tracktion::graph::BasicSummingNode, tracktion::graph::SilentNode, tracktion::graph::SinNode, tracktion::graph::MidiNode, tracktion::graph::SummingNode, tracktion::graph::LatencyNode, tracktion::graph::ConnectedNode, tracktion::engine::WaveNodeRealTime, tracktion::engine::WaveNode, tracktion::engine::WaveInputDeviceNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TimedMutingNode, tracktion::engine::SpeedRampWaveNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::RackReturnNode, tracktion::engine::RackInstanceNode, tracktion::engine::PluginNode, tracktion::engine::PlayHeadPositionNode, tracktion::engine::ModifierNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::MidiNode, tracktion::engine::MidiInputDeviceNode, tracktion::engine::MelodyneNode, tracktion::engine::LoopingMidiNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::LevelMeasuringNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::InsertSendNode, tracktion::engine::InsertSendReturnDependencyNode, tracktion::engine::InsertReturnNode, tracktion::engine::HostedMidiInputDeviceNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::ContainerClipNode, tracktion::engine::CombiningNode, tracktion::engine::ClickNode, and tracktion::engine::AuxSendNode.

Referenced by tracktion::graph::LatencyNode::getNodeProperties(), and initialise().

◆ isReadyToProcess()

virtual bool tracktion::graph::Node::isReadyToProcess ( )
pure virtual

Should return true when this node is ready to be processed.

This is usually when its input's output buffers are ready.

Implemented in tracktion::graph::ForwardingNode, tracktion::graph::SinkNode, tracktion::graph::ChannelRemappingNode, tracktion::graph::ReturnNode, tracktion::graph::SendNode, tracktion::graph::GainNode, tracktion::graph::FunctionNode, tracktion::graph::BasicSummingNode, tracktion::graph::SilentNode, tracktion::graph::SinNode, tracktion::graph::MidiNode, tracktion::graph::SummingNode, tracktion::graph::LatencyNode, tracktion::graph::ConnectedNode, tracktion::engine::WaveNodeRealTime, tracktion::engine::WaveNode, tracktion::engine::WaveInputDeviceNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TimedMutingNode, tracktion::engine::SpeedRampWaveNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::RackReturnNode, tracktion::engine::RackInstanceNode, tracktion::engine::PluginNode, tracktion::engine::PlayHeadPositionNode, tracktion::engine::ModifierNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::MidiNode, tracktion::engine::MidiInputDeviceNode, tracktion::engine::MelodyneNode, tracktion::engine::LoopingMidiNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::LevelMeasuringNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::InsertSendNode, tracktion::engine::InsertSendReturnDependencyNode, tracktion::engine::InsertReturnNode, tracktion::engine::HostedMidiInputDeviceNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::ContainerClipNode, tracktion::engine::CombiningNode, and tracktion::engine::ClickNode.

◆ retain()

void Node::retain ( )

Retains the buffers so they won't be deallocated after the Node has processed.

You shouldn't normally need to call this unles your Node player has special requirements.

Referenced by prepareForNextBlock(), and setAudioOutput().

◆ release()

void Node::release ( )

Releases the buffers allowing internal storage to be deallocated.

You shouldn't normally need to call this unles your Node player has special requirements.

Referenced by process().

◆ getAllocatedBytes()

size_t Node::getAllocatedBytes ( ) const
virtual

◆ prepareToPlay()

virtual void tracktion::graph::Node::prepareToPlay ( const PlaybackInitialisationInfo )
protectedvirtual

Called once before playback begins for each node.

Use this to allocate buffers etc. This step can be used to modify the topology of the graph (i.e. add/remove nodes). However, if you do this, you must make sure to call initialise on them so they are fully prepared for processing.

Reimplemented in tracktion::engine::PlayHeadPositionNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::WaveNode, tracktion::engine::WaveInputDeviceNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TimedMutingNode, tracktion::engine::SpeedRampWaveNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::RackReturnNode, tracktion::engine::RackInstanceNode, tracktion::engine::PluginNode, tracktion::engine::ModifierNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::MidiNode, tracktion::engine::MidiInputDeviceNode, tracktion::engine::MelodyneNode, tracktion::engine::LoopingMidiNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::InsertSendNode, tracktion::engine::InsertSendReturnDependencyNode, tracktion::engine::InsertReturnNode, tracktion::engine::HostedMidiInputDeviceNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::ContainerClipNode, tracktion::engine::CombiningNode, tracktion::engine::ClickNode, tracktion::engine::AuxSendNode, tracktion::graph::SilentNode, tracktion::graph::SinNode, tracktion::graph::MidiNode, tracktion::graph::SummingNode, tracktion::graph::LatencyNode, tracktion::graph::ConnectedNode, and tracktion::engine::WaveNodeRealTime.

Referenced by initialise().

◆ prefetchBlock()

virtual void tracktion::graph::Node::prefetchBlock ( juce::Range< int64_t >  )
protectedvirtual

Called before once on all Nodes before they are processed.

This can be used to prefetch audio data or update mute statuses etc..

Reimplemented in tracktion::engine::TrackMutingNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::PluginNode, tracktion::engine::DynamicOffsetNode, and tracktion::engine::CombiningNode.

Referenced by prepareForNextBlock().

◆ process() [2/2]

virtual void tracktion::graph::Node::process ( ProcessContext )
protectedpure virtual

Called when the node is to be processed.

This should add in to the buffers available making sure not to change their size at all.

Implemented in tracktion::engine::LevelMeasuringNode, tracktion::graph::ForwardingNode, tracktion::graph::ChannelRemappingNode, tracktion::graph::ReturnNode, tracktion::graph::SendNode, tracktion::graph::GainNode, tracktion::graph::FunctionNode, tracktion::graph::BasicSummingNode, tracktion::graph::SilentNode, tracktion::graph::SinNode, tracktion::graph::MidiNode, tracktion::graph::SummingNode, tracktion::graph::LatencyNode, tracktion::engine::PlayHeadPositionNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::graph::SinkNode, tracktion::graph::ConnectedNode, tracktion::engine::WaveNodeRealTime, tracktion::engine::WaveNode, tracktion::engine::WaveInputDeviceNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TimedMutingNode, tracktion::engine::SpeedRampWaveNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::RackReturnNode, tracktion::engine::RackInstanceNode, tracktion::engine::PluginNode, tracktion::engine::ModifierNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::MidiNode, tracktion::engine::MidiInputDeviceNode, tracktion::engine::MelodyneNode, tracktion::engine::LoopingMidiNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::InsertSendNode, tracktion::engine::InsertSendReturnDependencyNode, tracktion::engine::InsertReturnNode, tracktion::engine::HostedMidiInputDeviceNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::ContainerClipNode, tracktion::engine::CombiningNode, tracktion::engine::ClickNode, and tracktion::engine::AuxSendNode.

◆ setOptimisations()

void Node::setOptimisations ( NodeOptimisations  newOptimisations)
protected

This can be called to provide some hints about allocating or playing back a Node to improve efficiency.

Be careful with these as they change the default and often expected behaviour.

Referenced by tracktion::graph::LatencyNode::LatencyNode(), tracktion::graph::ReturnNode::ReturnNode(), tracktion::graph::SendNode::SendNode(), and tracktion::graph::SilentNode::SilentNode().

◆ setAudioOutput()

void Node::setAudioOutput ( Node sourceNode,
const choc::buffer::ChannelArrayView< float > &  newAudioView 
)
protected

This can be called during your process function to set a view to the output.

This is useful to avoid having to allocate an internal buffer and always fill it if you're just passing on data.

References retain().

Referenced by tracktion::engine::LevelMeasurerProcessingNode::process(), tracktion::graph::SilentNode::process(), tracktion::graph::SendNode::process(), and tracktion::graph::ReturnNode::process().

Member Data Documentation

◆ internal

void* tracktion::graph::Node::internal = nullptr

◆ numOutputNodes

int tracktion::graph::Node::numOutputNodes = -1

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