Web Audio (AudioWorklet + WASM)¶
Generates browser-ready AudioWorklet + WebAssembly modules from gen~ exports or graph sources. Emscripten compiles C++ to WASM; the generated processor.js runs DSP in a real-time audio thread via AudioWorkletProcessor. Includes a demo page (index.html) with parameter sliders and a make serve target for local browser testing.
OS support: macOS, Linux, Windows (any platform with Emscripten)
Prerequisites¶
- Python >= 3.10
- make
- Emscripten SDK (
emccon PATH)
Installing Emscripten¶
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
Verify with emcc --version.
Quick Start¶
# Create a Web Audio project from a gen~ export
gen-dsp ./my_export -n myeffect -p webaudio -o ./myeffect_webaudio
# Build
cd myeffect_webaudio && make all
# Serve locally and open in browser
make serve
# Open http://localhost:8080
From a graph source:
Output Files¶
| File | Description |
|---|---|
processor.js |
Emscripten glue + AudioWorkletProcessor (concatenated at build time) |
build/<name>.wasm |
WebAssembly binary |
index.html |
Demo page with parameter sliders and start/stop controls |
How It Works¶
gen_ext_webaudio.cppbridges Emscripten exports (wa_create,wa_perform, etc.) to the gen~ wrapper functions viaEMSCRIPTEN_KEEPALIVE_ext_webaudio.cppwraps genlib (header isolation pattern, same as all platforms)_processor.jsimplementsAudioWorkletProcessorwithparameterDescriptorsauto-generated from gen~ parameter metadata- At build time,
makecompiles C++ to WASM, then concatenates the Emscripten glue JS with_processor.jsinto the finalprocessor.js index.htmlloads the worklet module, creates anAudioWorkletNode, and renders parameter sliders
Limitations¶
- Buffer loading is not yet supported (browser file I/O is async and browser-specific)
- Build integration tests require
emccandnodeon PATH (skipped in CI if unavailable)