TracktionEngine
|
Main graph Node processor class. More...
#include <tracktion_Node.h>
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. | |
void | prepareForNextBlock (juce::Range< int64_t > referenceSampleRange) |
Call before processing the next block, used to reset the process status. | |
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. | |
bool | hasProcessed () const |
Returns true if this node has processed and its outputs can be retrieved. | |
AudioAndMidiBuffer | getProcessedOutput () |
Returns the processed audio and MIDI output. | |
virtual TransformResult | transform (Node &, const std::vector< Node * > &, TransformCache &) |
Called after construction to give the node a chance to modify its topology. | |
virtual std::vector< Node * > | getDirectInputNodes () |
Should return all the inputs directly feeding in to this node. | |
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(). | |
virtual NodeProperties | getNodeProperties ()=0 |
Should return the properties of the node. | |
virtual bool | isReadyToProcess ()=0 |
Should return true when this node is ready to be processed. | |
void | retain () |
Retains the buffers so they won't be deallocated after the Node has processed. | |
void | release () |
Releases the buffers allowing internal storage to be deallocated. | |
virtual size_t | getAllocatedBytes () const |
void | enablePreProcess (bool) |
Public Attributes | |
void * | internal = nullptr |
int | numOutputNodes = -1 |
Protected Member Functions | |
virtual void | prepareToPlay (const PlaybackInitialisationInfo &) |
Called once before playback begins for each node. | |
virtual void | prefetchBlock (juce::Range< int64_t >) |
Called before once on all Nodes before they are processed. | |
virtual void | process (ProcessContext &)=0 |
Called when the node is to be processed. | |
virtual void | preProcess (choc::buffer::FrameCount, juce::Range< int64_t >) |
Called when the node is to be processed, just before process. | |
void | setOptimisations (NodeOptimisations) |
This can be called to provide some hints about allocating or playing back a Node to improve efficiency. | |
void | setBufferViewToUse (Node *sourceNode, const choc::buffer::ChannelArrayView< float > &) |
This can be called during prepareToPlay to set a BufferView to use which can improve efficiency. | |
void | setAudioOutput (Node *sourceNode, const choc::buffer::ChannelArrayView< float > &) |
This can be called during your process function to set a view to the output. | |
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.
|
default |
|
virtualdefault |
void Node::initialise | ( | const PlaybackInitialisationInfo & | info | ) |
Call once after the graph has been constructed to initialise buffers etc.
References tracktion::graph::NodeOptimisations::allocate, tracktion::graph::PlaybackInitialisationInfo::allocateAudioBuffer, tracktion::graph::PlaybackInitialisationInfo::blockSize, tracktion::graph::PlaybackInitialisationInfo::deallocateAudioBuffer, getDirectInputNodes(), getNodeProperties(), prepareToPlay(), and tracktion::graph::yes.
void Node::prepareForNextBlock | ( | juce::Range< int64_t > | referenceSampleRange | ) |
Call before processing the next block, used to reset the process status.
References prefetchBlock(), and retain().
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.
numSamples | The number of samples that need to be processed. |
referenceSampleRange | The 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, preProcess(), process(), release(), and tracktion::graph::yes.
Referenced by process().
bool Node::hasProcessed | ( | ) | const |
Returns true if this node has processed and its outputs can be retrieved.
Referenced by getProcessedOutput(), tracktion::graph::LatencyNode::isReadyToProcess(), and tracktion::graph::ForwardingNode::isReadyToProcess().
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(), and tracktion::graph::ForwardingNode::process().
|
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.
postOrderedNodes | This is an ordered list obtained from visiting all the Nodes and can be used for quicker introspection of the graph |
TransformCache | A cache which can be used to speed up operations during the transform stage. |
Reimplemented in tracktion::graph::ConnectedNode, tracktion::graph::SummingNode, and tracktion::graph::ReturnNode.
References tracktion::graph::none.
|
virtual |
Should return all the inputs directly feeding in to this node.
Reimplemented in tracktion::engine::ArrangerLauncherSwitchingNode, tracktion::engine::ClickNode, tracktion::engine::CombiningNode, tracktion::engine::ContainerClipNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::InsertNode, tracktion::engine::InsertSendNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::LevelMeasuringNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::MelodyneNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::ModifierNode, tracktion::engine::PlayHeadPositionNode, tracktion::engine::PluginNode, tracktion::engine::RackInstanceNode, tracktion::engine::RackReturnNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::SlotControlNode, tracktion::engine::TimedMutingNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::graph::ConnectedNode, tracktion::graph::LatencyNode, tracktion::graph::SummingNode, tracktion::graph::ForwardingNode, tracktion::graph::BasicSummingNode, tracktion::graph::FunctionNode, tracktion::graph::GainNode, tracktion::graph::SendNode, tracktion::graph::ReturnNode, tracktion::graph::ChannelRemappingNode, and tracktion::graph::SinkNode.
Referenced by initialise(), tracktion::graph::test_utilities::logGraph(), tracktion::graph::node_player_utils::reserveAudioBufferPool(), tracktion::graph::detail::VisitNodesWithRecordBFS::visit(), and tracktion::graph::detail::VisitNodesWithRecord::visit().
|
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::ArrangerLauncherSwitchingNode, tracktion::engine::CombiningNode, tracktion::engine::ContainerClipNode, and tracktion::engine::DynamicOffsetNode.
|
pure virtual |
Should return the properties of the node.
This should not be called until after initialise.
Implemented in tracktion::engine::ArrangerLauncherSwitchingNode, tracktion::engine::AuxSendNode, tracktion::engine::ClickNode, tracktion::engine::CombiningNode, tracktion::engine::ContainerClipNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::HostedMidiInputDeviceNode, tracktion::engine::InsertNode, tracktion::engine::InsertSendNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::LevelMeasuringNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::LoopingMidiNode, tracktion::engine::MelodyneNode, tracktion::engine::MidiInputDeviceNode, tracktion::engine::MidiNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::ModifierNode, tracktion::engine::PlayHeadPositionNode, tracktion::engine::PluginNode, tracktion::engine::RackInstanceNode, tracktion::engine::RackReturnNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::SlotControlNode, tracktion::engine::SpeedRampWaveNode, tracktion::engine::TimedMutingNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::engine::WaveInputDeviceNode, tracktion::engine::WaveNode, tracktion::engine::WaveNodeRealTime, tracktion::graph::ConnectedNode, tracktion::graph::LatencyNode, tracktion::graph::SummingNode, tracktion::graph::ForwardingNode, tracktion::graph::MidiNode, tracktion::graph::SinNode, tracktion::graph::SilentNode, tracktion::graph::BasicSummingNode, tracktion::graph::FunctionNode, tracktion::graph::GainNode, tracktion::graph::SendNode, tracktion::graph::ReturnNode, tracktion::graph::ChannelRemappingNode, and tracktion::graph::SinkNode.
Referenced by tracktion::graph::LatencyNode::getNodeProperties(), tracktion::graph::ForwardingNode::getNodeProperties(), initialise(), and tracktion::graph::node_player_utils::reserveAudioBufferPool().
|
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::engine::ArrangerLauncherSwitchingNode, tracktion::engine::ClickNode, tracktion::engine::CombiningNode, tracktion::engine::ContainerClipNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::HostedMidiInputDeviceNode, tracktion::engine::InsertNode, tracktion::engine::InsertSendNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::LevelMeasuringNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::LoopingMidiNode, tracktion::engine::MelodyneNode, tracktion::engine::MidiInputDeviceNode, tracktion::engine::MidiNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::ModifierNode, tracktion::engine::PlayHeadPositionNode, tracktion::engine::PluginNode, tracktion::engine::RackInstanceNode, tracktion::engine::RackReturnNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::SlotControlNode, tracktion::engine::SpeedRampWaveNode, tracktion::engine::TimedMutingNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::engine::WaveInputDeviceNode, tracktion::engine::WaveNode, tracktion::engine::WaveNodeRealTime, tracktion::graph::ConnectedNode, tracktion::graph::LatencyNode, tracktion::graph::SummingNode, tracktion::graph::ForwardingNode, tracktion::graph::MidiNode, tracktion::graph::SinNode, tracktion::graph::SilentNode, tracktion::graph::BasicSummingNode, tracktion::graph::FunctionNode, tracktion::graph::GainNode, tracktion::graph::SendNode, tracktion::graph::ReturnNode, tracktion::graph::ChannelRemappingNode, and tracktion::graph::SinkNode.
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(), setAudioOutput(), and setBufferViewToUse().
void Node::release | ( | ) |
|
virtual |
Reimplemented in tracktion::engine::CombiningNode.
void tracktion::graph::Node::enablePreProcess | ( | bool | ) |
|
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::WaveNodeRealTime, tracktion::graph::ConnectedNode, tracktion::graph::LatencyNode, tracktion::graph::SummingNode, tracktion::graph::MidiNode, tracktion::graph::SinNode, tracktion::graph::SilentNode, tracktion::engine::AuxSendNode, tracktion::engine::ClickNode, tracktion::engine::CombiningNode, tracktion::engine::ContainerClipNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::HostedMidiInputDeviceNode, tracktion::engine::InsertNode, tracktion::engine::InsertSendNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::LoopingMidiNode, tracktion::engine::MelodyneNode, tracktion::engine::MidiInputDeviceNode, tracktion::engine::MidiNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::ModifierNode, tracktion::engine::PluginNode, tracktion::engine::RackInstanceNode, tracktion::engine::RackReturnNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::SlotControlNode, tracktion::engine::SpeedRampWaveNode, tracktion::engine::TimedMutingNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::engine::WaveInputDeviceNode, tracktion::engine::WaveNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::PlayHeadPositionNode, and tracktion::graph::ReturnNode.
Referenced by initialise().
|
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::ArrangerLauncherSwitchingNode, tracktion::engine::CombiningNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::PluginNode, tracktion::engine::RackInstanceNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::SlotControlNode, and tracktion::engine::TrackMutingNode.
Referenced by prepareForNextBlock().
|
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::ArrangerLauncherSwitchingNode, tracktion::engine::AuxSendNode, tracktion::engine::ClickNode, tracktion::engine::CombiningNode, tracktion::engine::ContainerClipNode, tracktion::engine::DynamicOffsetNode, tracktion::engine::HostedMidiInputDeviceNode, tracktion::engine::InsertNode, tracktion::engine::InsertSendNode, tracktion::engine::LiveMidiInjectingNode, tracktion::engine::LiveMidiOutputNode, tracktion::engine::LoopingMidiNode, tracktion::engine::MelodyneNode, tracktion::engine::MidiInputDeviceNode, tracktion::engine::MidiNode, tracktion::engine::MidiOutputDeviceInstanceInjectingNode, tracktion::engine::ModifierNode, tracktion::engine::PluginNode, tracktion::engine::RackInstanceNode, tracktion::engine::RackReturnNode, tracktion::engine::SharedLevelMeasuringNode, tracktion::engine::SlotControlNode, tracktion::engine::SpeedRampWaveNode, tracktion::engine::TimedMutingNode, tracktion::engine::TimeStretchingWaveNode, tracktion::engine::TrackMidiInputDeviceNode, tracktion::engine::TrackMutingNode, tracktion::engine::TrackWaveInputDeviceNode, tracktion::engine::WaveInputDeviceNode, tracktion::engine::WaveNode, tracktion::engine::WaveNodeRealTime, tracktion::graph::ConnectedNode, tracktion::graph::SinkNode, tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::PlayHeadPositionNode, tracktion::graph::LatencyNode, tracktion::graph::SummingNode, tracktion::graph::ForwardingNode, tracktion::graph::MidiNode, tracktion::graph::SinNode, tracktion::graph::SilentNode, tracktion::graph::BasicSummingNode, tracktion::graph::FunctionNode, tracktion::graph::GainNode, tracktion::graph::SendNode, tracktion::graph::ReturnNode, tracktion::graph::ChannelRemappingNode, and tracktion::engine::LevelMeasuringNode.
|
protectedvirtual |
Called when the node is to be processed, just before process.
You shouldn't normally have to use this but it gives Nodes an opportunity to perform optimisations like steal input buffers from source if appropriate.
Reimplemented in tracktion::engine::LevelMeasurerProcessingNode, tracktion::engine::PluginNode, tracktion::engine::RackInstanceNode, tracktion::engine::RackReturnNode, tracktion::engine::TrackMutingNode, and tracktion::graph::ReturnNode.
Referenced by process().
|
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::LatencyNode::LatencyNode(), tracktion::graph::LatencyNode::LatencyNode(), tracktion::engine::PlayHeadPositionNode::PlayHeadPositionNode(), tracktion::engine::LevelMeasurerProcessingNode::prepareToPlay(), tracktion::graph::ReturnNode::prepareToPlay(), tracktion::graph::ReturnNode::ReturnNode(), and tracktion::graph::SilentNode::SilentNode().
|
protected |
This can be called during prepareToPlay to set a BufferView to use which can improve efficiency.
Be careful with this. It's intended to use an input buffer as the internal buffer for this Node but that can only be done if the input Node only has a single output (or this Node doesn't write to it).
References retain().
Referenced by tracktion::engine::LevelMeasurerProcessingNode::preProcess(), and tracktion::graph::ReturnNode::preProcess().
|
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::engine::PlayHeadPositionNode::process(), tracktion::graph::SilentNode::process(), tracktion::graph::SendNode::process(), and tracktion::graph::ReturnNode::process().
void* tracktion::graph::Node::internal = nullptr |
int tracktion::graph::Node::numOutputNodes = -1 |