API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classAudioBus

@codexo/exojs / audio / stable

Hierarchical mixer node in the engine's audio routing graph. Each bus owns three Web Audio nodes (input gain, optional effect chain, stereo pan, output gain) and routes its output into its parent's input - the root bus connects to the destination. The three engine-built-in busses are constructed by AudioSystem: `master` (root), `music` (child of master), `sound` (child of master). User code creates additional busses via `new AudioBus(name, { parent })` and registers them via AudioSystem.registerBus. Volume is in 0..2 (1 = unity), pan is -1..1, mute is a boolean override. AudioBus.fadeIn / AudioBus.fadeOut produce smooth ramps over the output gain. Effect changes via AudioBus.addEffect / AudioBus.removeEffect rebuild the chain in place. Setup is deferred until the global `AudioContext` is unlocked (browser autoplay policy); operations that need live nodes are no-ops until that happens.

6
props
8
methods
0
events
Import
import { AudioBus } from '@codexo/exojs'

Hierarchical mixer node in the engine's audio routing graph. Each bus owns three Web Audio nodes (input gain, optional effect chain, stereo pan, output gain) and routes its output into its parent's input - the root bus connects to the destination.

The three engine-built-in busses are constructed by AudioSystem: `master` (root), `music` (child of master), `sound` (child of master). User code creates additional busses via `new AudioBus(name, { parent })` and registers them via AudioSystem.registerBus.

Volume is in 0..2 (1 = unity), pan is -1..1, mute is a boolean override. AudioBus.fadeIn / AudioBus.fadeOut produce smooth ramps over the output gain. Effect changes via AudioBus.addEffect / AudioBus.removeEffect rebuild the chain in place.

Setup is deferred until the global `AudioContext` is unlocked (browser autoplay policy); operations that need live nodes are no-ops until that happens.

Constructors1
new(name: string, options: AudioBusOptionsConstruction options for AudioBus.): AudioBus
Methods8
Append a effect to the end of the chain (before the pan stage). The chain is rebuilt in place; existing audio routes through the new effect on the next frame. Attaching does not transfer ownership: the caller keeps it and must destroy() the effect once it is no longer used anywhere. Neither AudioBus.removeEffect nor AudioBus.destroy destroys it. A no-op once the bus has been AudioBus.destroyed - without this guard the effect would silently accumulate in the (otherwise unused) internal list forever. Attaching the same effect twice is a caller error: the rebuilt chain would wire the effect's output back into its own input, producing a feedback loop. The dev build asserts; production ignores the second attach.
destroy(): void
Tear the bus down: drop pending setup work, detach every attached effect and disconnect this bus's own nodes from the graph. Attached effects are detached, **not** destroyed - a bus never owns them (see AudioBus.addEffect), and the same instance may still be in use on a voice or another bus. Destroy each effect yourself once it is no longer needed anywhere.
Linearly ramp the output gain from 0 to the current volume over duration. Cancels any in-flight ramps on the same gain node.
Linearly ramp the output gain to 0 over duration. By default mutes the bus once the ramp completes (stopAfter: true); pass stopAfter: false to let the ramp finish silently while leaving muted unchanged.
getInputNode(): GainNode | null
The GainNode a source connects to in order to feed this bus. null until the AudioContext is unlocked and the bus has built its node chain, and again after destroy, so callers must re-read it rather than cache it - the chain is rebuilt on context recovery. Part of the audio extension contract for custom effects and analysers.
getOutputNode(): GainNode | null
The GainNode carrying this bus's post-effect, post-pan signal, for taps that read the bus without altering it (analysers, sidechain sources). null under the same conditions as getInputNode, and subject to the same no-caching rule. Part of the audio extension contract for custom effects and analysers.
onceSetup(callback: () => void): () => void
Run callback the moment this bus's audio nodes are ready: immediately if it is already set up, otherwise queued on the bus and flushed when the context unlocks. Returns an unsubscribe function that removes the still-pending callback (a no-op once it has fired). Internal use. The queue lives on the bus rather than the global unlock signal, so many voices deferring a reconnect before the first user gesture do not pile listeners onto that singleton, and anything torn down pre-unlock drops its own pending callback (AU3).
Remove effect from the chain. No-op if not present. The caller still owns it and must destroy() it - the same contract AudioBus.destroy follows for whatever is still attached when the bus goes away.
Properties6
name: string
inputNode: GainNode | null
muted: boolean
pan: number
parent: AudioBus | null
volume: number
Source