Optionalcontext: AudioContext
An AudioContext to use instead of creating one -- lets tests (and any code
that already owns a shared context) inject their own instead of relying on the global
window.AudioContext.
Optionalevents: Events
An optional per-instance event bus on which non-fatal audio events (like
AUDIO_LOADED) are dispatched. Errors are deliberately not routed here -- load() throws
so callers keep an explicit failure path, consistent with the other loaders.
Stops every still-running endless sound (startDrone/startFire graphs) and closes the
AudioContext. Call this when tearing down the engine instance that owns this AudioSystem
-- without it, both the endless sound graphs and the context itself outlive the instance for
the lifetime of the page (browsers cap the number of concurrently open AudioContexts).
Loads an audio file and decodes it into a buffer.
The URL of the audio file.
The unique name to identify the sound.
Plays a global (non-spatial) sound.
Generates a retro synthesized footstep thud. See SynthSFX.playFootstep.
Generates a retro "Ugh!" hurt sound. See SynthSFX.playHurt.
Plays a global (non-spatial) music track through the music bus, so it responds to
setMusicVolume() independently of sound effects.
Generates a retro "Pew Pew" laser/gunshot sound. See SynthSFX.playShoot.
Plays a 3D spatial sound at a given position.
Generates a procedural synth tone (e.g., for musical instruments or physical impacts).
See SynthSFX.playTone.
The base frequency in Hz.
The duration of the tone in seconds.
The starting volume.
The oscillator type.
Plays a short one-shot burst of genuine white noise (impact "fuzz"/static crackle).
See SynthSFX.playWhiteNoiseBurst.
Seconds the burst plays for.
Peak burst volume (0..1).
Center of the band-pass shaping the fuzz character.
Band-pass resonance.
Must be called after a user interaction to resume the audio context on some browsers.
Set the global master volume (0.0 to 1.0)
Set the Music volume (0.0 to 1.0)
Set the Reverb level (0.0 to 1.0)
Set the SFX volume (0.0 to 1.0)
Starts a creepy, pulsing low-frequency background drone. See SynthSFX.startDrone. The drone
loops forever -- call .stop() on the returned handle to end it (also done automatically by
dispose()).
Starts a procedural fire crackling noise at a specific 3D location. See SynthSFX.startFire.
The noise loops forever -- call .stop() on the returned handle to end it (also done
automatically by dispose()).
Updates the global listener position and orientation based on the camera.
A basic Audio System that wraps the Web Audio API. Supports loading sounds and playing them globally or spatially.