SDK Instance
Initializes the SDK, creates and destroys engines, lists the registered engine, node and object types, and manages the files in the asset directories. This is the top-level object with ID switchboard, the parent of all engines, graphs and extensions.
Initializing the SDK
To initialize the Switchboard SDK, call the Switchboard.initialize method and pass in a configuration map. The configuration map should include the parameters described in the Configuration section below.
The method returns the object ID of the SDK instance, which can be used in subsequent calls. Note that only one instance of the SDK can exist at a time.
- C++
Config sdkConfig({
{ "appID", "demo" },
{ "appSecret", "demo" }
});
const Result<ObjectID> result = Switchboard::initialize(sdkConfig);
Deinitializing the SDK
To deinitialize the Switchboard SDK, call the Switchboard.deinitialize method. This will clean up all resources associated with the SDK, and any objects created by the SDK will be destroyed. It is important to ensure that the SDK is deinitialized when it is no longer needed to avoid resource leaks.
- C++
const Result<void> result = Switchboard::deinitialize();
Configuration
This object does not provide any configuration options.
Properties
Inherits properties from its parent, SwitchboardObject.
androidNativeLibraryDir (Read only)
Type: String
Android only. The directory the Android installer extracted the app's bundled native libraries to. Requires the extractNativeLibs flag in the AndroidManifest and useLegacyPackaging in the Gradle config. Empty on other platforms or when the path is not available.
appID (Read only)
Type: String
The app ID passed to initialize, as provided by Synervoz.
backgroundAudioEnabled (Read only)
Type: Boolean
Whether the host app declares background audio (audio in UIBackgroundModes in its Info.plist). When true, a running engine keeps capturing and playing while the app is in the background. On iOS and watchOS the SDK logs a warning at initialization when it is false. Always false on Android, Windows and Linux.
buildNumber (Read only)
Type: Int
The build number of the Switchboard SDK.
engines (Read only)
Type: Array
Array of the object IDs of the engines that currently exist.
hostAppVersion
Type: String
Default: ""
The version of the application integrating the SDK (set by the host app, e.g. switchboard-server).
isInitialized (Read only)
Type: Boolean
Whether initialize has completed successfully.
loadedExtensions (Read only)
Type: Array
Array of the names of the loaded extensions.
logLevel
Type: String
Default: "info"
Options: none, error, warning, info, debug, trace
Minimum severity of the messages the SDK logs; none turns logging off.
maxNumberOfFrames (Read only)
Type: Int
Unit: frames
The largest number of frames per buffer the SDK's internal buffers are sized for, one second of audio at 48 kHz. It is also the default maxNumberOfFrames of an audio graph.
tempDirPath
Type: String
Default: ""
Directory the SDK uses for temporary files, created if it does not exist. Set at initialization to the tempDirPath passed to initialize, or to the platform's temporary directory.
versionName (Read only)
Type: String
The version name of the Switchboard SDK.
Actions
Inherits actions from its parent, SwitchboardObject.
createEngine
Creates an engine. The parameters are the engine definition itself: type (e.g. Switchboard.Realtime), an optional id, and config. Fails if the SDK is not initialized or the ID is already taken.
Parameters
| Name | Type | Description |
|---|---|---|
config | Object | The engine's configuration map, as described by the engine type. |
Return Value
String — Object ID of the created engine, for use in later calls.
deinitialize
Deinitializes the SDK: ends the license session and deinitializes all extensions.
Parameters
None.
Return Value
None.
deleteFile
Deletes a file inside one of the asset directories.
Parameters
| Name | Type | Description |
|---|---|---|
path | String | Path of the file, which may start with an asset alias and must lie inside one of the asset directories. |
Return Value
None.
destroyEngine
Destroys the engine with the given object ID.
Parameters
| Name | Type | Description |
|---|---|---|
engineID | String | Object ID of the engine to destroy, as returned by createEngine. |
Return Value
None.
downloadFile
Reads a file inside one of the asset directories and returns it with its contents base64-encoded.
Parameters
| Name | Type | Description |
|---|---|---|
path | String | Path of the file, which may start with an asset alias and must lie inside one of the asset directories. |
Return Value
Object — Map with the file's path, name, size, mimeType and base64-encoded data.
getEngineTypes
Returns the list of all registered engine types.
Parameters
None.
Return Value
Array — Fully-qualified engine type names, e.g. Switchboard.Realtime.
getNodeTypes
Returns the list of all registered node types.
Parameters
None.
Return Value
Array — Node type descriptors, one per registered node type.
getObjectTypes
Returns the list of all registered object types, optionally filtered by object kind.
Parameters
| Name | Type | Description |
|---|---|---|
type (Optional) | String | Optional object kind filter (e.g. "switchboard", "engine", "graph", "node", "extension"). If omitted, returns all registered object types. |
Return Value
Array — Object type descriptors, one per registered object type, filtered by type when given.
initialize
Initializes the SDK with the app credentials, sets up the temporary and asset directories, and initializes the listed extensions. Fails if the SDK is already initialized.
Parameters
| Name | Type | Description |
|---|---|---|
apiURL (Optional) | String | Base URL of the Switchboard API, e.g. https://staging.api.switchboard.audio. Must be an https://*.switchboard.audio host. Defaults to https://api.switchboard.audio. |
appID | String | The app ID provided by Synervoz. |
appSecret | String | The app secret provided by Synervoz. |
extensions (Optional) | Object | Map from extension name to that extension's configuration map; each listed extension is initialized. A failing extension is logged and does not fail initialization. |
outputAssetsDirPath (Optional) | String | Directory the @output asset alias points to. Defaults to output inside the temporary directory. |
systemAssetsDirPath (Optional) | String | Directory the @system asset alias points to. Defaults to system inside the temporary directory. |
tempDirPath (Optional) | String | Directory for temporary files, created if it does not exist. Defaults to the platform's temporary directory. |
userAssetsDirPath (Optional) | String | Directory the @user asset alias points to. Defaults to user inside the temporary directory. |
Return Value
String — Object ID of the SDK singleton, always switchboard.
listAssetFiles
Lists the files in a directory inside one of the asset directories.
Parameters
| Name | Type | Description |
|---|---|---|
path | String | Directory to list, e.g. @user; must lie inside one of the asset directories. |
Return Value
Array — One map per file with path, name, size and mimeType.
loadExtension
Dynamically loads an extension library at runtime and initializes the extension with the supplied config. Returns the name the extension was initialized under, or an empty string if it was already registered. Supported on macOS and Linux.
Parameters
| Name | Type | Description |
|---|---|---|
config (Optional) | Object | Configuration passed to the extension's initialization. |
libraryPath | String | The path to the extension shared library. |
name (Optional) | String | The registered name of the extension to initialize. Omit for an unknown library: whichever extension it registers is initialized by its own getName(), so the caller does not need to know the name in advance. |
Return Value
String — Name of the extension that was loaded and initialized.
resolveFilePath
Expands an asset alias prefix (@system, @user or @output) to the directory it points to. Other paths are returned unchanged.
Parameters
| Name | Type | Description |
|---|---|---|
path | String | The path to resolve, e.g. @user/recording.wav. |
Return Value
String — The path with its alias expanded.
uploadFile
Writes base64-encoded data to a file inside one of the asset directories, overwriting any existing file. The size must be non-zero and at most 512 MiB.
Parameters
| Name | Type | Description |
|---|---|---|
data | String | The file contents, base64-encoded. |
path | String | Path of the file, which may start with an asset alias and must lie inside one of the asset directories. |
size | Int | Size of the file in bytes; must match the length of the decoded data. |
Return Value
None.
Events
licenseStateChanged
Emitted when the state of a license check changes.
Data
| Name | Type | Description |
|---|---|---|
state | String | The new state of the license. Possible values: CHECKING, ACTIVE, INACTIVE, ERROR. |