May this site count your visit with Google Analytics? It sets cookies and is used only for visit statistics. Privacy →

Step 02 of 11

Rhythm and drums

The pulse, meter and note lengths, the drum kit, the beat lab and hi-hats.

2.1The pulse

Everything loops in cycles. s("bd*4") plays the sample bd (bass drum) four times per cycle: a four-on-the-floor kick. setcpm sets cycles per minute, so 124/4 gives 31 bars a minute, which is 124 BPM.

Strudel · lesson 2.1Open in Strudel ↗
setcpm(124/4)

s("bd*4")

Listen for

A steady kick on every beat. The word bd lights up each time it plays.

Try changing

  • "bd*2" or "bd*8"
  • "bd(3,8)" (3 hits spread over 8 steps)
  • setcpm(90/4)

2.2Meter & note length

In regular sheet music, the time signature (meter) and note lengths are written with symbols. In Strudel both come from one rule: a cycle is one bar, and whatever you write inside the quotes shares that bar equally. Four items make four beats, three items make three beats, and so on. The tempo function tells the bar how long to last.

Tempo for any meter

Divide the BPM by the number of beats in the bar. setcpm counts bars (cycles) per minute: setcpm(124/4) is 124 beats ÷ 4 beats per bar = 31 bars a minute.

MeterFeelBeats per barStrudel
4/4 at 124 BPMPop, house, rock4setcpm(124/4)
3/4 at 90 BPMWaltz3setcpm(90/3)
6/8, 80 beatsBallad, folk: 2 big beats of 32 (dotted quarters)setcpm(80/2)
5/4 at 140 BPMJazz ("Take Five")5setcpm(140/5)
7/8, eighth = 210Balkan, prog7 (eighths)setcpm(210/7)

Note lengths

In 4/4, a note's length depends on how many steps share the bar. At 120 BPM one bar lasts 2 seconds:

One 4/4 bar at 120 BPM. Triplets fit three notes where two would normally go.
WriteLengthHow it works
"c"Whole noteOne item fills the whole bar
"c e"Half notesTwo items share the bar
"c e g b"Quarter notesFour items, one per beat
"[c e] g b d"Two eighths, then quarters[ ] squeezes its items into one beat
"[c e g] b"Quarter-note triplet, then a halfThree notes in the space of a half note
"[c e g]*4"Eighth-note tripletsThree notes in every beat
"c@3 e g@2 e@2"Dotted quarter, eighth, quarter, quarter@ sets a weight. The weights add up to 8, so each unit is an eighth note
"c ~ ~ e" or "c ~@2 e"Rests~ is silence and can be stretched with @ too
note("c e").slow(2)Longer than a barEach note now lasts a whole bar. .slow(4) makes them twice as long again
Strudel · note lengthsOpen in Strudel ↗
setcpm(100/4)

// one bar each: whole, halves, quarters, eighths
$: note("<c4 [c4 e4] [c4 e4 g4 e4] [c4 e4 g4 e4 c5 g4 e4 g4]>")
  .s("gm_vibraphone")
$: s("bd*4").bank("RolandTR909").gain(.5)
Strudel · dotted notes & tripletsOpen in Strudel ↗
setcpm(100/4)

// bar 1: dotted rhythm · bar 2: eighth triplets · bar 3: quarter triplets
$: note("<[c4@3 e4 g4@2 e4@2] [c4 e4 g4]*4 [[c4 e4 g4] [g4 e4 c4]]>")
  .s("gm_vibraphone")
$: s("bd*4").bank("RolandTR909").gain(.5)

Step length versus sound length

The step decides when a note starts. How long it actually sounds is separate. A synth note lasts until its step ends. A sample plays to the end of its file, even past the step. .clip() controls this: 1 lasts the full step (legato), .5 lasts half the step, and .1 is very short (staccato).

Strudel · legato to staccatoOpen in Strudel ↗
// bar 1: full length · bar 2: half · bar 3: very short
note("c3 e3 g3 c4").s("sawtooth").lpf(1500)
  .clip("<1 .5 .1>")

Meters in practice

3/4 waltz. Three beats in a bar: bass on 1, chords on 2 and 3.

Strudel · 3/4 waltzOpen in Strudel ↗
setcpm(90/3)

$: s("bd hh hh").bank("RolandTR808").gain("1 .5 .5")
$: note("<a2 d2 e2 a2>").s("gm_acoustic_bass")
$: chord("<Am Dm E Am>").struct("~ x x").voicing()
  .s("gm_piano").gain(.6)

6/8. Six eighth notes grouped as 3 + 3, so it feels like two big swaying beats. Accents on steps 1 and 4 make the grouping audible.

Strudel · 6/8Open in Strudel ↗
setcpm(80/2)   // 80 dotted-quarter beats per minute

$: s("bd hh hh sd hh hh").bank("RolandTR909")
  .gain("1 .4 .5 .9 .4 .5")
$: note("<a2 f2 g2 e2>").struct("x ~ ~ x ~ x")
  .s("sawtooth").lpf(600).clip(.8)

5/4. Five beats, grouped 3 + 2. Brackets alone would give both groups the same length, so use @ to weight them by how many beats each group has.

Strudel · 5/4Open in Strudel ↗
setcpm(140/5)

// wrong: "[bd hh hh] [sd hh]" makes both halves equal length
$: s("[bd hh hh]@3 [sd hh]@2").bank("RolandTR909")
$: chord("<Ebm7 Bbm7>").struct("x ~ ~ x ~").voicing()
  .s("gm_epiano1").gain(.6)

7/8. Seven eighth notes, grouped 2 + 2 + 3 so the bar feels short-short-long. Write all seven steps out.

Strudel · 7/8Open in Strudel ↗
setcpm(210/7)

$: s("bd ~ sd ~ bd bd sd").bank("RolandTR808")
$: s("hh*7").bank("RolandTR808")
  .gain(".7 .3 .7 .3 .7 .3 .3")

Polymeter. { }%8 plays a pattern of any length over a grid of 8 steps per bar. A 3-note pattern on an 8-step grid keeps shifting against the beat, which gives a rolling, hypnotic feel used a lot in techno.

Strudel · polymeterOpen in Strudel ↗
setcpm(124/4)

$: s("bd*4").bank("RolandTR909")
$: s("{hh hh oh}%8").bank("RolandTR909").gain(.5)
$: note("{c2 eb2 g2 bb2 g2}%8").s("sawtooth").lpf(900).clip(.5)

2.3The drum kit

GUIDED · 5 LAYERS · IN THE EDITORBuild the drum kit step by step →One layer at a time, with the explanation next to the code. Change anything and press Ctrl+Enter.

Each line that starts with $: is a separate layer, and all layers play together. .bank("RolandTR909") picks the drum machine. ~ is a rest, so "~ cp ~ cp" puts a clap on beats 2 and 4. "[~ oh]*4" repeats "rest, open hat" four times, which puts the open hat on every off-beat.

Strudel · lesson 2.3Open in Strudel ↗
setcpm(124/4)

$: s("bd*4").bank("RolandTR909")
$: s("~ cp ~ cp").bank("RolandTR909")
$: s("[~ oh]*4").bank("RolandTR909").gain(.4)

Highlighted lines are new or changed in this lesson.

One cycle split into 16 steps. The closed hats (hh) are added in lesson 2.5.

Mini-notation cheat sheet

WriteMeaningExample
a b cSplit the cycle into equal steps"bd sd hh"
~Rest (silence)"bd ~ sd ~"
[ ]Group several sounds into one step"bd [sd sd]"
*nRepeat n times inside the step"hh*8"
< >Play one item per cycle, in turn"<bd cp>"
,Play at the same time"bd*2, hh*4"
(k,n)Euclidean rhythm: k hits over n steps"bd(3,8)"
!nRepeat the item n times as steps"bd!3 sd"
@nMake a step n times longer"c@3 e"
:nPick sample number n"hh:2"

Try changing

  • .bank("RolandTR808") on every line
  • "~ cp ~ [cp cp]"
  • "bd*4, ~ bd:1" on the kick

2.4Beat lab: drum patterns in detail

Lesson 2.3 gave you one groove. This lab shows how to write any drum pattern: nine short beats in different styles, each with a play button, and the mistakes beginners hit most often.

How a drum line is built

Strudel · anatomyOpen in Strudel ↗
s("bd sd bd sd, hh*8").bank("RolandTR909")
PartWhat it does
s( … )Says "the words inside are sound names". Without it, Strudel plays its default synth.
"bd sd bd sdFour words split the bar into four equal steps, one per beat: kick, snare, kick, snare.
,Starts a second layer that plays at the same time.
hh*8"Eight closed hi-hats per bar (eighth notes).
.bank("RolandTR909")Which drum machine to use. Try "RolandTR808".

Drum sound names

NameSoundNameSound
bdBass drum (kick)lt mt htLow, mid, high tom
sdSnare drumcrCrash cymbal
cpHand claprdRide cymbal (909)
hhClosed hi-hatcbCowbell (808)
ohOpen hi-hatshShaker (808)
rimRimshotpercPercussion (808)

To browse every sound, open the sounds tab on the right side of the Strudel page and click a name to hear it.

1 · Pop / rock beat

The most common beat in popular music: kick on beats 1 and 3, snare on 2 and 4, and eighth-note hats over the top.

Strudel · rock beatOpen in Strudel ↗
setcpm(110/4)

s("bd sd bd sd, hh*8").bank("RolandTR909")

2 · House in one line

Lesson 2.3's groove in a single line. The commas stack four layers: kick on every beat, clap on 2 and 4, open hat on the off-beats, and 16 closed hats.

Strudel · houseOpen in Strudel ↗
setcpm(124/4)

s("bd*4, ~ cp ~ cp, [~ oh]*4, hh*16").bank("RolandTR909")

3 · Drum & bass: writing all 16 steps

When a rhythm is irregular, write out all 16 steps. Each word or ~ is one sixteenth note; count them as "1 e & a, 2 e & a…". The kick lands on steps 1, 8 and 11, and the snare on 5 and 13.

Strudel · drum & bassOpen in Strudel ↗
setcpm(172/4)

// 16 steps: 1 e & a  2 e & a  3 e & a  4 e & a
$: s("bd ~ ~ ~ sd ~ ~ bd ~ ~ bd ~ sd ~ ~ ~").bank("RolandTR909")
$: s("hh*16").bank("RolandTR909").gain(.4)

4 · Hip-hop with swing

A slow 808 beat with an off-grid kick. .swingBy(1/3, 4) delays every second hat slightly, which gives the laid-back "swing" feel. Remove that line to hear the difference.

Strudel · hip-hopOpen in Strudel ↗
setcpm(90/4)

$: s("bd ~ ~ bd ~ bd ~ ~, ~ ~ sd ~ ~ ~ sd ~").bank("RolandTR808")
$: s("hh*8").bank("RolandTR808").gain(.6)
  .swingBy(1/3, 4)

5 · Euclidean rhythms

(3,8) spreads 3 hits as evenly as possible over 8 steps, a rhythm found in Afro-Cuban and Latin music. An optional third number rotates the pattern: (5,8,2) starts two steps later. Stack a few of these to get a polyrhythmic groove from very little code.

Strudel · euclideanOpen in Strudel ↗
setcpm(110/4)

$: s("bd(3,8)").bank("RolandTR808")
$: s("rim(5,8,2)").bank("RolandTR808").gain(.6)
$: s("cb(2,8,3)").bank("RolandTR808").gain(.4)
$: s("hh*8").bank("RolandTR808").gain(.4)

6 · Variations with < >

< > picks a different item each bar. The last snare of the bar changes over a 4-bar phrase: a single hit, a double, a single hit, then a roll of four.

Strudel · snare variationsOpen in Strudel ↗
setcpm(124/4)

