Home / Trance from scratch

The kick: a sine wave with a falling pitch

LearningUpdated 2026-09-27

Build the trance kick from first principles, tune it to the key, and program four-on-the-floor.

Goal

A punchy kick on every beat, tuned to the song's key, built from nothing but a sine wave.

The idea

Hit a real kick drum and the skin starts off moving fast and tight, then relaxes into its natural low note. So its pitch starts high and falls quickly. That downward sweep is the thump you feel in your chest. Two ingredients copy it:

  1. A sine whose frequency falls, from about 150 Hz to about 55 Hz in a few tens of milliseconds. The fast drop is the punch; the resting pitch is the weight.
  2. A volume that decays over a few hundred milliseconds. Long decay, boomy kick. Short decay, tight kick.

Optionally a soft clipper (drive) squashes the peaks. That adds harmonics, so the kick survives on laptop speakers that can't play 55 Hz at all.

The dashed line is the pitch, falling fast from 150 Hz to 55 Hz while the wave fades.

The resting pitch is a real note. Our track is in A, and 55 Hz is A1, the same note as the bass root (MIDI 33), so End pitch goes to exactly 55. A kick on the wrong note fights the bass all song long.

The maths per sample is tiny: a pitch that decays exponentially, a sine of the accumulated phase, a falling level. Here's the whole instrument:

Show the full code: trance_kick.jsfx (77 lines)
desc:Trance Kick
// A kick drum from first principles:
//   1. a sine wave whose PITCH starts high and falls fast (the "thump")
//   2. multiplied by a VOLUME envelope that decays away
//   3. optionally squashed by a soft clipper for extra harmonics
// Every incoming MIDI note-on triggers the drum; the note number is ignored.

slider1:150<40,400,1>Start pitch (Hz)
slider2:55<30,80,0.5>End pitch (Hz)
slider3:35<5,200,1>Pitch fall time (ms)
slider4:300<80,800,1>Decay time (ms)
slider5:6<0,24,0.5>Drive (dB)
slider6:-3<-24,0,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.
ev_off = 0;      // event queue: up to 16 note-ons per audio block
ev_vel = 16;
function tanh_(x) local(e) (
  x = min(max(x, -20), 20);
  e = exp(2 * x);
  (e - 1) / (e + 1);
);

playing = 0;
t = 0;
phase = 0;

@slider
// Runs whenever a slider moves: turn slider values into ready-to-use numbers.
pitch_tau = slider3 * 0.001;
amp_tau = slider4 * 0.001 / 6.9;   // 6.9 time-constants = 60 dB drop
drive = 10 ^ (slider5 / 20);
outgain = 10 ^ (slider6 / 20);
drive_norm = 1 / tanh_(drive);

@block
// Runs before each chunk of audio: read the incoming MIDI notes here.
blk_pos = 0;
ev_n = 0;
ev_i = 0;
while (midirecv(offs, m1, m2, m3)) (
  (m1 & 0xF0) == 0x90 && m3 > 0 && ev_n < 16 ? (
    ev_off[ev_n] = offs;
    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.
while (ev_i < ev_n && ev_off[ev_i] <= blk_pos) (
  vel = ev_vel[ev_i];
  playing = 1;
  t = 0;
  phase = 0;
  ev_i += 1;
);

s = 0;
playing ? (
  freq = slider2 + (slider1 - slider2) * exp(-t / pitch_tau);
  phase += 2 * $pi * freq / srate;
  phase > 2 * $pi ? phase -= 2 * $pi;
  s = sin(phase) * exp(-t / amp_tau);
  s = tanh_(s * drive) * drive_norm;
  s *= vel * outgain;
  t += 1 / srate;
  t > slider4 * 0.001 * 1.5 ? playing = 0;
);
spl0 = s;
spl1 = s;
blk_pos += 1;

Download trance_kick.jsfx

Reading it:

Build it

  1. Open the project from Project setup and installing the instruments. The Kick track already has Trance Kick and a one-bar item.
  2. Set the sliders:
SliderValueWhy
Start pitch (Hz)150where the punch starts
End pitch (Hz)55the A of our key
Pitch fall time (ms)35how fast it drops
Decay time (ms)300time to fall 60 dB
Drive (dB)6a few extra harmonics
Output (dB)-3headroom
  1. Put one note on each beat, velocity about 110. Any pitch, any length: the kick only cares when a note starts.
Step:  1 . . . 2 . . . 3 . . . 4 . . .     (16th-note steps; 1 2 3 4 are the beats)
Kick:  X . . . X . . . X . . . X . . .
  1. Drag the item's right edge out to the end of bar 16. New MIDI items loop, so the bar repeats. (Or Ctrl-drag to copy it.)
  2. Loop the first four bars and play.
Download the notes (MIDI)

Drag a file onto the track at the bar where it starts. How: using the MIDI files.

Listen for

Two bars at the settings in the table.

Try this

One slider at a time, while it loops:

Why does a kick sound thumpy?

Its pitch starts high and falls fast to a low resting note.

Why is End pitch set to 55 Hz here?

55 Hz is A1, the key and the bass root. A kick on the same note doesn't clash.

What's the drive control for?

Soft clipping adds harmonics, so the kick is audible on speakers that can't play the lowest notes.

Why read MIDI in @block but start the sound in @sample?

So the kick starts on the exact sample where the note begins, not at the start of a buffer.