Code monitor closeup

By ByteCraft · August 18, 2024

The Architecture of Acid Synthesis

The Roland TB-303's iconic sound stems from a single sawtooth or square wave oscillator fed into a distinctive 24dB/octave diode ladder filter with high resonance and fast envelope decay.

Web Audio Implementation

Using native AudioContext primitives in modern browsers, we can construct this DSP signal chain in under 100 lines of JavaScript.

const ctx = new AudioContext();
const osc = ctx.createOscillator();
const filter = ctx.createBiquadFilter();
const amp = ctx.createGain();

osc.type = 'sawtooth';
filter.type = 'lowpass';
filter.frequency.setValueAtTime(400, ctx.currentTime);
filter.Q.value = 18; // High resonance for classic squelch

osc.connect(filter);
filter.connect(amp);
amp.connect(ctx.destination);

Adding Accent & Slide

Slide functionality is modeled by linearly ramping the osc.frequency AudioParam across overlapping 16th notes, while accent spikes both the filter cutoff peak and total gain simultaneously.

Go Back