The kick: punch, tail and distortion
Build the hardstyle kick from a falling sine wave, a long decay and a hard clipper, and see why distortion makes the tail buzz.
Goal
The kick everything else in the genre hangs off: a sharp punch, then a long, squared-off, buzzing tail.
The idea
Start with the trance kick, a sine whose pitch falls fast with a decaying volume, and change two things.
- The tail is long, and it's a note. After the drop the pitch settles on G1 (49 Hz) and stays there while the volume decays over a few hundred milliseconds. The high start is the Punch, the low part the Tail.
- Everything gets smashed into a clipper. Multiply the wave by a big gain (Drive) and chop off whatever passes the maximum. That's Clipping, on purpose.
Why does that change everything? At 30 dB of drive (about 32 times louder), the sine slams into the limit and stays flat against it for as long as its level is above about 3% of full scale. A sine with flat tops is basically a square wave, and a square wave is full of odd harmonics (3, 5, 7 times the pitch).
Three consequences:
- The tail stays loud. While the wave is pinned to the limit its level can't fall, even as the sine underneath decays. At 30 dB of drive, the level 100 ms into the tail was within half a decibel of the level at 20 ms. With no drive the same tail had already dropped over 13 dB.
- The tail buzzes. Those harmonics turn "boom" into a bright, hard note, and let a phone speaker that can't play 49 Hz still play 147 and 245 Hz.
- Clipping makes fizz. Sharp corners contain very high harmonics, some of which fold back as Aliasing. A two-stage Low-pass filter after the clipper (Tail low-pass) sands it off.
Show the full code: hardstyle_kick.jsfx (95 lines)
desc:Hardstyle Kick
// A hardstyle kick from first principles:
// 1. a sine wave whose PITCH starts high and falls fast (the punch)
// 2. settling on a tail pitch, which can follow the MIDI note (a tuned tail)
// 3. a long volume decay
// 4. pushed HARD into a clipper, so the long tail turns into a squared-off,
// buzzing tone instead of fading away (the hardstyle sound)
// 5. a low-pass filter to tame the fizz the clipper creates
// Every MIDI note-on triggers the kick. In "Follow MIDI note" mode the note
// number sets the tail pitch (MIDI 31 = G1 = 49 Hz); otherwise it is ignored.
slider1:400<100,900,1:log=400>Start pitch (Hz)
slider2:18<3,120,1>Pitch fall time (ms)
slider3:0<0,1,1{Fixed,Follow MIDI note}>Tail pitch
slider4:49<30,80,0.5>Fixed tail pitch (Hz)
slider5:350<100,900,1>Tail decay (ms)
slider6:30<0,48,0.5>Drive (dB)
slider7:1<0,1,1{Soft (tanh),Hard (brickwall)}>Clip style
slider8:3000<300,10000,1:log=2000>Tail low-pass (Hz)
slider9:-6<-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;
ev_note = 32;
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;
lp1 = lp2 = 0;
tail = 49;
@slider
// Runs whenever a slider moves: turn slider values into ready-to-use numbers.
pitch_tau = slider2 * 0.001;
amp_tau = slider5 * 0.001 / 6.9; // 6.9 time-constants = 60 dB drop
drive = 10 ^ (slider6 / 20);
outgain = 10 ^ (slider9 / 20);
drive_norm = 1 / tanh_(drive);
lpa = 1 - exp(-2 * $pi * min(slider8, srate * 0.45) / srate);
// the tail is over when (level x drive) has fallen to 0.0001
t_end = min(3, amp_tau * log(max(drive, 1) * 10000));
@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_note[ev_n] = m2;
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];
tail = slider3 ? 440 * 2 ^ ((ev_note[ev_i] - 69) / 12) : slider4;
playing = 1;
t = 0;
phase = 0;
lp1 = lp2 = 0;
ev_i += 1;
);
s = 0;
playing ? (
freq = tail + (slider1 - tail) * exp(-t / pitch_tau);
phase += 2 * $pi * freq / srate;
phase > 2 * $pi ? phase -= 2 * $pi;
s = sin(phase) * exp(-t / amp_tau) * drive;
s = slider7 ? min(max(s, -1), 1) : tanh_(s) * drive_norm;
lp1 += lpa * (s - lp1);
lp2 += lpa * (lp1 - lp2);
s = lp2 * vel * outgain;
t += 1 / srate;
t > t_end ? playing = 0;
);
spl0 = s;
spl1 = s;
blk_pos += 1;
It reads like the trance kick (The kick: a sine wave with a falling pitch explains the sections). New bits:
tailis set per note: the Fixed tail pitch slider, or in Follow MIDI note mode the pitch of the note you played. Next tutorial.s = slider7 ? min(max(s, -1), 1) : tanh_(s) * drive_normis the clipper. Hard chops flat withminandmax; Soft bends smoothly withtanh_.lp1andlp2are the filter stages;t_endis when the tail is quiet enough to stop computing.
Build it
- The
Kicktrack from Hardstyle project setup and the kick instrument, four notes per bar. - Sliders:
| Slider | Value | Why |
|---|---|---|
| Start pitch (Hz) | 400 | where the punch starts |
| Pitch fall time (ms) | 18 | how fast it drops to the tail |
| Tail pitch | Fixed | ignore the MIDI note for now |
| Fixed tail pitch (Hz) | 49 | G1, the root |
| Tail decay (ms) | 350 | 60 dB fall, before the clipper |
| Drive (dB) | 30 | how hard it hits the clipper |
| Clip style | Hard (brickwall) | flat tops |
| Tail low-pass (Hz) | 3000 | removes the fizz |
| Output (dB) | -6 | headroom |
- Notes on every beat, velocity about 110:
Step: 1 . . . 2 . . . 3 . . . 4 . . .
Kick: X . . . X . . . X . . . X . . .
- Stretch the item to the end of bar 8, loop four bars, play.
Listen for
- A hard punch, then a buzz that lasts almost to the next beat.
- A tail that sounds like a note, not a thud.
- No sandpaper hiss on top. Hear some? Lower Tail low-pass.
Try this
- Drive 30 to 0: the buzz disappears and it fades like any kick. Up to 48: longer and nastier.
- Clip style Hard vs Soft. At 30 dB they're nearly the same; at 12 dB soft clipping rounds the peaks and stays warmer.
- Tail low-pass 8000 down to 1000: the top of the buzz dulls (about 29 dB less above 6 kHz at 1 kHz).
- Pitch fall time 3 ms: a hard click. 60 ms: a "pew".
- Tail decay 150: tight. 800: a roar that runs into the next kick.
Which part is the punch and which the tail?
The punch is the short high start; the tail is the long low note after it.
Why does heavy clipping keep the tail loud?
While the wave is pinned to the limit its level can't fall, even as the sine underneath decays.
Why does a clipped sine buzz?
Flattened peaks make it close to a square wave, which has strong odd harmonics.
What's the tail low-pass for?
Removing the very high fizz, including aliasing, that clipping's sharp corners create.