#include <audio/core/audionodemanager.h>
Public Types | |
using | OutputMapping = std::vector< std::vector< SampleBuffer * > > |
Public Member Functions | |
NodeManager (DeletionQueue &deletionQueue) | |
~NodeManager () | |
void | process (float **inputBuffer, float **outputBuffer, unsigned long framesPerBuffer) |
void | process (std::vector< SampleBuffer * > &inputBuffer, std::vector< SampleBuffer * > &outputBuffer, unsigned long framesPerBuffer) |
void | enqueueTask (nap::TaskQueue::Task task) |
int | getInputChannelCount () const |
int | getOutputChannelCount () const |
float | getSampleRate () const |
float | getSamplesPerMillisecond () const |
int | getInternalBufferSize () const |
const DiscreteTimeValue & | getSampleTime () const |
void | setInputChannelCount (int inputChannelCount) |
void | setOutputChannelCount (int outputChannelCount) |
void | setSampleRate (float sampleRate) |
void | setInternalBufferSize (int size) |
void | registerRootProcess (Process &rootProcess) |
void | unregisterRootProcess (Process &rootProcess) |
template<typename T , typename... Args> | |
SafeOwner< T > | makeSafe (Args &&... args) |
template<typename T > | |
SafeOwner< T > | makeSafe (T *ptr) |
DeletionQueue & | getDeletionQueue () |
Public Attributes | |
Signal< DiscreteTimeValue > | mUpdateSignal |
Signal< NodeManager & > | mChannelCountChangedSignal |
The audio node manager represents a node system for audio processing. The nodes in the system can have multiple inputs and outputs that can be connected between different nodes. A connection represents a mono audio signal. Does not own the nodes but maintains a list of existing nodes that is updated from the node's constructor end destructors.
using OutputMapping = std::vector<std::vector<SampleBuffer*> > |
NodeManager | ( | DeletionQueue & | deletionQueue | ) |
~NodeManager | ( | ) |
void enqueueTask | ( | nap::TaskQueue::Task | task | ) |
Enqueue a lambda to be executed before the processing of the next internal buffer starts. This way modifications to the processing chain can be made in a threadsafe manner from outside of the audio thread, with a timing accuracy that corresponds to the internal buffer size.
task | Lamba without arguments that will be called on the next audio callback |
DeletionQueue& getDeletionQueue | ( | ) |
Returns the DeletionQueue that this node manager uses to construct and destruct nodes or other processes on the audio thread safely.
int getInputChannelCount | ( | ) | const |
int getInternalBufferSize | ( | ) | const |
int getOutputChannelCount | ( | ) | const |
float getSampleRate | ( | ) | const |
float getSamplesPerMillisecond | ( | ) | const |
const DiscreteTimeValue& getSampleTime | ( | ) | const |
SafeOwner<T> makeSafe | ( | Args &&... | args | ) |
Constructs an object managed by a SafeOwner that will dispose the object in the NodeManager's DeletionQueue when it is no longer used. This will make sure the object is always destructed by the audio thread, so after going out of scope it can be safely referred until the next audio callback cycle.
T | The type of the object retained by the newly constructed SafeOwner. |
args | The arguments passed to the constructor of the object that will be retained by the newly created SafeOwner |
SafeOwner<T> makeSafe | ( | T * | ptr | ) |
Make an object to be retained by a SafeOwner that will dispose the object in the NodeManager's DeletionQueue when it is no longer used. This will make sure the object is always destructed by the audio thread, so after going out of scope it can be safely referred until the next audio callback cycle.
T | The type of the object to be retained by the newly constructed SafeOwner |
ptr | Pointer to the object to be retained |
void process | ( | float ** | inputBuffer, |
float ** | outputBuffer, | ||
unsigned long | framesPerBuffer | ||
) |
This function is typically called by an audio callback to perform all the audio processing. It feeds the inputbuffer to the audio input nodes and polls the audio output nodes for output.
inputBuffer | an array of float arrays, representing one sample buffer for every channel |
outputBuffer | an array of float arrays, representing one sample buffer for every channel |
framesPerBuffer | the number of samples that has to be processed per channel |
void process | ( | std::vector< SampleBuffer * > & | inputBuffer, |
std::vector< SampleBuffer * > & | outputBuffer, | ||
unsigned long | framesPerBuffer | ||
) |
This function is typically called by an audio callback to perform all the audio processing. It feeds the inputbuffer to the audio input nodes and polls the audio output nodes for output.
inputBuffer | a vector of sample buffers, representing one sample buffer for every channel |
outputBuffer | a vector of sample buffers, representing one sample buffer for every channel |
framesPerBuffer | the number of samples that has to be processed per channel |
void registerRootProcess | ( | Process & | rootProcess | ) |
Used by nodes to register themselves to be processed directly by the node manager
rootProcess | The root process is a process or node that is executed on every audio callback without being connected to an input of another node. In most cases the root process is an OutputNode. |
void setInputChannelCount | ( | int | inputChannelCount | ) |
Sets the number of input channels that will be fed into the node system
inputChannelCount | the number of input channels |
void setInternalBufferSize | ( | int | size | ) |
Changes the internal buffer size that the node system uses. The internal buffer size determines the timing accuracy of state changes within the node system. The internal buffer size needs to fit a discrete amount of times into the audio callback's buffer size. Beware: this can be smaller than the buffersize the audio device is running on.
size | the new buffer size |
void setOutputChannelCount | ( | int | outputChannelCount | ) |
Sets the number of output channels that will be processed by the node system
outputChannelCount | the number of output channels that the node system provides audio to |
void setSampleRate | ( | float | sampleRate | ) |
Changes the sample rate the node system is running on. This method is normally called by the AudioService.
sampleRate | the sample rate in Hz |
void unregisterRootProcess | ( | Process & | rootProcess | ) |
Used by nodes to unregister themselves to be processed directly by the node manager.
rootProcess | The root process is a process or node that is executed on every audio callback without being connected to an input of another node. In most cases the root process is an OutputNode. |
Signal<NodeManager&> mChannelCountChangedSignal |
Signal triggered whenever the input or output channel count of the node manager changes
Signal<DiscreteTimeValue> mUpdateSignal |
This signal is emitted from the process() function after processing every internal buffer of audio.