WavePedal build log - WordPad
✕
C:\ar9av\builds\WAVEPEDA.TXT
  1. Desktop
  2. Build Log
  3. Music & Audio

Build log · Music & Audio

How I built WavePedal

A synth with 13 chainable effect pedals, a layer looper and Web MIDI input

Screenshot of WavePedal running in the portfolio
WavePedal, running on the desktop. Open it yourself →

1.Why I built it

WavePedal began as a plain synth, and the idea grew into hooking digital guitar-style pedals onto basic waves like a cosine and seeing and hearing what each one does to the signal. Each pedal is a real Web Audio node chain, and the scope, spectrum and math views show the result.

Over time I added a multi-layer looper with saved pedal settings per layer, then hardware MIDI support so I could play it from a MiniLab keyboard, and then polyphony, more tones and tempo tools when single notes started to feel limiting.

2.How it works

Rebuild the graph only when the topology changes

There are 13 pedals: drive, distortion, filter, compressor, tremolo, wobble, phaser, flanger, delay, reverb, chorus, ring mod and bitcrush. The app reduces the current state to a topology string, the wave type plus the ids of active pedals. If that string changes, the whole node graph is torn down and rebuilt in pedal order. If only a knob moved, rampParam glides the existing AudioParam to its new value over 40 ms.

This split matters because rebuilding causes clicks and turning a knob shouldn't. A shared voice bus survives rebuilds, so held notes keep ringing through the new chain. The end of the chain is a master gain, then a hard limiter (a DynamicsCompressorNode at -6 dB threshold, ratio 20, zero knee), then an analyser for the scope and spectrum.

Tones from Fourier coefficients

Basic waves use the built-in oscillator types. Organ, brass, flute and reed are lists of harmonic amplitudes turned into a PeriodicWave. Reed uses only odd harmonics, which is what gives a clarinet its hollow sound. The chip tone is a 25% pulse wave, built by writing the real and imaginary Fourier series of a pulse with that duty cycle into 32 harmonics.

Supersaw stacks three sawtooth oscillators detuned by -14, 0 and +14 cents and halves the peak to make up for it. Bell is FM synthesis: a modulator at 3.5 times the note frequency feeds the carrier's frequency, and its depth decays exponentially from 3 * freq to 0.05 * freq over 1.5 seconds, so the strike is bright and the tail is pure.

Effects as small node recipes

The phaser is four allpass biquad filters in series at 1000, 1500, 2000 and 2500 Hz, all swept by one sine LFO through gain nodes connected to their frequency params. The bitcrush pedal is a WaveShaperNode with an 8192-point staircase curve that rounds every sample to 2 / 2^bits steps, mixed with the dry signal. Ring mod connects an oscillator straight into a gain node's gain param, which multiplies the signal by the modulator.

Chorus uses two short delays with separate LFOs, the right one at 1.1 times the rate of the left, for stereo width. Reverb is a convolver fed an impulse response generated from decaying noise with a damping control, so no sample files are needed.

A looper that remembers its pedals

While recording, a ScriptProcessorNode with a 4096-sample buffer taps the signal before the analyser and copies each block into a list of Float32Array chunks. On stop, the chunks are joined into one AudioBuffer and played by a looping AudioBufferSourceNode with its own gain. Each layer also stores a deep copy of the pedal settings and wave type at record time, and selecting a layer loads them back onto the board.

Export mixes every layer at its volume through an OfflineAudioContext, which renders faster than real time, and then writes the result to a WAV file with a small hand-written RIFF header encoder.

MIDI from a real keyboard

Web MIDI drives the synth with velocity-sensitive notes (velocity scales the envelope peak), pitch bend of plus or minus 2 semitones applied live to ringing notes, and CC64 sustain that holds notes until the pedal is released. Any knob can be MIDI-learned: arm it, turn a controller knob, and that CC is bound. A learnable pad toggles the looper and defaults to the MiniLab mkII's first pad.

MIDI access is requested on a click, not on mount, because browsers deny requestMIDIAccess() without a prompt when no user gesture triggered it. The keyboard row shows the real status (device name, blocked, or no device) so it never fails silently.

3.Try it

Play notes with the on-screen keys, the computer keyboard (A to ;) or a MIDI controller, switch pedals on and turn their knobs, and record loop layers on top of each other.

More from the build log

WavePedal · 4 min readAll 29 builds