Architecture Overview
The WASM build system creates two separate modules:DSP Module
Thread: AudioWorklet (real-time audio thread)
- Audio processing only
- Embedded as BASE64 for synchronous loading
- No UI code
UI Module
Thread: Main thread
- IGraphics rendering
- User interaction
- Asynchronous loading
Communication
- Parameters/MIDI:
postMessageAPI - Visualization:
SharedArrayBuffer(low-latency) orpostMessage(fallback)
Why split architecture?
- Isolates audio processing from UI jank
- Smaller initial load (DSP embedded, UI loads async)
- No WAM SDK dependency
- Multi-instance support
Prerequisites
Building with Makefiles
Each example project includes build scripts:Build Process
The script:- Packages resources (fonts, images, SVGs)
- Builds DSP module with
SINGLE_FILE=1(BASE64 embedded) - Builds UI module (if
PLUG_HAS_UI=1) - Copies templates and generates web bundle
- Outputs to
build-web-wasm/
Headless Plugins
For plugins without IGraphics (PLUG_HAS_UI=0), only the DSP module is built:
Project Configuration
Makefile Config
Createconfig/YourPlugin-wasm.mk:
DSP/UI Project Files
projects/YourPlugin-wasm-dsp.mk:
projects/YourPlugin-wasm-ui.mk:
Build Output
Server Requirements
ForSharedArrayBuffer support (low-latency visualization), your server must send these headers:
Development Server
Use the included Python server:- Python 3
- emrun
- Node.js (http-server)
Create Run:
serve.py:Message Protocol
UI → DSP (via postMessage)
| Type | Fields | Description |
|---|---|---|
param | paramIdx, value | Parameter change |
midi | status, data1, data2 | MIDI message |
sysex | data (ArrayBuffer) | SysEx message |
arbitrary | msgTag, ctrlTag, data | Custom message |
tick | - | Idle tick (flush queue) |
DSP → UI (via postMessage)
| Verb | Fields | Description |
|---|---|---|
SPVFD | paramIdx, value | Parameter value from DSP |
SCVFD | ctrlTag, value | Control value (visualization) |
SCMFD | ctrlTag, msgTag, data | Control message |
SAMFD | msgTag, data | Arbitrary message |
SSMFD | data | SysEx from DSP |
pluginInfo | data | Plugin metadata |
SharedArrayBuffer (Low-Latency)
For high-frequency visualization data:Multi-Instance Support
The WASM DSP module supports multiple plugin instances in the same AudioWorklet context:Each instance has isolated state and parameters, but shares the WASM module code.
Template Files
Build copies templates fromIPlug/WEB/TemplateWasm/:
| File | Purpose |
|---|---|
index.html | Main page with Web Audio setup |
scripts/IPlugWasmBundle.js.template | Controller, connects DSP↔UI |
scripts/IPlugWasmProcessor.js.template | AudioWorkletProcessor wrapper |
styles/style.css | Default styling |
NAME_PLACEHOLDER are replaced during build.
Debugging
Browser Console
Check console messages
Both DSP and UI modules log to consoleDSP messages are prefixed with plugin name
Common Issues
SharedArrayBuffer is not defined
SharedArrayBuffer is not defined
Module not found in globalThis
Module not found in globalThis
Cause: DSP module failed to loadSolution:
- Check browser console for WASM compilation errors
- Verify WASM file is accessible (check Network tab)
- Ensure MIME type is
application/wasm
Audio glitches
Audio glitches
Cause: DSP module too heavy for real-timeSolution:
- Profile with Chrome DevTools Performance panel
- Reduce buffer processing complexity
- Check for allocations in
ProcessBlock - Consider disabling SIMD if causing issues
UI not appearing
UI not appearing
Cause: IGraphics initialization failureSolution:
- Check browser console for errors
- Verify resources (fonts, images) are loaded
- Test with headless build first
- Ensure canvas element is created
Performance Profiling
WAM vs Split WASM
| Feature | WASM (Split) | WAM |
|---|---|---|
| SDK dependency | None | WAM SDK required |
| Architecture | Split DSP/UI | Combined |
| AudioWorklet | Native | Via SDK |
| Visualization | SAB + postMessage | WAM events |
| DAW integration | Basic | WAM host support |
| Deployment | Simpler | Standardized |
Building WAM (Alternative)
For Web Audio Module builds:CMake Build (Alternative)
iPlug2 web projects can also be built with CMake:Deployment
Hosting Requirements
CDN Deployment
For serving via CDN: Workarounds:- Host on your own server with proper headers
- Use Cloudflare Workers to add headers
- Use Service Worker to add headers client-side
Embedding in Web Pages
Next Steps
WAM Integration
Integrate with WAM hosts
Web UI
Building web-based UIs
CMake Build
Alternative build system
Deployment
Production deployment