FlixelTeaVMSoundHandler
View sourceclass
org.flixelgdx.backend.teavm.audio.FlixelTeaVMSoundHandler
TeaVM/web implementation of Factory backed by the Web Audio API.
A single AudioContext and master GainNode are shared across all sounds. Both are created lazily on the first FlixelTeaVMSoundHandler.createSound(...) or FlixelTeaVMSoundHandler.prewarmSound(String) call to respect browser policies that require an active user gesture before audio can play.
Audio data is read synchronously from the virtual filesystem (which is fully preloaded before the game starts) and decoded asynchronously via AudioContext.decodeAudioData.
Decoded AudioBuffer objects are cached by path. Once a path has been decoded (either by a previous FlixelTeaVMSoundHandler.createSound(...) call or by an explicit FlixelTeaVMSoundHandler.prewarmSound(String) call), subsequent FlixelTeaVMSoundHandler.createSound(...) calls for that path use the cached buffer and start playback immediately with no decode lag. This is the mechanism that keeps multiple tracks started in the same frame in perfect sync without skipping into the audio.
Focus-based pause and resume are implemented via AudioContext.suspend() and AudioContext.resume(), which atomically halts or continues every active sound with no per-instance bookkeeping.
Groups are no-ops beyond triggering context-level suspend/resume: the Web Audio API does not expose per-group routing without a dedicated graph, and the engine's SFX and music groups are always paused and resumed together by FlixelSoundManager.
Audio-graph effects (ReverbNode, EchoNode, LowPassNode) are fully supported on web using native Web Audio API nodes. Reverb uses a ConvolverNode driven by a procedurally generated impulse response; echo uses a DelayNode with a feedback GainNode; low-pass uses a BiquadFilterNode.
Constructors
FlixelTeaVMSoundHandler()
Methods
createSound(String, short, Object, boolean)
prewarmSound(String)
isPrewarmPending()
createGroup()
disposeGroup(Object)
groupPause(Object)
groupPlay(Object)
setMasterVolume(float)
getMasterVolume()
Returns the tracked master volume.
Returns: Master volume in [0, 1].