Skip to main content

Class: SoundServer

Defined in: src/sdk/utils/sound/SoundServer.ts:162

A server which plays and manages sounds. Commands to start or stop playing sounds can be sent to the server via the event bus.

The server plays sounds as packets. Each sound packet consists of a string key and zero or more sound atoms that are played in sequence. Each sound atom represents a single playable sound file from within the sim. Sound packets can be played as a one-shot or be looped continuously. Only one packet with a given key can be played at a time. Queueing of packets with the same key is supported.

Constructors​

Constructor​

new SoundServer(bus): SoundServer

Defined in: src/sdk/utils/sound/SoundServer.ts:178

Creates a new instance of SoundServer. The server is initially awake after being created.

Parameters​

ParameterTypeDescription
busEventBusThe event bus.

Returns​

SoundServer

Properties​

DEFAULT_TIMEOUT​

readonly static DEFAULT_TIMEOUT: 10000 = 10000

Defined in: src/sdk/utils/sound/SoundServer.ts:163

Methods​

onSoundEnd()​

onSoundEnd(id): void

Defined in: src/sdk/utils/sound/SoundServer.ts:215

A callback method that responds to when the sim notifies the JS instrument that a sound file has stopped playing. This method needs to be manually called for SoundServer to function properly.

Parameters​

ParameterTypeDescription
idName_ZThe ID of the sound file that stopped playing.

Returns​

void


sleep()​

sleep(): void

Defined in: src/sdk/utils/sound/SoundServer.ts:247

Puts this server to sleep. This will stop all currently playing sound packets at the earliest opportunity and clears all queued packets. While asleep, this server will not respond to any commands.

Returns​

void


wake()​

wake(): void

Defined in: src/sdk/utils/sound/SoundServer.ts:233

Wakes this server. Once awake, this server will respond to commands.

Returns​

void