The underlying context, created lazily on first access.
True once the context exists and is running (not suspended/closed).
The master bus all other buses route through.
Master volume in [0, 1]. Shorthand for master.volume.
Mute/unmute all output. Volume settings are preserved across toggles.
The shared loader, for advanced use (eviction, manual decode).
Number of live (not yet pruned) voices.
The music bus volume in [0, 1].
Resume the context. Browsers require this to run from a user gesture.
Resume the context on the first user interaction. Attaches one-shot
pointer/touch/key listeners to target (default window) and removes them
once the context is running. Safe to call before any gesture.
Fetch + decode (cached) a clip. See AudioLoader.load.
Decode an already-fetched buffer into a clip cached under name.
Play a non-spatial one-shot through a bus (default sfx). Returns a handle
for control, or null if the context isn't running yet.
Play a spatial one-shot positioned at pos (a PannerNode). Defaults to
the sfx bus. Call .follow(target) on the result to track a moving object.
Play a looping background track through the music bus. Only one track
plays at a time; calling again replaces it, optionally crossfading. Accepts
a URL (loaded on demand) or a preloaded AudioClip.
Stop the current music track, optionally fading out over fade seconds.
Fade the current music out over duration seconds, then stop.
Request microphone access. See Microphone.request.
Optionalopts: MicrophoneOptionsCreate a standalone analyser. Connect a source into its .input to tap it,
or pass it to AudioBus.analyser to tap a bus.
Optionalopts: AudioAnalyserOptionsPer-frame housekeeping: advance follow()-bound spatial voices and prune
finished ones. Call once per frame after gameplay updates.
Stop everything and close the context.
The central audio API: a thin, game-oriented layer over the Web Audio API. Owns one AudioContext, a tree of AudioBuses (
masterplussfx/music/ui/voice), an AudioLoader, and the pool of live SoundHandle voices.Standalone — instantiate one with
new AudioEngine(), drive it from your own loop: