sound patterns + three little operators — replicate, speed, weight — and you can write most of drum-machine history in a line each.
sound !"bd ~ sn ~" is a track with no patch: each token names a sample (bd kick, sn snare, hh hat, cp clap…).
hh!3 replicates a token — three even hats without typing them. hh*2 plays a step double-time. They compose: [hh hh*2] is a hat then two faster ones in half the space.
sn@2 gives a step twice the width — long slots lean, short slots rush. Uneven widths are how a machine groove stops sounding like a grid.
Keep the synth bassline playing underneath: drums and synths are just tracks, and tracks stack.
The starting point#
The lesson opens with this song in the editor. Every edit recompiles and plays.
-- The drum machine: a bassline with no drums. Build the kit around it.
bass = patch {
source = saw (freq pitch),
ampEnv = adsr 2ms 150ms 0 90ms,
cutoff = 800Hz,
gain = vel * 0.5
}
line = play bass !"c2 ~ [c2 eb2] g1"
What to watch#
Each drum owns a different part of the spectrum: the kick is the low hump, the snare the middle, the hats the bright fizz up top.
Goals#
The workbench checks these as you work; the solution is there when you want it.
- Add a sound drum track
- Replicate a token with !
- Double-time a step with *2
- Stretch: widen a step with @
Make it yours#
Build a beat in three tracks — kick, snare, hats — where the hats use ! and *2 and nothing else. Then delete the kick's third hit and hear what its absence does.
Further reading#
The sampler in the reference.