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.
| Field | Type | Description |
|---|---|---|
sourceNode | String | ID of the source node, or nodeID.outputName to declare a data connection inline. |
destinationNode | String | ID of the destination node, or nodeID.inputName to declare a data connection inline. |
sourceBusIndex (Optional) | Integer | Zero-based output bus on the source node. Defaults to the first unused output bus. |
destinationBusIndex (Optional) | Integer | Zero-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.
| Field | Type | Description |
|---|---|---|
source | String | Source port, as nodeID.outputName. |
destination | String | Destination 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.
| Field | Type | Description |
|---|---|---|
id (Optional) | String | Identifier of the node within the graph. Referenced by connections. Auto-generated when omitted, which makes the node unreachable from connections. |
objectID (Optional) | objectID | Identifier of the object within its parent scope. |
type | String | Fully-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
| Name | Type | Description |
|---|---|---|
destination | String | Destination URI in the form '<nodeID>/actions/<actionName>'. |
source | String | Source 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
| Name | Type | Description |
|---|---|---|
config (Optional) | Object | Optional node-specific configuration map. |
id (Optional) | String | Optional object ID for the new node. Auto-generated if omitted. |
type | String | The 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
| Name | Type | Description |
|---|---|---|
destinationBusIndex (Optional) | Int | Input bus index on the destination node. First available bus is used if omitted. |
destinationNode | String | The ID of the destination node. |
sourceBusIndex (Optional) | Int | Output bus index on the source node. First available bus is used if omitted. |
sourceNode | String | The ID of the source node. |
Return Value
None.
disconnect
Removes an audio bus connection between two nodes. Fails while the graph is running.
Parameters
| Name | Type | Description |
|---|---|---|
destinationBusIndex | Int | Input bus index on the destination node. |
destinationNode | String | The ID of the destination node. |
sourceBusIndex | Int | Output bus index on the source node. |
sourceNode | String | The ID of the source node. |
Return Value
None.
removeConnection
Removes a data connection by ID.
Parameters
| Name | Type | Description |
|---|---|---|
id | String | The 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
| Name | Type | Description |
|---|---|---|
id | String | The ID of the node to remove. |
Return Value
None.
Events
This object does not provide any events.