Home / Sound recipes

The Lab Synth: one synth for every recipe

LearningUpdated 2026-09-28

Install the Lab Synth, the instrument behind the sound recipes, and learn its controls in ten minutes.

Every recipe in this area uses one instrument, the Lab Synth, plus the drum instruments from the song series where a recipe needs drums. Install it once and each recipe page stands on its own: a settings table, the notes as a MIDI file, and a clip of what it should sound like.

Install

  1. Download lab_synth.jsfx. For the drum recipes you'll also want trance_kick.jsfx and trance_noise_drum.jsfx; the supersaw recipe uses trance_synth.jsfx.
  2. Options, Show REAPER resource path..., copy the files into Effects, restart REAPER.
  3. On a track: FX button, Add, search lab, add JS: Lab Synth.

The controls

The signal runs: two oscillators plus a sub and noise, into a filter, into a volume envelope, then drive and chorus.

SectionSlidersWhat they're for
VoiceVoice mode, Glide timePoly plays chords. Mono plays one note; overlap two notes and the pitch glides from one to the next without restarting (a 303 slide, an 808 glide)
OscillatorsOsc 1 shape, Osc 2 shape, level, octave, detuneSaw, Pulse, Triangle, Sine, or PWM saw. Detune two saws and they beat against each other (the Reese)
PulsePulse width, PWM depthHow wide the pulse is (50% is a square), and how much the LFO moves it
ExtrasSub sine, NoiseWeight an octave down; hiss for breath and grit
Filtertype, slope, cutoff, resonanceLow-, high- or band-pass, 12 or 24 dB per octave
Filter envelopeamount, decayPushes the cutoff up at each note and lets it fall: the "pew"
AccentAccentNotes at velocity 100 or more get a bigger filter sweep and extra level (the 303 trick)
Pitch envelopeamount, timeStarts each note off-pitch and bends it in; time is roughly how long the bend takes to die away
LFOrate, shape, to pitch, to cutoffOne slow wave for vibrato, wobble and PWM
Ampattack, decay, sustain, releaseThe volume envelope
OutputDrive, Chorus mix, OutputSoft clipping, a stereo chorus, and level
Mono mode: overlapping notes slide, separated notes jump. That one rule is how 303 slides and 808 glides work.
Show the full code: lab_synth.jsfx (232 lines)
desc:Lab Synth
// A small, flexible synth for recreating classic sounds.
//   2 oscillators (saw, pulse, triangle, sine, PWM saw) + sub sine + noise
//     -> filter (low/high/band-pass, 12 or 24 dB/octave) with a decay envelope
//     -> volume envelope (ADSR) -> drive -> chorus
// Extras: mono mode with legato glide (303 slide, 808 glide), accent on loud
// notes (velocity 100+), a pitch envelope, and one LFO for pitch, cutoff and
// pulse width. 8 voices in Poly mode, 1 in Mono.
// All decay/release times are the time the sound takes to fall by 60 dB.

slider1:0<0,1,1{Poly (8 voices),Mono (legato glide)}>Voice mode
slider2:0<0,1000,1>Glide time (ms)
slider3:0<0,4,1{Saw,Pulse,Triangle,Sine,PWM saw}>Osc 1 shape
slider4:0<0,4,1{Saw,Pulse,Triangle,Sine,PWM saw}>Osc 2 shape
slider5:0<0,1,0.01>Osc 2 level
slider6:1<0,3,1{-1 octave,Same,+1 octave,+2 octaves}>Osc 2 octave
slider7:0<-50,50,0.5>Osc 2 detune (cents)
slider8:50<5,95,0.5>Pulse width (%)
slider9:0<0,1,0.01>PWM depth (LFO)
slider10:0<0,1,0.01>Sub sine (1 octave down)
slider11:0<0,1,0.01>Noise
slider12:0<0,2,1{Low-pass,High-pass,Band-pass}>Filter type
slider13:0<0,1,1{12 dB/oct,24 dB/oct}>Filter slope
slider14:18000<30,18000,1:log=1200>Filter cutoff (Hz)
slider15:0.1<0,1,0.01>Filter resonance
slider16:0<-4,8,0.05>Filter env amount (octaves)
slider17:200<5,3000,1:log=200>Filter env decay (ms)
slider18:0<0,1,0.01>Accent (velocity 100+)
slider19:0<-24,24,0.5>Pitch env amount (semitones)
slider20:50<1,1000,1:log=80>Pitch env time (ms)
slider21:1<0.05,20,0.01:log=2>LFO rate (Hz)
slider22:0<0,3,1{Sine,Triangle,Square,Saw down}>LFO shape
slider23:0<0,100,1>LFO to pitch (cents)
slider24:0<0,4,0.05>LFO to cutoff (octaves)
slider25:2<0.5,4000,0.5:log=50>Amp attack (ms)
slider26:400<5,6000,1:log=300>Amp decay (ms)
slider27:0.8<0,1,0.01>Amp sustain
slider28:150<5,6000,1:log=250>Amp release (ms)
slider29:0<0,36,0.5>Drive (dB)
slider30:0<0,1,0.01>Chorus mix
slider31:-9<-36,6,0.5>Output (dB)

