Skip to main content

Audio Graph

Holds audio nodes and the bus connections between them and processes them as one unit. The engine's audio enters through the built-in node with ID inputNode and leaves through outputNode. Nodes and connections can only be changed while the graph is not running.


Configuration​

bufferSize​

Type: Int

Default: 512
Minimum: 1

Number of frames per processing block when sampleRate is set. Ignored when sampleRate is 0.

connections​

Type: Array of Audio connection

Audio connections, each a map with sourceNode and destinationNode IDs and optional sourceBusIndex / destinationBusIndex. When a bus index is omitted, the first free bus is used.

FieldTypeDescription
sourceNodeStringID of the source node, or nodeID.outputName to declare a data connection inline.
destinationNodeStringID of the destination node, or nodeID.inputName to declare a data connection inline.
sourceBusIndex (Optional)IntegerZero-based output bus on the source node. Defaults to the first unused output bus.
destinationBusIndex (Optional)IntegerZero-based input bus on the destination node. Defaults to the first unused input bus.

dataConnections​

Type: Array of Data connection

Event-to-action connections, each a map with source (<nodeID>/events/<eventName>) and destination (<nodeID>/actions/<actionName>). When the event fires, its data is passed as the action's parameters.

FieldTypeDescription
sourceStringSource port, as nodeID.outputName.
destinationStringDestination port, as nodeID.inputName.

maxNumberOfChannels​

Type: Int

Default: 2
Minimum: 1

Maximum channels per internal audio bus. Sizes the pre-allocated buffer pool; must be >= the widest internal bus the graph will produce. A desktop Realtime engine refuses to start when the device stream is wider.

maxNumberOfFrames​

Type: Int

Default: 48000
Minimum: 1

Maximum frames per internal audio bus. Sizes the pre-allocated buffer pool; must be >= the largest per-call frame count the graph will process.

nodes​

Type: Array of Node

Nodes to create, each a map with type (e.g. Switchboard.Gain), an optional id and an optional config. The built-in inputNode and outputNode already exist and need no entry.

FieldTypeDescription
id (Optional)StringIdentifier of the node within the graph. Referenced by connections. Auto-generated when omitted, which makes the node unreachable from connections.
objectID (Optional)objectIDIdentifier of the object within its parent scope.
typeStringFully-qualified node type, e.g. Switchboard.AudioPlayer or Superpowered.Reverb. An unqualified name is matched against every registered node factory in turn.

numberOfInputs​

Type: Int

Default: 1
Minimum: 0

Number of input buses on the graph's inputNode, i.e. how many audio streams the engine feeds into the graph.

numberOfOutputs​

Type: Int

Default: 1
Minimum: 0

Number of output buses on the graph's outputNode, i.e. how many audio streams the graph hands back to the engine.

sampleRate​

Type: Int

Default: 0
Minimum: 0

Fixed processing sample rate, in Hz. When 0, the graph runs at whatever sample rate the engine delivers. Otherwise the engine's audio is resampled to this rate and rebuffered into blocks of bufferSize frames, and only the first input and output bus, with up to 2 channels, are carried through.


Properties​

Inherits properties from its parent, SwitchboardObject.

This object does not provide any additional properties.


Actions​

Inherits actions from its parent, SwitchboardObject.

addConnection​

Creates a data connection that calls an action on one node whenever another node emits an event, passing the event data as the action's parameters.

Parameters​

NameTypeDescription
destinationStringDestination URI in the form '<nodeID>/actions/<actionName>'.
sourceStringSource URI in the form '<nodeID>/events/<eventName>'.

Return Value​

String — Object ID of the created connection, for use with removeConnection. Matches the requested id when one was given, otherwise generated.

addNode​

Adds a node to the graph. Fails while the graph is running.

Parameters​

NameTypeDescription
config (Optional)ObjectOptional node-specific configuration map.
id (Optional)StringOptional object ID for the new node. Auto-generated if omitted.
typeStringThe fully-qualified node type to instantiate.

Return Value​

String — Object ID of the created node, for use in connections. Matches the requested id when one was given, otherwise generated.

connect​

Connects an output bus of one node to an input bus of another. Fails while the graph is running.

Parameters​

NameTypeDescription
destinationBusIndex (Optional)IntInput bus index on the destination node. First available bus is used if omitted.
destinationNodeStringThe ID of the destination node.
sourceBusIndex (Optional)IntOutput bus index on the source node. First available bus is used if omitted.
sourceNodeStringThe ID of the source node.

Return Value​

None.

disconnect​

Removes an audio bus connection between two nodes. Fails while the graph is running.

Parameters​

NameTypeDescription
destinationBusIndexIntInput bus index on the destination node.
destinationNodeStringThe ID of the destination node.
sourceBusIndexIntOutput bus index on the source node.
sourceNodeStringThe ID of the source node.

Return Value​

None.

removeConnection​

Removes a data connection by ID.

Parameters​

NameTypeDescription
idStringThe ID of the data connection to remove.

Return Value​

None.

removeNode​

Removes a node from the graph by ID. Fails while the graph is running.

Parameters​

NameTypeDescription
idStringThe ID of the node to remove.

Return Value​

None.


Events​

This object does not provide any events.