Rust · no audio crates · hand-written WAV
Reverb is an audio synthesis engine in Rust with oscillators, an ADSR envelope, mixing, and a hand-written WAV file writer. No audio crates, no shortcuts. Here is the real math, running in your browser.
Pick a waveform (sine, square, sawtooth, or triangle) and an octave, then click a key on the on-screen keyboard or press Play note to hear it. The frequency slider tunes the pitch directly in hertz.
The four ADSR sliders shape each note's volume over time: attack (fade in), decay (drop to sustain), sustain (held level), and release (fade out). Adjust them and play again to hear the change, and watch the waveform preview redraw the actual samples. Play melody sequences several notes so you can hear the mixer at work.
A short pipeline turns a note name into raw audio samples, with nothing borrowed along the way.
Sine, square, sawtooth, and triangle waves at any frequency and sample rate, computed directly from phase.
Attack, decay, sustain, and release shape every note so it fades in and out instead of clicking.
Notes chain into a track, tracks mix together, and the result is normalized to stay in range.
A RIFF header, fmt chunk, and data chunk written byte by byte. No audio or WAV crates involved.
The usual Rust audio path leans on crates: hound for WAV files, cpal or rodio for playback, a DSP crate for the math. Reverb does none of that, on purpose.
Every sample and every WAV byte is computed in this repo. Nothing hides the oscillator math or the RIFF layout behind a dependency.
Oscillator, envelope, mixer, and WAV writer are a few short files. You can read the whole path from a note name to bytes on disk in one sitting.
Phase accumulation, the four waveform shapes, the ADSR curve, and 16-bit PCM quantization are all in plain view, not wrapped away.
Standard 16-bit PCM WAV files that open in any player or editor, written header first by hand with no format library involved.
The same oscillator and envelope math you just heard, writing WAV files to disk. Real output below.
$ cargo build --release $ reverb tone --freq 440 --secs 2 -o out.wav wrote out.wav (88200 samples) $ reverb demo -o demo.wav wrote demo.wav (108045 samples)
Pick a frequency, a length, and a waveform with --wave (sine, square, sawtooth, triangle), and write it to a WAV file.
Render the short sequenced track so you can hear the sequencer and mixer without writing a manifest first.
Checks sample counts and range, WAV header correctness, envelope shape, and the waveform values themselves.
The oscillator, envelope, sequencer, mixer, and WAV writer are a plain Rust library, the same code this page ports to run in the browser.