Skip to main content

Audio Graph

About Audio Graphs

The Switchboard SDK implements the audio graph paradigm. An audio graph is a data structure used in audio programming to represent a collection of audio processing nodes and the connections between them.

In an audio graph, each processing node represents an audio processing unit, such as an oscillator, a filter, or a delay. The nodes are connected by audio buses, which represent the flow of audio data between the processing nodes. The audio graph can be thought of as a visual representation of the signal flow in an audio processing application.

The audio graph allows for flexible routing of audio data between processing nodes, which is important for complex signal processing applications. For example, an audio graph can represent a digital audio workstation (DAW), where the user can create and arrange audio processing nodes to process and mix multiple audio tracks. The audio graph allows the user to easily connect and disconnect audio processing nodes, change their parameters, and monitor the audio data at various points in the signal flow.

Audio Nodes

In the Switchboard SDK there are three kinds of audio nodes: source nodes, processor nodes and sink nodes.

Source Nodes

Source nodes are audio generators in the audio graph. They don't have inputs, only outputs.

Some examples:

Processor Nodes

Processor nodes receive audio on their input and also output audio.

Some examples:

  • GainNode: A node that changes the gain of an audio signal.
  • NoiseFilterNode: A node that filters noise from the audio signal.
  • CompressorNode: A node that applies dynamic range compression on the audio signal.
  • MixerNode / SplitterNode: A node that mixes / splits audio streams.

Sink Nodes

Sink nodes only receive audio in an audio graph. They don't have outputs, only inputs.

Some examples:

  • AudioGraphOutputNode: The output node of the audio graph.
  • RecorderNode: A node that records audio and saves it to a file.
  • VUMeterNode: A node that analysis the audio signal and reports its audio level.
  • VoiceCommandDetectorNode: A node that detects voice commands in the audio signal.

Connecting Nodes

Before connecting nodes in the audio graph, you need to add the nodes you wish to connect to the graph. Only valid connections return with a success result, for example, you cannot connect anything to a source node's input or a sink node's output. You must not create any connection loops, the audio graph has to be acyclic.

Some nodes support multiple connections (buses) while others support only one connection. For example, a mixer node can receive multiple node's output, but the splitter node can only receive one audio bus.

Nodes can only be disconnected and removed when the audio graph is not running.

{
"nodes": {
{ "id": "audioPlayerNode", "type": "AudioPlayerNode" },
{ "id": "gainNode", "type": "GainNode" },
{ "id": "recorderNode", "type": "RecorderNode" }
},
"connections": {
{ "sourceNode": "audioPlayerNode", "destinationNode": "gainNode" },
{ "sourceNode": "gainNode", "destinationNode": "recorderNode" }
}
}