Skip to main content

Overview

The Switchboard SDK is a powerful tool for building and managing audio processing engines. It allows developers to design complex audio workflows using simple JSON configurations, enabling rapid prototyping and deployment. Once the audio engine is set up, its state can be dynamically modified with just a few API calls, providing flexibility and control for real-time audio applications.

Switchboard Objects

In the Switchboard V3 API, everything is a Switchboard Object:

Object TypeDescription
SDK InstanceThe main entry point for interacting with the Switchboard SDK.
EngineAudio processing engine that can run graphs.
GraphManaging and connecting nodes together.
NodesIndividual components within the graph that perform specific tasks.

Switchboard objects share a common behavior model that includes:

FeatureDescription
Configuration parametersUsed to create the object and may sometimes be immutable after creation.
ValuesAttributes of the object that can be either read-only or read-write.
ActionsFunctions that you can invoke to perform specific operations on the object.
EventsNotifications that you can subscribe to, allowing you to react to changes or actions.

Using the SDK

Creating and Destroying Objects

To work with Switchboard Objects, you typically create and destroy them using provided API methods.

// Creating an object
auto createResult = SwitchboardV3::createEngine(engineConfig);
// Destroying an object
auto destroyResult = SwitchboardV3::destroyObject(objectID);

Read-write values, which can be configured through the provided configuration parameters. These parameters allow you to define the initial state of the object and specify attributes that can be dynamically updated during runtime.

Getting and Setting Values

Switchboard Objects have attributes called Values that can be either read-only or read-write. You can retrieve or modify these values using the provided API methods.

// Getting a value
auto volume = SwitchboardV3::getValue("gainNode", "gain");

// Setting a value
auto setResult = SwitchboardV3::setValue("gainNode", "gain", 0.8);

Values allow you to configure and query the state of objects dynamically, enabling flexible control over your audio processing pipeline.

Calling Actions

Switchboard Objects support Actions, which are functions you can invoke to perform specific operations. Actions allow you to trigger behaviors or processes on an object dynamically.

// Calling an action
auto result = SwitchboardV3::callAction("ttsNode", "synthesize", { { "text", text } });

In the example above, the callAction method is used to invoke the synthesize action on a Text-to-Speech (TTS) node, passing the required parameters as a key-value map. This enables you to interact with objects in a flexible and extensible way.

Subscribing to Events

Switchboard Objects emit Events that you can subscribe to in order to react to changes or specific actions. Events provide a mechanism for asynchronous communication, enabling you to handle updates dynamically.

// Subscribing to an event
SwitchboardV3::addEventListener("sttNode", "transcription", [](const std::any& data) {
const auto text = std::any_cast<std::string>(data);
std::cout << "STT node transcribed: " << text << std::endl;
});

// Unsubscribing from an event
SwitchboardV3::removeEventListener("sttNode", "transcription");

In the example above, the addEventListener method is used to subscribe to the transcription event on a Speech-to-Text (STT) node. The callback function processes the event data, allowing you to handle the transcription results. To stop receiving updates, you can use the removeEventListener method.

List of Objects

Engines

TypeDescription
Real-timeRuns a graph in real-time using the system audio I/O.
OfflineProcesses a graph with audio file inputs and outputs.
ManualManually processing audio buffers.
WebSocketProcessing audio coming on a WebSocket channel.

Graphs

There is only a single implementation of AudioGraph which you can read about here.

Nodes

TypeDescription
AudioPlayerPlays audio from a buffer or file source, functioning as a basic audio source.
BusSelectSelects a specific audio bus from a multi-bus stream for further processing.
BusSplitterSplits an incoming audio signal into individual bus outputs.
ChannelSplitterDivides a multi-channel audio signal into separate single-channel outputs.
ClippingDetectorDetects when an audio signal exceeds the maximum level, potentially causing distortion.
DiscardDiscards incoming audio without processing or forwarding it.
GainA node that adjusts the amplitude of the audio signal, effectively controlling its volume.
MixerCombines multiple audio inputs into a single output mix.
MonoBusMergerMerges several mono audio buses into a single bus multi-channel output.
MonoToMultiChannelConverts a mono signal into a multi-channel output by duplicating the input.
MultiChannelToMonoMixes multiple channels down into a single mono signal.
MusicDuckingLowers background music volume when another signal, like voice, is detected.
MuteSilences the audio signal without stopping the stream.
NoiseGateSuppresses signals below a certain threshold, reducing background noise.
PassthroughForwards audio without modification, useful for routing or diagnostics.
RecorderCaptures incoming audio and stores it for playback or export.
ResampedSinkReceives audio and resamples it to a different sample rate for an embedded audio node.
ResampledSourceOutputs audio that has been resampled from another sample rate of an embedded audio node.
ResamplerChanges the sample rate of the audio stream.
SilenceGenerates a silent audio signal, typically used for timing or control.
SineGeneratorA node that generates a sine wave signal, often used for testing or as a basic audio source.
StereoBusMergerMerges multiple stereo buses into a unified stereo bus output.
StereoPannerAdjusts the left-right stereo balance of the audio signal.
SubgraphProcessorProcesses audio using a subgraph, allowing for modular and reusable signal chains.
SubgraphSinkAudio sink that embeds another audio graph.
SubgraphSourceAudio source that embeds another audio graph.
SynchronizedAudioPlayerPlays audio in sync with a timeline or other synchronized events.
TimelineManages time-based events and synchronization within an audio graph.
TimelineQuantizedTriggerTriggers actions aligned to timeline quantization points, useful for music timing.
VoiceActivityDetectorDetects the presence of voice in an audio stream for use in gating or ducking.
VUMeterMeasures audio signal levels for monitoring purposes.
WhiteNoiseGeneratorProduces a white noise signal, often used for testing or audio masking.

Extensions

The list of available nodes can be expanded by implementing a custom Switchboard SDK extension. For more details on how to create your own extension, please contact us.