$: s("bd*4").bank("RolandTR909")
$: s("~ sd ~ <sd [sd sd] sd [sd*4]>").bank("RolandTR909")
$: s("hh*8").bank("RolandTR909").gain(.5)

7 · A tom fill every 4th bar

Producers mark the end of a phrase with a fill. Here the kick stops halfway through bar 4 while the toms roll down (high, mid, low, low), and a crash cymbal marks the start of each new phrase.

Strudel · tom fillOpen in Strudel ↗
setcpm(124/4)

$: s("<bd*4 bd*4 bd*4 [bd bd ~ ~]>").bank("RolandTR909")
$: s("~ cp ~ cp").bank("RolandTR909")
$: s("hh*8").bank("RolandTR909").gain(.5)
$: s("<~ ~ ~ [~ ~ [ht mt] [lt lt]]>").bank("RolandTR909")
$: s("<cr ~ ~ ~>").bank("RolandTR909").gain(.5)

8 · Human feel

A drum machine hits every note at the same volume, and real drummers don't. rand.range(.25, .7) gives each hat a random volume. .degradeBy(.15) randomly drops 15% of the hits, and .pan(sine.slow(2)) moves the hats slowly from left to right.

Strudel · human feelOpen in Strudel ↗
setcpm(124/4)

$: s("bd*4").bank("RolandTR909")
$: s("~ cp ~ cp").bank("RolandTR909")
$: s("hh*16").bank("RolandTR909")
  .gain(rand.range(.25, .7))
  .degradeBy(.15)
  .pan(sine.slow(2))

9 · Choosing samples inside a set

Some sound names hold several samples. jazz is a whole kit: 0 is a kick, 3 a hi-hat and 7 a snare. You can pick one with n() or with name:number.

Strudel · sample numbersOpen in Strudel ↗
setcpm(100/4)

// n() picks the sample number
$: n("0 ~ 0 [~ 0]").s("jazz")
// the same idea written as name:number
$: s("~ jazz:7 ~ jazz:7, jazz:3*8").gain(.6)

Common mistakes

You wroteWhat happensFix
("bd sd").bank("RolandTR909")Error: sound RolandTR909_triangle not found. Without s() the words aren't sounds, so Strudel uses its default triangle synth and the bank prefix is added to that.s("bd sd").bank(…)
s('bd sd')Error: sound bd sd not found. Single quotes make a plain string, not mini-notation.Always use double quotes: "bd sd"
Two lines without $:Only the last line plays.Start each line with $:, or join them with a comma inside one s("…")
s("bd*4 sd*2 hh")The bar is split into 3 parts: four fast kicks, two snares, one hat. It sounds like a stumble.Use commas for layers: s("bd*4, ~ sd ~ sd, hh*8")
.bank("TR-909")Error: sound TR-909_bd not found.Use an exact bank name (RolandTR909) or its short alias (TR909). See the Sound bank appendix.
A missing ) or "A red syntax error. The old version keeps playing.Check that every bracket and quote is closed

2.5Hi-hats that breathe

Sixteen closed hats would sound mechanical at one volume. .gain("[.25 .5]*8") alternates quiet and louder hits, which creates an accent pattern. .sometimesBy(.2, x => x.ply(2)) picks about 20% of the hits at random and doubles them (ply), so the groove changes slightly every bar.

Strudel · lesson 2.5Open in Strudel ↗
setcpm(124/4)

$: s("bd*4").bank("RolandTR909")
$: s("~ cp ~ cp").bank("RolandTR909")
$: s("[~ oh]*4").bank("RolandTR909").gain(.4)
$: s("hh*16").bank("RolandTR909")
  .gain("[.25 .5]*8")
  .sometimesBy(.2, x => x.ply(2))

Listen for

Small rolls in the hats that never repeat exactly.

Try changing

  • .sometimesBy(.5, …)
  • "[.2 .4 .7 .4]*4" as the gain
  • x => x.speed(1.5) in place of ply

Tested with Strudel 1.3. Course text: CC BY-SA 4.0, code: CC0 1.0 (licences).