Skip to content

Music channels ​

A channel owns one current cue and a queue of approved catalog cue IDs. It uses the same emitters, audience controls, buses and playback clock as ordinary sources. A channel's volume multiplies the cue's volume.

lua
local pa = { { coords = vec3(100, 200, 30), refDistance = 8, maxDistance = 50 } }
for _, deck in ipairs({ 'deckA', 'deckB' }) do
  exports.np_audio:createChannel(deck, { emitters = pa, bucket = 0, backend = 'web' })
end
exports.np_audio:channelLoad('deckA', 'my_resource:song1')
exports.np_audio:channelQueueAdd('deckA', 'my_resource:song2')
exports.np_audio:crossfadeChannels('deckA', 'deckB', 'my_resource:song3', 4000)

Transport and queue ​

Load replaces current media and preserves the queue. Play/resume starts current media or the queue head; stop clears current media and keeps the queue. Skip loads the queue head, or stops when the queue is empty. Queue remove/move use 1-based indexes. Queue modes are end, next, and now.

Autoplay uses the server-approved durationMs; the next cue anchors to the previous planned deadline so periodic ticks do not accumulate drift. An unknown-duration live stream continues until the owner stops/skips it. Client metadata or an ended report cannot advance the shared queue.

Looping is a channel option and defaults false. Pause, resume, seek, scheduled starts and volume ramps use the same server clock as source playback.

Two decks ​

crossfadeChannels(from, to, newCue, ms, {at?}) loads the destination at zero, then fades the source to zero and destination to one at a common timestamp. Both channels must belong to the caller. Use at most 60000ms for the fade. Cold asset/network/decoder startup can affect timing; this is synchronized playback, not phase-coherent distributed audio.

np_screens delegation ​

The built-in player is the default. Approved URL music may explicitly use backend='screens', or be delegated automatically when preferForMusic=true and the host exposes its Audio Channels API. That enables the host's media and YouTube playback while np_audio retains its catalog/queue ownership.

Restricted audiences, nonspatial channels and bundled files use the built-in backend. Forced screens channels cannot broaden their audience. Delegated channels keep the host's local preferences and DSP limits; use Web Audio for np_audio's local category/streamer/effect controls. Integrations documents restart recovery and public export contracts.