Synth
A polyphonic synth that runs in the browser tab. Click or touch the keys, or play the computer keyboard: A to ' are the white keys, W to P the black keys, and Z and X change the octave. The sound starts at the first click or key.
Full page version: joellof.com/synth/app/
What it has
Section titled “What it has”- Eight voices. A ninth note takes the oldest voice, with a 5 ms fade so the steal does not click.
- Nine waveforms. Sine, PolyBLEP saw and square, triangle, and five band-limited wavetables: mellow saw, electric piano, organ, violin and a 25% pulse.
- An ADSR envelope on each voice, from 1 ms to 10 s.
- A low-pass filter on each voice: a two-pass state-variable filter with the cutoff from 20 Hz to 20 kHz and the resonance as Q from 0.1 to 30.
- A waveform scope of the output, and the master volume.
How it works
Section titled “How it works”The DSP is Rust with no crates, no allocator and no wasm-bindgen. It compiles to a 14 KB WebAssembly module with a C ABI: init, note_on, note_off, set_param and render.
/// Renders up to 128 frames and returns how many it wrote.
#[no_mangle]
pub extern "C" fn render(frames: u32) -> u32 {
let (synth, tables) = state();
synth.render(frames, tables)
}The page fetches the module and passes its bytes to an AudioWorkletProcessor in processorOptions. The processor compiles them, writes silence until the module is ready, and then calls render once per 128-frame block on the audio thread. The notes and the settings go to the processor as messages on its port, so a slider never stops a held note.
Tech Stack
Section titled “Tech Stack”| DSP | Rust, compiled to WebAssembly with no crates |
| Audio | Web Audio API, AudioWorklet |
| UI | React, TypeScript |
| Build | Bun, Cargo |