in_pin:none
out_pin:Left
out_pin:Right

@init
NV = 8;
// memory map: one block of NV numbers per voice property
v_note = 0;    v_stage = 8;   v_env = 16;   v_fenv = 24;  v_vel = 32;
v_acc = 40;    v_f = 48;      v_ft = 56;    v_penv = 64;  v_p1 = 72;
v_p2 = 80;     v_ps = 88;     v_a1 = 96;    v_a2 = 104;   v_b1 = 112;
v_b2 = 120;
ev_off = 200;  ev_kind = 216; ev_note = 232; ev_vel = 248;  // event queue
held = 300;    nheld = 0;                                    // mono note stack
cbuf = 1000;   CLEN = 4096;   cpos = 0;                      // chorus delay line
lfo_ph = 0;    cho_ph = 0;    dc_xl = dc_yl = dc_xr = dc_yr = 0;

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); );
function fall(ms) ( exp(-6.9 / (max(ms, 0.1) * 0.001 * srate)); );
function mtof(n) ( 440 * 2 ^ ((n - 69) / 12); );
// one oscillator sample. shape: 0 saw, 1 pulse, 2 triangle, 3 sine, 4 PWM saw
function osc(shape, p, dt, pw) local(s, q) (
  shape == 0 ? ( 2 * p - 1 - polyblep(p, dt); )
  : shape == 1 ? (
      s = (p < pw ? 1 : -1);
      s += polyblep(p, dt);
      q = p - pw; q < 0 ? q += 1;
      s - polyblep(q, dt);
    )
  : shape == 2 ? ( p < 0.5 ? 4 * p - 1 : 3 - 4 * p; )
  : shape == 3 ? ( sin(2 * $pi * p); )
  : ( p < 1 - pw ? 2 * p / (1 - pw) - 1 : 1; );   // saw that rises, then holds flat for pw
);
// TPT state-variable filter step; returns lp, hp or bp depending on ftype
function svf(x, s1, s2) local(v1, v2, v3) instance(o1, o2) (
  v3 = x - s2;
  v1 = fa1 * s1 + fa2 * v3;
  v2 = s2 + fa2 * s1 + fa3 * v3;
  o1 = 2 * v1 - s1;  o2 = 2 * v2 - s2;
  ftype == 0 ? v2 : ftype == 1 ? x - fk * v1 - v2 : v1;
);
function lfo_val(ph) (
  slider22 == 0 ? sin(2 * $pi * ph)
  : slider22 == 1 ? (ph < 0.5 ? 4 * ph - 1 : 3 - 4 * ph)
  : slider22 == 2 ? (ph < 0.5 ? 1 : -1)
  : 1 - 2 * ph;
);
function start_voice(vi, n, vel) (
  v_note[vi] = n; v_vel[vi] = vel; v_acc[vi] = vel >= 100 / 127 ? slider18 : 0;
  v_stage[vi] = 1; v_env[vi] = 0; v_fenv[vi] = 1; v_penv[vi] = 1;
  v_f[vi] = v_ft[vi] = mtof(n);
  v_a1[vi] = v_a2[vi] = v_b1[vi] = v_b2[vi] = 0;
  v_p1[vi] = 0; v_p2[vi] = 0.25; v_ps[vi] = 0;
);

@slider
amp_inc = 1 / (slider25 * 0.001 * srate);
amp_dec = fall(slider26);
amp_rel = fall(slider28);
f_dec = fall(slider17);
p_dec = exp(-1 / (max(slider20, 1) * 0.001 * srate / 4.6));   // pitch env: ~1% left after the time
glide_c = slider2 > 0 ? exp(-1 / (slider2 * 0.001 * srate / 4.6)) : 0;
o2_ratio = 2 ^ (slider6 - 1) * 2 ^ (slider7 / 1200);
drv = 10 ^ (slider29 / 20); drv_norm = 1 / tanh_(drv);
outgain = 10 ^ (slider31 / 20);
ftype = slider12;
fk = 2 * (1 - slider15) + 0.05;       // damping: low = ringing
lfo_inc = slider21 / srate;
mono = slider1;

