|
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... | |
| struct | TransformOptions |
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. | |
| bool | canShareOutputBuffer () const |
| Returns true if downstream Nodes may adopt this Node's output buffer as their own process buffer, overwriting its contents. | |
| virtual TransformResult | transform (TransformOptions &) |
| 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 graph::PlaybackInitialisationInfo::allocateAudioBuffer, graph::PlaybackInitialisationInfo::blockSize, and graph::PlaybackInitialisationInfo::deallocateAudioBuffer.
| void Node::prepareForNextBlock | ( | juce::Range< int64_t > | referenceSampleRange | ) |
Call before processing the next block, used to reset the process status.
| 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! |
| bool Node::hasProcessed | ( | ) | const |
Returns true if this node has processed and its outputs can be retrieved.
| Node::AudioAndMidiBuffer Node::getProcessedOutput | ( | ) |
Returns the processed audio and MIDI output.
Must only be called after hasProcessed returns true.
| bool Node::canShareOutputBuffer | ( | ) | const |
Returns true if downstream Nodes may adopt this Node's output buffer as their own process buffer, overwriting its contents.
This is the default but Nodes whose buffer contents must persist between blocks can opt out with ShareOutputBuffer::no.
References graph::NodeOptimisations::share.
|
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.
Reimplemented in graph::ConnectedNode, graph::SummingNode, and graph::ReturnNode.
|
virtual |
Should return all the inputs directly feeding in to this node.
Reimplemented in graph::ConnectedNode, graph::LatencyNode, graph::SummingNode, graph::BasicSummingNode, graph::FunctionNode, graph::GainNode, graph::SendNode, graph::ReturnNode, and graph::SinkNode.
Referenced by graph::test_utilities::logGraph(), graph::node_player_utils::reserveAudioBufferPool(), graph::detail::VisitNodesWithRecordBFS::visit(), and 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.
Referenced by graph::addNodesRecursive().
|
pure virtual |
Should return the properties of the node.
This should not be called until after initialise.
Implemented in engine::WaveNodeRealTime, graph::ConnectedNode, graph::LatencyNode, graph::SummingNode, graph::MidiNode, graph::SinNode, graph::SilentNode, graph::BasicSummingNode, graph::FunctionNode, graph::GainNode, graph::SendNode, graph::ReturnNode, and graph::SinkNode.
Referenced by graph::addNodesRecursive(), and 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 engine::WaveNodeRealTime, graph::ConnectedNode, graph::LatencyNode, graph::SummingNode, graph::MidiNode, graph::SinNode, graph::SilentNode, graph::BasicSummingNode, graph::FunctionNode, graph::GainNode, graph::SendNode, graph::ReturnNode, and 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 setAudioOutput(), and setBufferViewToUse().
| 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.
|
virtual |
| void 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 engine::WaveNodeRealTime, graph::ConnectedNode, graph::LatencyNode, graph::SummingNode, graph::MidiNode, graph::SinNode, and graph::SilentNode.
|
protectedvirtual |
Called before once on all Nodes before they are processed.
This can be used to prefetch audio data or update mute statuses etc..
|
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 engine::WaveNodeRealTime, graph::ConnectedNode, graph::SinkNode, graph::LatencyNode, graph::SummingNode, graph::MidiNode, graph::SinNode, graph::SilentNode, graph::BasicSummingNode, graph::FunctionNode, graph::GainNode, graph::SendNode, and graph::ReturnNode.
|
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 graph::ReturnNode.
|
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.
|
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().
|
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().
| void* graph::Node::internal = nullptr |
| int graph::Node::numOutputNodes = -1 |