Class: SoundServer
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
Creates a new instance of SoundServer. The server is initially awake after being created.
Parameters
Name | Type | Description |
---|---|---|
bus | EventBus | The event bus. |
Returns
Defined in
src/sdk/utils/sound/SoundServer.ts:178
Properties
DEFAULT_TIMEOUT
▪ Static
Readonly
DEFAULT_TIMEOUT: 10000
Defined in
src/sdk/utils/sound/SoundServer.ts:163
Methods
onSoundEnd
▸ onSoundEnd(id
): void
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
Name | Type | Description |
---|---|---|
id | Name_Z | The ID of the sound file that stopped playing. |
Returns
void
Defined in
src/sdk/utils/sound/SoundServer.ts:215
sleep
▸ sleep(): void
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
Defined in
src/sdk/utils/sound/SoundServer.ts:247
wake
▸ wake(): void
Wakes this server. Once awake, this server will respond to commands.
Returns
void
Defined in
src/sdk/utils/sound/SoundServer.ts:233