Mixers & scenes ​
Mixer buses belong to the resource that created them. A bus may have a parent owned by the same resource, up to eight levels deep. A source's volume is multiplied by every bus in that chain. Muting a parent affects its descendants.
exports.np_audio:createBus('master', { volume = 0.8 })
exports.np_audio:createBus('machines', { parent = 'master', volume = 0.5 })
local ok, handle = exports.np_audio:play('alarm', {
coords = vec3(100, 200, 30), bus = 'machines', bucket = 0,
})
exports.np_audio:setBusVolume('machines', 0.5, { muted = true })
exports.np_audio:setBusVolume('master', 0.3, { rampMs = 2000 })
setSourceBus moves an owned source to another owned bus; nil detaches it.
destroyBus refuses a bus with child buses or source/channel references, so
removing a mixer never silently disconnects active sound.
Ramps ​
Source, bus and channel volume setters accept rampMs and an optional at
timestamp from the audio server clock. Ramps are evaluated against the shared
clock. Replacing a pending ramp preserves the currently audible ramp until the
new one starts, and its history is bounded.
Volumes use 0..1. A source's audible gain also includes emitter falloff, local preferences, category/master factors and optional environmental gain.
Scenes ​
registerScene stores static cue/option entries. playScene creates those
sources at a common timestamp (now+150ms by default), returning their handles.
Every entry is validated. If creation fails midway, the newly created sources
are rolled back; existing unrelated sources are kept.
exports.np_audio:registerScene('announcement', {
{ cue = 'notify', options = { coords = vec3(100, 200, 30), bucket = 0 } },
{ cue = 'notify', options = { coords = vec3(120, 200, 30), bucket = 0 } },
})
local ok, handles = exports.np_audio:playScene('announcement')
Scenes create owned audio sources. Live microphone capture and voice mixing remain the responsibility of the server's voice resource.