API reference

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

C

classAudioListener

@codexo/exojs / audio / stable

Observer position that spatial voices of one Application are panned against. Read each frame from AudioListener.target when one is set, else written directly via AudioListener.position. **Virtual, not the WebAudio listener.** `AudioContext.listener` belongs to the process-wide context, so it is a single global object - two Applications writing their own world position into it every frame would simply overwrite each other, and both mixes would pan against whichever ticked last. This class therefore pins the real WebAudio listener at the origin (orientation forward = -Z, up = +Y for 2D scenes, identical for every app) and each spatial BaseVoice writes its panner position **relative** to its own system's listener (`source − listener`). Distance, attenuation and the distance model are unaffected: only the offset vector matters to a panner whose listener sits at the origin. A consequence worth knowing: listener motion used to be smoothed once, centrally, on the listener's own `AudioParam`s. It is now folded into each voice's relative position and smoothed per voice by the same SpatialSmoothingSettings. The audible result is the same ramp, but SpatialSmoothingSettings.teleportThreshold is now evaluated against the *relative* jump - a listener warp snaps every voice individually rather than snapping the listener once - and a moving listener costs one `setTargetAtTime` per spatial voice per frame instead of three in total. Owned by AudioSystem; one instance per Application. `velocity` feeds the Doppler calculation on every spatial BaseVoice - explicit when set, else auto-derived each frame from the listener's own position delta (same fallback BaseVoice.velocity uses). That path is unaffected by the virtualization: it has always worked in absolute world coordinates in JS.

5
props
1
methods
0
events
Import
import { AudioListener } from '@codexo/exojs'

Observer position that spatial voices of one Application are panned against. Read each frame from AudioListener.target when one is set, else written directly via AudioListener.position.

**Virtual, not the WebAudio listener.** `AudioContext.listener` belongs to the process-wide context, so it is a single global object - two Applications writing their own world position into it every frame would simply overwrite each other, and both mixes would pan against whichever ticked last. This class therefore pins the real WebAudio listener at the origin (orientation forward = -Z, up = +Y for 2D scenes, identical for every app) and each spatial BaseVoice writes its panner position **relative** to its own system's listener (`source − listener`). Distance, attenuation and the distance model are unaffected: only the offset vector matters to a panner whose listener sits at the origin.

A consequence worth knowing: listener motion used to be smoothed once, centrally, on the listener's own `AudioParam`s. It is now folded into each voice's relative position and smoothed per voice by the same SpatialSmoothingSettings. The audible result is the same ramp, but SpatialSmoothingSettings.teleportThreshold is now evaluated against the *relative* jump - a listener warp snaps every voice individually rather than snapping the listener once - and a moving listener costs one `setTargetAtTime` per spatial voice per frame instead of three in total.

Owned by AudioSystem; one instance per Application. `velocity` feeds the Doppler calculation on every spatial BaseVoice - explicit when set, else auto-derived each frame from the listener's own position delta (same fallback BaseVoice.velocity uses). That path is unaffected by the virtualization: it has always worked in absolute world coordinates in JS.

Constructors1
Methods1
destroy(): void
Properties5
elevation: number
Height of the observer above (positive) or below (negative) the world plane, in world units. Default 0. Not read from AudioListener.target: a scene node has no third axis, so this is the caller's to set - and it is preserved across every target tick rather than being reset to the plane each frame.
elevationVelocity: number
Vertical component of AudioListener.velocity, in world units per second. Default 0. Only Doppler reads it, and it is never auto-derived - nothing tracks elevation for the listener to derive it from.
Source