Home / Dubstep from scratch

The wobble: a tempo-synced LFO on a filter

LearningUpdated 2026-09-27

Build the wobble by moving a low-pass filter's cutoff with an LFO locked to the project tempo, and learn what rate, depth, shape and sync do.

Goal

The mid layer: buzzing saws whose brightness rises and falls in time with the beat. The "wub".

The idea

A Low-pass filter keeps the lows and cuts everything above its cutoff. Move the cutoff up and the sound opens (bright, buzzy); move it down and it closes (dark, hollow). Do that rhythmically and you get wub-wub-wub.

The hand on the cutoff knob is an LFO: an oscillator so slow (a few cycles a second) that you hear it as movement, not pitch.

A slow wave moving a control by itself, here a filter cutoff.

The rule inside the Dubstep Bass: cutoff = base × 2 ^ (depth × lfo), with the LFO running from 0 (closed) to 1 (open). Base 200 Hz and depth 3 swing the filter between 200 Hz and 200 × 2³ = 1600 Hz. Depth is in octaves, each one a doubling, which is how filters like to be measured.

The saw tone (top) with the LFO (bottom) opening and closing its filter: bright and buzzy when the LFO is high, soft and hollow when it's low.

Tempo sync. The LFO speed isn't in cycles per second, it's in note values: one wobble per quarter, per eighth, and so on. The instrument reads REAPER's tempo and position (the JSFX variables tempo and beat_position), so the wobble stays locked to the beat whatever the BPM.

The tempo drifts and the wobble follows, because it's set to one per sixteenth note.

At 140 BPM ("triplet" splits a beat into three instead of two or four):

Wobble rateBeatsOne wobbleSpeed
1 bar41714 ms0.58 Hz
1/2 note2857 ms1.17 Hz
1/4 note1429 ms2.33 Hz
1/4 triplet2/3286 ms3.5 Hz
1/8 note1/2214 ms4.67 Hz
1/8 triplet1/3143 ms7.0 Hz
1/16 note1/4107 ms9.33 Hz
1/16 triplet1/671 ms14 Hz
1/32 note1/854 ms18.7 Hz
1/64 note1/1627 ms37.3 Hz
A beat cut into equal parts. 1/8 is two wobbles a beat, 1/16 is four.

Guides describe quarter-note wobbles as slow and ominous, eighths as energetic, sixteenths as aggressive. Near the bottom of the table the wobble stops being a rhythm and turns into a texture, even a vowel. That's where the growl lives (The growl: drive, resonance and layers).

Shape is the shape of the movement: Sine (the classic smooth wub), Triangle (steadier, more angular), Saw down (snaps open, closes slowly: "yow"), Square (open, shut, nothing between: a stutter).

Sync decides where each wobble starts. Restart on each note starts every note closed, so every note sounds the same. Follow the song beat locks the wobble to the song grid and notes start wherever it happens to be, like a hand on the knob that never stops.

Show the full code: dubstep_bass.jsfx (211 lines)
desc:Dubstep Bass
// A two-layer dubstep bass in one file.
//   MID layer:  1-5 detuned saws
//                 -> resonant low-pass filter, its cutoff moved by a tempo-synced LFO (the wobble)
//                 -> drive (soft clipper)
//                 -> low cut (high-pass), so the mid layer leaves the low end to the sub
//   SUB layer:  a clean sine at the note's pitch. It never touches the filter,
//               the LFO or the drive.
// 4-voice polyphonic, mono output. The wobble is locked to the project tempo.
// "Restart on each note" makes every note start its wobble from the bottom;
// "Follow the song beat" keeps the wobble locked to the beat grid instead.
// All "times" are the time the sound takes to fall by 60 dB.

slider1:3<1,5,1>Saws per note
slider2:12<0,50,0.5>Detune spread (cents)
slider3:1<0,2,1{Same as note,+1 octave,+2 octaves}>Mid layer octave
slider4:0.8<0,1,0.01>Mid level
slider5:150<30,400,1:log=100>Mid low cut (Hz)
slider6:200<40,4000,1:log=300>Filter base cutoff (Hz)
slider7:3<0,6,0.05>Wobble depth (octaves)
slider8:4<0,9,1{1 bar,1/2 note,1/4 note,1/4 triplet,1/8 note,1/8 triplet,1/16 note,1/16 triplet,1/32 note,1/64 note}>Wobble rate
slider9:0<0,3,1{Sine,Triangle,Saw down,Square}>Wobble shape
slider10:1<0,1,1{Follow the song beat,Restart on each note}>Wobble sync
slider11:0.4<0,1,0.01>Filter resonance
slider12:12<0,36,0.5>Drive (dB)
slider13:0.7<0,1,0.01>Sub level
slider14:3<0.5,200,0.5:log=10>Attack (ms)
slider15:60<5,2000,1:log=100>Release (ms)
slider16:-9<-36,6,0.5>Output (dB)

