SoundManager <Channel, SoundName>
Implements
- SoundManagerApi
- Loadable<AudioBuffer[]>
Index
Constructors
constructor
Type parameters
- Channel: string
- SoundName: string
Parameters
options: SoundManagerOptions<Channel, SoundName>
Returns SoundManager<Channel, SoundName>
Properties
publicchannel
publicdata
Decoded audio of every managed sound once loaded, see Loadable
publicreadonlyinput
Master bus input every channel (and channel-less sound) is mixed into
publicmaxConcurrentTracks
Maximum number of simultaneously playing tracks across ALL managed sounds.
Default is Infinity (unbounded). When the cap is reached, new play()
calls are dropped.
publicreadonlyoutput
Master gain carrying the master volume and mute, connected to the audio context destination
publicvoiceStealing
Stop the oldest playing track to make room when a cap is reached instead of dropping the new play
Accessors
publicmuted
Whether the master output is muted
Returns boolean
publicvolume
Master volume [0-1], default 1
Returns number
Parameters
volume: number
Returns void
Methods
publicgetChannel
Get a SoundChannel, creating it on first use
Parameters
name: Channel
Returns SoundChannel
publicgetChannels
Returns readonly SoundChannel[]
publicgetSound
publicgetSounds
Returns readonly Sound<string>[]
publicgetSoundsForChannel
publicgetVolume
Get the mix volume of a tracked sound (or Sound.volume for an untracked one)
Parameters
name: SoundName
Returns number
publicisLoaded
Returns true if the loadable is loaded
Returns boolean
publicisMuted
Whether a sound is silenced by its own mute, its channel's mute, or the master mute
Parameters
name: SoundName
Returns boolean
publicload
Load every managed sound
Returns Promise<AudioBuffer[]>
publicmute
Mute a tracked sound, or the master output when no sound is given. Playback continues silently.
Parameters
optionalname: SoundName
Returns void
publicplay
Play a sound with optional one-off PlayOptions. Resolves to false if the sound is unknown or dropped by a concurrency cap. Muted sounds still play (silently) so they are audible mid-clip when unmuted.
Parameters
name: SoundName
optionaloptions: number | PlayOptions
Returns Promise<boolean>
publicplayingCount
Total number of currently-playing tracks across all managed sounds
Returns number
publicsetChannel
Route a tracked sound through a channel, or
nullfor straight to the master outputParameters
name: SoundName
channel: Channel | null
Returns void
publicsetVolume
Set the mix volume [0-1] of a tracked sound (or Sound.volume for an untracked one)
Parameters
name: SoundName
optionalvolume: number
Returns void
publicstart
Like SoundManager.play but returns the SoundTrack synchronously, or
nullif the play was dropped.Parameters
name: SoundName
optionaloptions: PlayOptions
Returns SoundTrack | null
publicstop
Parameters
optionalname: SoundName
Returns void
publictoggle
Parameters
optionalname: SoundName
Returns void
publictrack
Start managing a sound, registered under
name, the config'sname, or the sound's own name. Its output is re-routed through the manager's mixer graph.Parameters
sound: Sound<string> | SoundConfig<string, string>
Returns void
publicunmute
Parameters
optionalname: SoundName
Returns void
publicuntrack
Stop managing a sound, restoring its output straight to the speakers
Parameters
name: SoundName
Returns void
Manages a set of sounds through a Web Audio mixer graph:
Sound.output → mix gain → SoundChannel (input → output) → SoundManager.output → speakersMaster, channel and per-sound mix volumes and mutes compose in the graph, so muting is silent playback rather than a pause and none of it touches Sound.volume. A SoundManager is Loadable, add it to a Loader to load every sound it manages.