Overview
iPlug2 can compile plugins to WebAssembly (WASM) to run in web browsers. This enables:- Standalone web apps - Run plugins in browsers without installation
- Plugin demos - Let users try plugins before buying
- Educational tools - Interactive audio DSP learning
- Web DAWs - Integrate into browser-based music production
Architecture
iPlug2 uses a split DSP/UI architecture for WASM builds:DSP Module
AudioWorklet Thread
- Real-time audio processing
- Runs in isolated audio thread
- Embedded as BASE64 in page
- Sample-accurate timing
UI Module
Main Thread
- IGraphics rendering
- User interaction
- Loads asynchronously
- Shadow DOM encapsulation
Communication
- Parameters/MIDI:
postMessage(always available) - Visualization:
SharedArrayBuffer(requires HTTPS + special headers)
No WAM SDK RequirediPlug2’s WASM build uses standard Web Audio API directly. For WAM SDK integration, see the legacy
WAM build targets.Prerequisites
Install Emscripten
.bashrc, .zshrc):
Server Requirements
ForSharedArrayBuffer support (needed for low-latency visualization):
postMessage fallback.
Building with Makefile
cd scripts
./makedist-wasm.sh # Build and launch in Chrome
./makedist-wasm.sh off # Build only
./makedist-wasm.sh on safari # Launch in Safari
build-web-wasm/
├── index.html # Main page
├── scripts/
│ ├── IPlugEffect-wasm-dsp.js # DSP loader (BASE64 embedded)
│ ├── IPlugEffect-wasm-ui.js # UI module
│ └── IPlugWasmBundle.js # Controller
├── styles/
│ └── style.css # Default styling
└── resources/
├── fonts/ # Embedded fonts
└── images/ # Embedded images
Building with CMake
IPlugEffect-wasm-dsp- DSP module onlyIPlugEffect-wasm-ui- UI module onlyIPlugEffect-wasm-dist- Full distribution bundle
Project Configuration
Headless Plugins
For plugins without custom UI:config.h
Web-Specific Config
Createconfig/YourPlugin-wasm.mk for custom settings:
Message Protocol
DSP and UI communicate via typed messages:UI → DSP
DSP → UI
postMessage or SharedArrayBuffer ring buffer.
Multi-Instance Support
Multiple plugin instances can run in the same page:- Has its own DSP state
- Uses separate audio buffers
- Maintains independent parameters
- Shares WASM module code (efficient)
Custom HTML Integration
Embed in Existing Page
Control from JavaScript
Visualization Data
Using SharedArrayBuffer
For low-latency visualization (meters, scopes, etc.):SharedArrayBuffer ring buffer, polled by UI at 60fps.
Using postMessage
Fallback whenSharedArrayBuffer unavailable:
postMessage when TransmitData called.
Local Development Server
Createserve.py with COOP/COEP headers:
Debugging
Browser Console
Both DSP and UI modules log to console: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 load/compileFix: Check browser console for WASM compilation errors. Verify Emscripten version.
Audio glitches/dropouts
Audio glitches/dropouts
Cause: DSP too heavy for real-time processingFix:
- Profile with Chrome DevTools Performance panel
- Reduce buffer processing complexity
- Check for allocations in
ProcessBlock - Disable SIMD if causing issues
- Increase buffer size (tradeoff: latency)
UI doesn't appear
UI doesn't appear
Cause: UI module failed to load or incorrect container IDFix:
- Verify
scripts/IPlugEffect-wasm-ui.jsexists - Check container element ID matches
- Look for JavaScript errors in console
Performance Optimization
Compiler Flags
Memory Management
Bundle Size
- Use
-Osfor smaller binaries - Avoid including unused libraries
- Use embedded resources sparingly
- Consider gzip compression on server
WAM SDK vs Split WASM
| Feature | Split WASM | WAM SDK |
|---|---|---|
| SDK dependency | None | WAM SDK required |
| Architecture | Split DSP/UI | Combined |
| AudioWorklet | Native | Via SDK |
| DAW integration | Basic | WAM host support |
| Deployment | Simple | Standardized |
- Standalone web apps
- Plugin demos
- Simple deployment
- Web DAW integration
- WAM-compatible hosts
- Standardized plugin format
Deployment
Static Hosting
Uploadbuild-web-wasm/ to any static host:
- GitHub Pages
- Netlify
- Vercel
- AWS S3 + CloudFront
HTTPS Required
ForSharedArrayBuffer support:
- Must use HTTPS (not HTTP)
- Set COOP/COEP headers
- Use valid SSL certificate
CDN Configuration
Next Steps
WASM Docs
Detailed WASM build documentation
Web Audio API
MDN Web Audio reference
AudioWorklet
AudioWorklet API documentation
Examples
Browse web plugin examples