Audio
Audio — procedural sound-effect synthesis for March compiled with --target js.
Wraps the browser's Web Audio API to synthesize short sound effects on the fly (tones, frequency sweeps, filtered noise) instead of loading audio files -- no assets, no licensing, fully deterministic from code. Requires --target js; calling these functions from a native build panics.
Browsers block audio output until a user gesture occurs on the page -- call resume from inside your first tap/click handler.
Usage: let actx = Audio.create() Audio.resume(actx) -- call on first user gesture Audio.beep(actx, 900.0, 0.05, "square") -- laser-ish blip Audio.sweep(actx, 400.0, 900.0, 0.12, "sine") -- rising chime Audio.noise_burst(actx, 0.2, 900.0) -- explosion-ish thud Audio.set_volume(actx, 0.0) -- mute
Functions
Play a flat tone at freq Hz for duration seconds. wave is one of \
Create a new Web Audio context. Call once at startup.
Play a burst of filtered white noise for duration seconds, low-passed at filter_freq Hz -- impacts, explosions.
Unlock audio output. Browsers block sound until a user gesture occurs on the page -- call this from inside your first tap/click handler.
Set the master volume, 0.0 (silent) to 1.0 (full).
Play a tone that glides from freq_from Hz to freq_to Hz over duration seconds -- risers, chirps, fall-offs.