Switchboard SDK
Loading...
Searching...
No Matches
switchboard::AudioGraph Class Reference

Manages a graph of AudioNode instances. More...

#include <AudioGraph.hpp>

Public Member Functions

 WASM_EXPORT (AudioGraph)
 
WASM AudioGraph (const uint maxNumberOfChannels=constants::STEREO, const uint maxNumberOfFrames=constants::MAX_NUMBER_OF_FRAMES)
 Creates an AudioGraph.
 
WASM ~AudioGraph ()
 AudioGraph destructor.
 
WASM const AudioGraphInputNodegetInputNode () const
 Returns the input node of the audio graph.
 
WASM const AudioGraphOutputNodegetOutputNode () const
 Returns the output node of the audio graph.
 
WASM bool addNode (AudioNode &audioNode, bool moveOwnership=false)
 Adds a node to the audio graph.
 
WASM bool removeNode (AudioNode &audioNode)
 Removes a node from the audio graph.
 
const std::vector< AudioNode * > & getNodes () const
 Gets a list of all audio nodes in the audio graph.
 
AudioNodegetNodeByName (const std::string &name) const
 Finds an audio node by name.
 
WASM AudioNodegetNodeByName (const char *name) const
 Finds an audio node by name.
 
WASM bool connect (const AudioSourceNode &srcNode, const AudioProcessorNode &dstNode)
 Connects a source node to a processor node.
 
WASM bool connect (const AudioSourceNode &srcNode, const AudioSinkNode &dstNode)
 Connects a source node to a sink node.
 
WASM bool connect (const AudioProcessorNode &srcNode, const AudioProcessorNode &dstNode)
 Connects a processor node to another processor node.
 
WASM bool connect (const AudioProcessorNode &srcNode, const AudioSinkNode &dstNode)
 Connects a processor node to a sink node.
 
WASM bool start ()
 Starts the audio graph.
 
WASM void stop ()
 Stops the audio graph.
 
WASM bool isRunning ()
 Checks if the audio graph has been started.
 
WASM bool process (AudioBusList &inAudioBuses, AudioBusList &outAudioBuses)
 The real-time audio process function of the audio graph.
 
WASM bool processBuffer (AudioBuffer< float > *inAudioBuffer, AudioBuffer< float > *outAudioBuffer)
 The real-time audio process function of the audio graph that processes audio buffers.
 

Public Attributes

const uint maxNumberOfChannels
 Maximum number of channels that is supported by the audio graph.
 
const uint maxNumberOfFrames
 Maximum number of frames that is supported by the audio graph.
 

Detailed Description

Manages a graph of AudioNode instances.

AudioGraph class.

This class can be used to easily put together complicated audio pipelines by adding and then connecting AudioNode instances together.

Constructor & Destructor Documentation

◆ AudioGraph()

switchboard::AudioGraph::AudioGraph ( const uint maxNumberOfChannels = constants::STEREO,
const uint maxNumberOfFrames = constants::MAX_NUMBER_OF_FRAMES )

Creates an AudioGraph.

Parameters
maxNumberOfChannelsMaximum number of channels that is supported by the audio graph.
maxNumberOfFramesMaximum number of frames that is supported by the audio graph.

Member Function Documentation

◆ addNode()

bool switchboard::AudioGraph::addNode ( AudioNode & audioNode,
bool moveOwnership = false )

Adds a node to the audio graph.

Parameters
audioNodeThe node to be added.
moveOwnershipIf set to true, the AudioGraph will destruct the audio node.
Returns
True if the node was successfully added, false otherwise.

◆ connect() [1/4]

bool switchboard::AudioGraph::connect ( const AudioProcessorNode & srcNode,
const AudioProcessorNode & dstNode )

Connects a processor node to another processor node.

Parameters
srcNodeThe source processor node.
dstNodeThe destination processor node.
Returns
True if the nodes were successfully connected, false otherwise.

◆ connect() [2/4]

bool switchboard::AudioGraph::connect ( const AudioProcessorNode & srcNode,
const AudioSinkNode & dstNode )

Connects a processor node to a sink node.

Parameters
srcNodeThe processor node.
dstNodeThe sink node.
Returns
True if the nodes were successfully connected, false otherwise.

◆ connect() [3/4]

bool switchboard::AudioGraph::connect ( const AudioSourceNode & srcNode,
const AudioProcessorNode & dstNode )

Connects a source node to a processor node.

Parameters
srcNodeThe source node.
dstNodeThe processor node.
Returns
True if the nodes were successfully connected, false otherwise.

◆ connect() [4/4]

bool switchboard::AudioGraph::connect ( const AudioSourceNode & srcNode,
const AudioSinkNode & dstNode )

Connects a source node to a sink node.

Parameters
srcNodeThe source node.
dstNodeThe sink node.
Returns
True if the nodes were successfully connected, false otherwise.

◆ getInputNode()

const AudioGraphInputNode & switchboard::AudioGraph::getInputNode ( ) const

Returns the input node of the audio graph.

Returns
The input node.

◆ getNodeByName() [1/2]

AudioNode * switchboard::AudioGraph::getNodeByName ( const char * name) const

Finds an audio node by name.

Parameters
nameThe name of the audio node.
Returns
The found audio node, or nullptr if the audio node could not be found.

◆ getNodeByName() [2/2]

AudioNode * switchboard::AudioGraph::getNodeByName ( const std::string & name) const

Finds an audio node by name.

Parameters
nameThe name of the audio node.
Returns
The found audio node, or nullptr if the audio node could not be found.

◆ getNodes()

const std::vector< AudioNode * > & switchboard::AudioGraph::getNodes ( ) const

Gets a list of all audio nodes in the audio graph.

Returns
A vector with all the audio nodes in the audio graph.

◆ getOutputNode()

const AudioGraphOutputNode & switchboard::AudioGraph::getOutputNode ( ) const

Returns the output node of the audio graph.

Returns
The output node.

◆ isRunning()

bool switchboard::AudioGraph::isRunning ( )

Checks if the audio graph has been started.

Returns
True if the audio graph was already started successfully, false otherwise.

◆ process()

bool switchboard::AudioGraph::process ( AudioBusList & inAudioBuses,
AudioBusList & outAudioBuses )

The real-time audio process function of the audio graph.

Processes the audio in the provided input audio buses and puts the output audio in the provided output audio buses.

Parameters
inAudioBusesThe input audio buses.
outAudioBusesThe output audio buses.
Returns
True if the process call was successful, false otherwise.

◆ processBuffer()

bool switchboard::AudioGraph::processBuffer ( AudioBuffer< float > * inAudioBuffer,
AudioBuffer< float > * outAudioBuffer )

The real-time audio process function of the audio graph that processes audio buffers.

Processes the audio in the provided input audio buffer and puts the output audio in the provided output audio buffer. This is a convenience method that can be used when the audio graph has no more than one input and output buses. To process multiple buses, use the process method.

Parameters
inAudioBufferThe input audio buffer, or null if there graph has no input.
outAudioBufferThe output audio buffer, or null if the graph has no output.
Returns
True if the process call was successful, false otherwise.

◆ removeNode()

bool switchboard::AudioGraph::removeNode ( AudioNode & audioNode)

Removes a node from the audio graph.

Parameters
audioNodeThe node to be removed.
Returns
True if the node was successfully removed, false otherwise.

◆ start()

WASM bool switchboard::AudioGraph::start ( )

Starts the audio graph.

Returns
True if the audio graph was started successfully, false otherwise.