in_pin:none
out_pin:Left
out_pin:Right

@init
// Runs once when the effect loads: set up variables and helper functions.
NV = 4;                        // number of voices
// --- memory map: one block of numbers per voice property ---
v_note = 0;  v_stage = 4;  v_env = 8;   v_vel = 12;  v_freq = 16;
v_lph = 20;  v_f1 = 24;    v_f2 = 28;   v_h1 = 32;   v_h2 = 36;
v_ph = 40;   // 6 phases per voice (5 saws + the sub) = 24 numbers
ev_off = 100; ev_kind = 116; ev_note = 132; ev_vel = 148;   // event queue (16 per block)
saw_ratio = 200;
// voice stage: 0 free, 1 attack, 2 held, 3 release

// note lengths of the wobble rates, in beats
len_tab = 300;
len_tab[0] = 4;   len_tab[1] = 2;    len_tab[2] = 1;      len_tab[3] = 2 / 3;   len_tab[4] = 0.5;
len_tab[5] = 1 / 3; len_tab[6] = 0.25; len_tab[7] = 1 / 6; len_tab[8] = 0.125; len_tab[9] = 0.0625;

function polyblep(t, dt) (
  t < dt ? ( t /= dt; t + t - t * t - 1; )
  : t > 1 - dt ? ( t = (t - 1) / dt; t * t + t + t + 1; )
  : 0;
);
function tanh_(x) local(e) (
  x = min(max(x, -20), 20);
  e = exp(2 * x);
  (e - 1) / (e + 1);
);
// Multiplier per sample that makes a level fall 60 dB in `ms` milliseconds.
function fall(ms) ( exp(-6.9 / (max(ms, 0.1) * 0.001 * srate)); );
// The wobble shape: 0 = closed filter, 1 = fully open. ph runs 0..1 over one cycle.
function lfo_shape(shape, ph) (
  shape == 0 ? 0.5 - 0.5 * cos(2 * $pi * ph)
  : shape == 1 ? (ph < 0.5 ? 2 * ph : 2 - 2 * ph)
  : shape == 2 ? 1 - ph
  : (ph < 0.5 ? 0 : 1);
);

@slider
// Runs whenever a slider moves: turn slider values into ready-to-use numbers.
nsaw = slider1;
saw_gain = 1 / sqrt(nsaw);
mid_mult = 2 ^ slider3;
lfo_len = len_tab[slider8];
amp_inc = 1 / (slider14 * 0.001 * srate);
amp_rel = fall(slider15);
res_k = 2 * (1 - slider11) + 0.1;         // filter damping: low = ringing, high = calm
drv = 10 ^ (slider12 / 20);
drv_norm = 1 / tanh_(drv);
ha = 1 - exp(-2 * $pi * min(slider5, srate * 0.45) / srate);
outgain = 10 ^ (slider16 / 20);
si = 0;
loop(5,
  norm = nsaw > 1 ? (si - (nsaw - 1) / 2) / ((nsaw - 1) / 2) : 0;   // -1 .. +1 across the saws
  saw_ratio[si] = 2 ^ (slider2 * norm / 1200);                      // detune as a frequency ratio
  si += 1;
);

@block
// Runs before each chunk of audio: read the incoming MIDI notes here.
blk_pos = 0;
ev_n = 0;
ev_i = 0;
bp0 = beat_position;                       // where the project is, in beats
beat_inc = tempo / (60 * srate);           // beats per sample
lfo_inc = beat_inc / lfo_len;              // LFO cycles per sample
while (midirecv(offs, m1, m2, m3)) (
  st = m1 & 0xF0;
  ev_n < 16 && (st == 0x90 || st == 0x80) ? (
    ev_off[ev_n] = offs;
    ev_kind[ev_n] = (st == 0x90 && m3 > 0);
    ev_note[ev_n] = m2;
    ev_vel[ev_n] = m3 / 127;
    ev_n += 1;
  );
);

@sample
// Runs once for EVERY audio sample (44,100+ times a second): make the sound here.
// ---- handle notes that start on this exact sample ----
while (ev_i < ev_n && ev_off[ev_i] <= blk_pos) (
  n = ev_note[ev_i];
  ev_kind[ev_i] ? (
    // note on: take a free voice, or steal the quietest one
    vi = 0; best = 1000000; j = 0;
    loop(NV,
      score = v_stage[j] == 0 ? -1 : v_env[j];
      score < best ? ( best = score; vi = j; );
      j += 1;
    );
    v_note[vi] = n;
    v_freq[vi] = 440 * 2 ^ ((n - 69) / 12);
    v_vel[vi] = ev_vel[ev_i];
    v_stage[vi] = 1;
    v_env[vi] = 0;
    v_lph[vi] = 0;
    v_f1[vi] = v_f2[vi] = v_h1[vi] = v_h2[vi] = 0;
    k = 0;
    loop(6, v_ph[vi * 6 + k] = 0; k += 1; );
  ) : (
    // note off: release every voice that is playing this note
    j = 0;
    loop(NV,
      (v_stage[j] == 1 || v_stage[j] == 2) && v_note[j] == n ? ( v_stage[j] = 3; );
      j += 1;
    );
  );
  ev_i += 1;
);

