Real-Time WASM DSP Engine
High-performance audio processing engine written in Rust and compiled to WebAssembly. Implements glitch-free real-time effects (Soft Clipping, Biquad Filtering) that run independently of the JavaScript Garbage Collector.
Initialization • Click 'Start Audio Engine' to initialize the WebAssembly module • Click 'Start Signal' to begin audio playback Signal Processing • Adjust the Gain slider to increase signal intensity • Toggle 'Enable Soft Clipper' to engage the WASM-based distortion effect • Toggle 'Enable Lowpass Filter' and adjust 'Filter Frequency' to shape the tone Playback Control • Click 'Stop Signal' to pause playback
Need DSP Engineering?
From prototypes to production-grade systems.
The Performance Bottleck
JavaScript’s unpredictable Garbage Collection (GC) pauses can cause audible “glitches” or dropouts in high-performance audio applications. This lab solves that by offloading the mathematical heavy lifting to Rust via WebAssembly, ensuring deterministic processing time for each audio buffer.
Rust Implementation Details
The core DSP logic is implemented in lib.rs and compiled to a .wasm binary:
- Soft Clipper: An analog-modeled distortion effect using a
tanh(hyperbolic tangent) approximation. This simulates the warm saturation of vacuum tube amplifiers. - IIR Biquad Filter: A stateful filter implementation that maintains high precision (
f32) for cutoff frequency application.
Architecture
The audio flows through an AudioWorkletProcessor in the browser, which delegates the buffer processing (48,000 samples per second) directly to the WASM linear memory. This allows standard JavaScript UI to control parameters (like “Gain” or “Drive”) while the audio thread remains lock-free and glitch-free.
References
[1] Mozilla Developer Network. (n.d.). “WebAssembly.” Retrieved from https://developer.mozilla.org/en-US/docs/WebAssembly
[2] Mozilla Developer Network. (n.d.). “AudioWorklet.” Retrieved from https://developer.mozilla.org/en-US/docs/Web/API/AudioWorklet
[3] The Rust Programming Language. (n.d.). “Rust Documentation.” Retrieved from https://www.rust-lang.org/