new AudioMixer()
AudioMixer provides centralized audio control. Manages separate channels for music, SFX, and UI sounds.
- Source
Methods
addMusic(name, path)
Register a music track.
Parameters:
| Name | Type | Description |
|---|---|---|
name | string | |
path | string |
- Source
addSound(name, path, poolSize)
Register a sound effect.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
name | string | ||
path | string | ||
poolSize | number | 5 |
- Source
bindGameplayEvents(eventSource, eventMap) → {AudioMixer}
Route gameplay events to registered sound effects or music tracks. Mapping values are { type: "sound"|"music", name, channel? } or a function that returns one of those records for the event payload.
Parameters:
| Name | Type | Description |
|---|---|---|
eventSource | Object | Emitter exposing on(event, listener). |
eventMap | Object | Event-name to audio action mapping. |
- Source
Returns:
This mixer (for chaining).
- Type:
- AudioMixer
playMusic(name)
Play a music track.
Parameters:
| Name | Type | Description |
|---|---|---|
name | string |
- Source
playSound(name, channel)
Play a sound effect.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
name | string | ||
channel | string | sfx | Channel name ('sfx' or 'ui'). |
- Source
setChannelMuted(channel, muted)
Mute/unmute a channel.
Parameters:
| Name | Type | Description |
|---|---|---|
channel | string | |
muted | boolean |
- Source
setChannelVolume(channel, volume)
Set channel volume.
Parameters:
| Name | Type | Description |
|---|---|---|
channel | string | |
volume | number |
- Source
setMasterVolume(volume)
Set master volume.
Parameters:
| Name | Type | Description |
|---|---|---|
volume | number |
- Source
stopMusic()
Stop music.
- Source
unbindGameplayEvents()
Remove all gameplay event bindings.
- Source