// ---- the wobble position that follows the song beat ----
bp = bp0 + blk_pos * beat_inc;
song_ph = bp / lfo_len;
song_ph -= floor(song_ph);

// ---- synthesize every active voice ----
out = 0;
j = 0;
loop(NV,
  v_stage[j] ? (
    // volume envelope: ramp up, hold, then fall away on note-off
    st = v_stage[j];
    e = v_env[j];
    st == 1 ? ( e += amp_inc; e >= 1 ? ( e = 1; v_stage[j] = 2; ); )
    : st == 3 ? ( e *= amp_rel; e < 0.0001 ? ( e = 0; v_stage[j] = 0; ); );
    v_env[j] = e;

    // wobble position for this voice
    lp_ph = v_lph[j];
    v_lph[j] = lp_ph + lfo_inc >= 1 ? lp_ph + lfo_inc - 1 : lp_ph + lfo_inc;
    ph_l = slider10 ? lp_ph : song_ph;
    u = lfo_shape(slider9, ph_l);

    // MID layer: detuned saws
    dt0 = v_freq[j] * mid_mult / srate;
    m = 0;
    i = 0;
    loop(nsaw,
      dt = dt0 * saw_ratio[i];
      p = v_ph[j * 6 + i] + dt;
      p >= 1 ? p -= 1;
      v_ph[j * 6 + i] = p;
      m += 2 * p - 1 - polyblep(p, dt);
      i += 1;
    );
    m *= saw_gain;

    // resonant low-pass filter (TPT state-variable); the LFO moves the cutoff
    fc = slider6 * 2 ^ (slider7 * u);
    fc = min(max(fc, 20), srate * 0.45);
    g = tan($pi * fc / srate);
    a1 = 1 / (1 + g * (g + res_k));
    a2 = g * a1;
    a3 = g * a2;
    v3 = m - v_f2[j];
    v1 = a1 * v_f1[j] + a2 * v3;
    v2 = v_f2[j] + a2 * v_f1[j] + a3 * v3;
    v_f1[j] = 2 * v1 - v_f1[j];
    v_f2[j] = 2 * v2 - v_f2[j];
    m = v2;

    // drive, then the low cut (two 6 dB/octave high-pass stages)
    m = tanh_(m * drv) * drv_norm;
    v_h1[j] += ha * (m - v_h1[j]);  m -= v_h1[j];
    v_h2[j] += ha * (m - v_h2[j]);  m -= v_h2[j];

    // SUB layer: a clean sine
    p = v_ph[j * 6 + 5] + v_freq[j] / srate;
    p >= 1 ? p -= 1;
    v_ph[j * 6 + 5] = p;
    sub = sin(2 * $pi * p);

    out += (m * slider4 + sub * slider13) * e * v_vel[j];
  );
  j += 1;
);
spl0 = out * outgain;
spl1 = out * outgain;
blk_pos += 1;

Download dubstep_bass.jsfx

Worth finding in the code:

Build it

  1. On Bass, wobble only (Drive off for now):
SliderValue
Saws per note3
Detune spread (cents)12
Mid layer octave+1 octave
Mid level0.8
Mid low cut (Hz)150
Filter base cutoff (Hz)200
Wobble depth (octaves)3
Wobble rate1/8 note
Wobble shapeSine
Wobble syncRestart on each note
Filter resonance0.4
Drive (dB)0
Sub level0.7
Attack (ms)3
Release (ms)60
Output (dB)-9

The mid layer plays an octave above the note (F2, 87 Hz, when you play F1), which lifts the buzz into phone-speaker range while the sub stays put.

  1. Play the two F1 notes: the buzz opens and closes twice a beat over a steady sub.
  2. Step through Wobble rate while it plays.
  3. BPM from 140 to 100 and back. The wobble follows.

Listen for

1/4 note: one wobble per beat.
1/8 note, the table's setting: two per beat.
1/16 note: four per beat.

Try this

What's an LFO?

An oscillator too slow to hear as pitch, used to move a control.

What does tempo sync mean for the wobble?

Its speed is a note value, so it follows the BPM.

What does Wobble depth do?

Sets how many octaves the cutoff swings above its base: cutoff = base × 2 ^ (depth × lfo).

Restart on each note vs Follow the song beat?

Restart starts every note closed. Follow keeps one wobble running on the song grid.

Why is the mid layer an octave up?

To put the buzz where small speakers can play it, while the sub keeps the depth.

More resources for Dubstep from scratch →