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

Step 05 of 11

Song structure

The finished arrangement of Night Bus, and longer songs built from blocks.

5.1Arrangement: the finished track

.mask() switches a layer on or off per cycle. "<0!4 1!12>" means "off for 4 cycles, then on for 12", so it's one 16-cycle loop. Each layer gets its own mask, and the result is the arrangement from the top of the page. This is the complete Night Bus.

Strudel · Night Bus (final)Open in Strudel ↗
// Night Bus · A minor · 124 BPM · 16 cycles
setcpm(124/4)

// drums
$: s("bd*4").bank("RolandTR909")
$: s("~ cp ~ cp").bank("RolandTR909")
  .mask("<0!2 1!14>")
$: s("[~ oh]*4").bank("RolandTR909").gain(.4)
  .mask("<0!2 1!14>")
$: s("hh*16").bank("RolandTR909")
  .gain("[.25 .5]*8")
  .sometimesBy(.2, x => x.ply(2))
  .mask("<0!2 1!14>")

// bass
$: note("<a1 f1 c2 g1>")
  .struct("x ~ x x ~ x x ~")
  .s("sawtooth")
  .lpf(sine.range(300, 1800).slow(8))
  .decay(.15).sustain(0)
  .mask("<0!4 1!12>")

// chords
$: chord("<Am7 F^7 C^7 G7>")
  .struct("[~ x]*2")
  .voicing()
  .s("gm_epiano1")
  .room(.5).gain(.6)
  .mask("<0!8 1!8>")

// melody
$: n("0 [~ 2] 4 [3 2]".add("<0 -2 2 -1>"))
  .scale("A4:minor")
  .s("triangle")
  .jux(rev)
  .delay(.4).gain(.5)
  .mask("<0!12 1!4>")

Playing it live

  • Edit while it plays, then press Ctrl+Enter. The change lands on the next cycle without stopping the music.
  • Write _$: instead of $: to mute a layer. Remove the underscore to bring it back.
  • Delete the .mask(…) lines when you want to "drop" every layer at once.
  • Add .pianoroll() to the end of the melody to see its notes scroll by.

5.2A song from blocks

In lesson 5.1, layers switched on one after another inside a single 16-bar loop. Real songs work differently: they're made of blocks (sections) that replace each other. First an intro, then a verse, a build-up, the chorus, a quiet breakdown, the chorus again, and an outro. Each block is a fixed group of layers, played for a set number of bars.

BlockJob in the songTypical length
IntroSets the tempo and mood with only a few layers. DJs mix in over it.8–16 bars
VerseThe main groove, without the strongest hook8–16 bars
BuildTension before the chorus: rolls, risers, the kick drops out4–8 bars
Chorus / dropThe peak: every layer plus the melody8–16 bars
BreakdownA rest: drums stop, pads and melody stay4–8 bars
OutroLayers leave and the track winds down8–16 bars

Keep every block a multiple of 4 bars, the length of the chord progression, so each block starts on the first chord.

The plan for Night Bus

48 bars, about 1 minute 33 seconds at 124 BPM. The width of each block is its number of bars.
LayerIntroVerseBuildChorusBreakOutro
kick●●·●·●
clap·●·●··
hats●●·●··
ohats···●··
fill (toms, bar 8)·●····
roll (snare roll)··●···
bass·●●●··
chords·●·●··
pad●·●·●●
melody···●●·

Three steps in code

  1. Layers: define every instrument part once, with const and a name.
  2. Blocks: combine layers with stack(…). One block is a list of layers that play together.
  3. Song: put the blocks in order with arrange([bars, block], …). Each block starts from its own first bar, so a fill written for "bar 8" lands on the last bar of an 8-bar block.
Strudel · Night Bus, full songOpen in Strudel ↗
// Night Bus · full song · A minor · 124 BPM
setcpm(124/4)

// ---------- 1. layers: every instrument part, defined once ----------
const kick   = s("bd*4").bank("RolandTR909")
const clap   = s("~ cp ~ cp").bank("RolandTR909")
const hats   = s("hh*16").bank("RolandTR909").gain("[.25 .5]*8")
const ohats  = s("[~ oh]*4").bank("RolandTR909").gain(.4)
const fill   = s("<~!7 [~ ~ [ht mt] [lt lt]]>").bank("RolandTR909")  // tom fill in bar 8
const roll   = s("sd*16").bank("RolandTR909")
  .ply("<1 1 2 2>").gain(saw.range(.1, .7).slow(4))               // snare roll, louder and faster
const bass   = note("<a1 f1 c2 g1>").struct("x ~ x x ~ x x ~")
  .s("sawtooth").lpf(sine.range(300, 1800).slow(8)).decay(.15).sustain(0)
const chords = chord("<Am7 F^7 C^7 G7>").struct("[~ x]*2").voicing()
  .s("gm_epiano1").room(.5).gain(.6)
const pad    = chord("<Am7 F^7 C^7 G7>").voicing().s("gm_pad_warm").gain(.35)
const melody = n("0 [~ 2] 4 [3 2]".add("<0 -2 2 -1>")).scale("A4:minor")
  .s("triangle").jux(rev).delay(.4).gain(.5)

// ---------- 2. blocks: which layers play together ----------
const intro     = stack(kick, hats, pad)
const verse     = stack(kick, clap, hats, bass, chords, fill)
const build     = stack(roll, pad, bass)
const chorus    = stack(kick, clap, hats, ohats, bass, chords, melody)
const breakdown = stack(pad, melody)
const outro     = stack(kick, pad)

// ---------- 3. the song: [number of bars, block] ----------
$: arrange(
  [8, intro],
  [8, verse],
  [4, build],
  [8, chorus],
  [4, breakdown],
  [8, chorus],
  [8, outro]
)

The song loops after the outro. To stop at the end, press Ctrl+.. To get a file, export cycles 0–48 as a WAV (lesson 7.1).

Transitions between blocks

A plain cut from one block to the next can sound abrupt. These tricks tell the listener that something new is coming:

TrickCodeWhere it's used above
Fill in the last bars("<~!7 [~ ~ [ht mt] [lt lt]]>")fill in the verse
Roll that speeds up and gets louders("sd*16").ply("<1 1 2 2>").gain(saw.range(.1, .7).slow(4))roll in the build
Drop the kick before the chorusLeave kick out of the build blockbuild
Kick stops for the last bar of a blockkick.mask("<1!7 0>")Try it in the verse
Filter opens across a block.lpf(saw.range(300, 4000).slow(8))Try it on chords

Another way: the song as one line

Replace the arrange(…) part with a "score line". !8 means "for 8 bars", and .pick() looks up each block by name. Keep the three steps above and change only step 3:

Strudel · score line (replace step 3)
// 3. the song as a score line: name!bars
$: "<intro!8 verse!8 build!4 chorus!8 breakdown!4 chorus!8 outro!8>"
  .pick({intro, verse, build, chorus, breakdown, outro})

Unlike arrange, pick plays each block by the song's global clock. A block that starts at bar 17 plays its own bar 17, not bar 1. That's fine as long as every block starts on a multiple of its pattern lengths (4 or 8 bars here). The full song above follows this rule.

Playing the blocks live

When you perform, you choose the next block by hand instead of writing out the order. Keep steps 1 and 2, and replace step 3 with a single line. Then change the word and press Ctrl+Enter: the new block starts right away, in time.

Strudel · live switching (replace step 3)
// change the word (intro, verse, build, chorus, breakdown, outro) and press Ctrl+Enter
$: verse

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