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

Step 01 of 11

Start here

One track, built one layer at a time: a deep-house loop called Night Bus. Hear the finished track in 1.3, then write it yourself in Strudel, one layer per lesson, in parts 2 to 5.

1.1What Strudel is

Strudel is a music program that runs in a web page. You write short lines of code, press Ctrl+Enter, and hear them straight away. The music is made of patterns that repeat every cycle (here, one bar). A pattern lives inside quotes: s("bd*4") means "play the sound bd (a kick drum) four times per cycle".

  • Nothing to install. It runs in the browser, and every example in this course plays with one click.
  • Sounds are built in: drum machines (TR-909, TR-808…), 128 General MIDI instruments, synths and sample sets (see the Sound bank).
  • You see what plays. Each part of the code lights up while it sounds.
  • You change the music while it plays. Edit a number, press Ctrl+Enter, and the change lands on the next cycle without stopping.
  • Short, readable errors. When something is wrong, the Error messages part says what it means.

Strudel is the JavaScript version of TidalCycles, an older live-coding language. This course uses Strudel only. Most patterns you write here look almost the same in Tidal, if you ever want to try it.

1.2Start the software

  1. Nothing to install. Every Strudel example on this site has a Run button. Press it to hear the code, and press Stop to stop.
  2. Click into a code block and press Ctrl+Enter to play it, or Ctrl+. to stop. On a Mac, use Cmd.
  3. Open in Strudel ↗ opens the same code in the full editor at strudel.cc. Use it to change the code, to see the visuals, and to export a WAV file.

No sound?

  1. Check the volume, the output device, and that the browser tab isn't muted.
  2. The first Run downloads Strudel and its sounds, so it can take a few seconds. A drum machine or instrument you use for the first time loads when it first plays.
  3. If a code block shows a message under it, read what the error messages mean.

1.3The track: Night Bus

Key A minor Tempo 124 BPM Form 16 cycles (bars) Chords Am7 · Fmaj7 · Cmaj7 · G7 Time about 1 hour

This is the track you build in parts 2 to 5. Play it to hear where you're going. A cycle is one bar of 4/4 here. The full form is 16 cycles, about 31 seconds, and then it loops. Layers enter every four bars, so the track builds up the way a DJ intro does.

Arrangement, one column per cycle (bar). You build it in 5.1 Arrangement with .mask().
Strudel · Night Bus (the finished track)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>")

Where you build each layer

Each lesson adds one layer to the same code, so by the end of part 5 you have written every line above yourself.

CommandWhat it doesLesson
setcpm(124/4)
$: s("bd*4")
Sets the tempo to 124 BPM (124 beats ÷ 4 beats per bar = 31 cycles per minute) and plays a kick drum on every beat.2.1 The pulse
.bank("RolandTR909")
s("~ cp ~ cp"), s("[~ oh]*4")
Uses the sounds of the TR-909 drum machine, adds a clap on beats 2 and 4, and an open hi-hat between the beats.2.3 The drum kit
s("hh*16")
.gain("[.25 .5]*8")
.sometimesBy(.2, x => x.ply(2))
Sixteen closed hi-hats per bar, alternating quiet (.25) and louder (.5). About 1 in 5 of them (.2) plays twice in its own time.2.5 Hi-hats that breathe
note("<a1 f1 c2 g1>")
.struct("x ~ x x ~ x x ~")
The bassline: one root note per bar (A, F, C, G), played in a syncopated rhythm (x = play, ~ = rest).3.2 Bassline
chord("<Am7 F^7 C^7 G7>")
.voicing()
One chord per bar on an electric piano. F^7 is Strudel's name for Fmaj7. .voicing() picks the notes of each chord.3.3 Chords
n("0 [~ 2] 4 [3 2]")
.scale("A4:minor")
The melody, written as steps of the A minor scale (0 = A, 2 = C, 4 = E). .add("<0 -2 2 -1>") shifts it each bar to follow the chords.3.5 Melody
.lpf(sine.range(300, 1800).slow(8))
.jux(rev)
The bass filter opens and closes slowly (between 300 and 1800 Hz, over 8 bars), and the melody plays backwards in the right speaker.4.1 Movement
.mask("<0!4 1!12>")Switches a layer off for 4 bars, then on for 12. Each layer has its own mask, which makes the arrangement above.5.1 Arrangement

After that, 5.2 A song from blocks turns the loop into a 48-bar song, and 7.1 Save and export shows how to keep it as a WAV file.

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