@block
blk_pos = 0; ev_n = 0; ev_i = 0;
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
while (ev_i < ev_n && ev_off[ev_i] <= blk_pos) (
  n = ev_note[ev_i];
  mono ? (
    ev_kind[ev_i] ? (
      // mono: legato (another note still held) glides without retriggering
      (nheld > 0 && v_stage[0] && v_stage[0] != 3) ? (
        v_ft[0] = mtof(n); v_note[0] = n;
        glide_c == 0 ? v_f[0] = v_ft[0];
      ) : ( start_voice(0, n, ev_vel[ev_i]); );
      nheld < 8 ? ( held[nheld] = n; nheld += 1; );
    ) : (
      // remove from the stack; if other notes are held, glide back to the latest
      j = 0; k = 0;
      loop(nheld, held[j] != n ? ( held[k] = held[j]; k += 1; ); j += 1; );
      nheld = k;
      nheld > 0 ? (
        v_note[0] != held[nheld - 1] ? ( v_ft[0] = mtof(held[nheld - 1]); v_note[0] = held[nheld - 1];
                                         glide_c == 0 ? v_f[0] = v_ft[0]; );
      ) : ( v_stage[0] == 1 || v_stage[0] == 2 ? v_stage[0] = 3; );
    );
  ) : (
    ev_kind[ev_i] ? (
      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; );
      start_voice(vi, n, ev_vel[ev_i]);
    ) : (
      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;
);

// global LFO
lfo_ph += lfo_inc; lfo_ph >= 1 ? lfo_ph -= 1;
lv = lfo_val(lfo_ph);
pw = min(max(slider8 / 100 + slider9 * 0.4 * lv, 0.03), 0.97);
vib = 2 ^ (slider23 * lv / 1200);

out = 0;
j = 0;
loop(mono ? 1 : NV,
  v_stage[j] ? (
    st = v_stage[j]; e = v_env[j];
    st == 1 ? ( e += amp_inc; e >= 1 ? ( e = 1; v_stage[j] = 2; ); )
    : st == 2 ? ( e = slider27 + (e - slider27) * amp_dec; )
    : ( e *= amp_rel; e < 0.0001 ? ( e = 0; v_stage[j] = 0; ); );
    v_env[j] = e;
    v_fenv[j] *= f_dec;
    v_penv[j] *= p_dec;
    // glide: move the current frequency toward the target in log steps
    v_f[j] = v_ft[j] * (v_f[j] / v_ft[j]) ^ glide_c;
    f0 = v_f[j] * 2 ^ (slider19 * v_penv[j] / 12) * vib;

    dt1 = min(f0 / srate, 0.45);
    p = v_p1[j] + dt1; p >= 1 ? p -= 1; v_p1[j] = p;
    s = osc(slider3, p, dt1, pw);
    slider5 > 0 ? (
      dt2 = min(f0 * o2_ratio / srate, 0.45);
      p = v_p2[j] + dt2; p >= 1 ? p -= 1; v_p2[j] = p;
      s += slider5 * osc(slider4, p, dt2, pw);
    );
    slider10 > 0 ? (
      p = v_ps[j] + f0 * 0.5 / srate; p >= 1 ? p -= 1; v_ps[j] = p;
      s += slider10 * sin(2 * $pi * p);
    );
    slider11 > 0 ? s += slider11 * (rand(2) - 1);

    // filter: cutoff moved by the filter envelope (bigger on accents) and the LFO
    acc = v_acc[j];
    fc = slider14 * 2 ^ (slider16 * (1 + acc) * v_fenv[j] + slider24 * lv);
    fc = min(max(fc, 20), srate * 0.45);
    g = tan($pi * fc / srate);
    fa1 = 1 / (1 + g * (g + fk)); fa2 = g * fa1; fa3 = g * fa2;
    y = f1.svf(s, v_a1[j], v_a2[j]); v_a1[j] = f1.o1; v_a2[j] = f1.o2;
    slider13 ? ( y = f2.svf(y, v_b1[j], v_b2[j]); v_b1[j] = f2.o1; v_b2[j] = f2.o2; );

    out += y * e * v_vel[j] * (1 + 0.5 * acc);
  );
  j += 1;
);

// drive, DC blocker, chorus
out = slider29 > 0 ? tanh_(out * drv) * drv_norm : out;
cbuf[cpos] = out;
l = r = out;
slider30 > 0 ? (
  cho_ph += 0.8 / srate; cho_ph >= 1 ? cho_ph -= 1;
  dl = (0.012 + 0.005 * sin(2 * $pi * cho_ph)) * srate;
  dr = (0.012 + 0.005 * sin(2 * $pi * (cho_ph + 0.25))) * srate;
  i0 = floor(dl); fr = dl - i0;
  a = cbuf[(cpos - i0 + CLEN) % CLEN]; b = cbuf[(cpos - i0 - 1 + CLEN) % CLEN];
  wl = a + (b - a) * fr;
  i0 = floor(dr); fr = dr - i0;
  a = cbuf[(cpos - i0 + CLEN) % CLEN]; b = cbuf[(cpos - i0 - 1 + CLEN) % CLEN];
  wr = a + (b - a) * fr;
  l = out * (1 - 0.5 * slider30) + wl * slider30;
  r = out * (1 - 0.5 * slider30) + wr * slider30;
);
cpos = (cpos + 1) % CLEN;
yl = l - dc_xl + 0.995 * dc_yl; dc_xl = l; dc_yl = yl;
yr = r - dc_xr + 0.995 * dc_yr; dc_xr = r; dc_yr = yr;
spl0 = yl * outgain;
spl1 = yr * outgain;
blk_pos += 1;

Download lab_synth.jsfx

The recipes

What does Mono mode do when two notes overlap?

The pitch glides from the first to the second without restarting the envelopes.

What does the Accent control do?

Notes at velocity 100 or more get a bigger filter sweep and more level.

What's the PWM saw?

A saw that holds flat for part of each cycle; the pulse width sets how much.