live coding with strudel

making music by typing code

been messing around with strudel.cc lately. it’s a browser-based live coding environment where you make music by writing javascript-like patterns. no downloads, no setup, no daw. just open a tab and start typing.

what is live coding

you write code, and the music plays while you type. change a line, the sound changes instantly. there’s a whole community around this called algorave, people literally perform at clubs by coding on stage.

strudel is based on tidalcycles but without the complex haskell setup. just open a browser tab. that’s it.

voodoo child in strudel

the basics

s("bd sd bd sd")

four sounds in a cycle. strudel figures out the timing. the spaces between words are not pauses, they’re equal divisions of time. you don’t think in bpm or time signatures, you think in patterns.

brackets subdivide time, so [bd bd] plays two kicks in the space of one. add effects on top:

s("bd sd [bd bd] sd")
    .room(0.5) // reverb

before you know it, you have something that actually sounds like a track.

acid

here’s something i made a few days ago. tr909 drums, phrygian bassline, acid lead… the slider functions let you tweak stuff in real time while the pattern plays. so you can actually perform with it.

setcps(140/60/4)

drum: stack(
  s("bd*4")
    .gain(1.2)
    .distort(slider(0.3, 0, 1))
    .lpf(400)
    .room(0.1),
  
  s("~ oh!3")
    .gain("0.4 0.6 0.4 0.8")
    .hpf(2000)
    .velocity(slider(0.8, 0, 1)),
  
  s("hh*16")
    .gain("0.2 0.3 0.2 0.4")
    .hpf(5000)
    .velocity(slider(0.5, 0, 1)),

  s("~ sd:2 ~ sd:2")
    .gain(0.7)
    .room(0.3)
    .roomsize(10)
    .distort(0.2)
).bank("tr909").scope()

bass: n("<0 0 12 7 0 0 10 3>*16".add("<0 7 5 3>*2"))
  .s("sawtooth")
  .scale("c2:phrygian")
  .legato(slider(0.9, 0.1, 1.2))
  .lpf(sine.slow(4).range(300, 4500)) 
  .lpq(slider(20, 5, 30))
  .lpenv(2)
  .distort(0.7)
  .gain(0.8)
  .velocity(slider(0.9, 0, 1))
  ._pianoroll({width:390})

lead: n("<0 3 5 7 10 12 10 7>*16")
  .s("square")
  .scale("c4:phrygian")
  .legato(0.5)
  .lpf(tri.slow(8).range(800, 6000))
  .lpq(15)
  .distort(slider(0.5, 0, 0.9))
  .room(0.6)
  .roomsize(20)
  .gain(saw.range(0, 0.5).slow(16))
  .velocity(slider(0.7, 0, 1))
  ._pianoroll({width:390})

noise: s("noise*16")
  .gain(sine.slow(16).range(0, 0.2))
  .hpf(saw.slow(16).range(1000, 8000))
  .room(1)

why i like it

i write code all day. api calls, database queries, ui stuff. strudel is different because the output is something you can actually hear. you tweak a number, the pattern shifts. add a function, everything transforms. i really like how raw it is. no presets, no drag and drop. everything is based on your code.

getting started

just go to strudel.cc and press play. the tutorial is solid.

  • start with s("bd sd hh oh") and play with it
  • ctrl+enter to evaluate
  • try .lpf(), .room(), .delay() for effects
  • check the pattern visualizer to see what’s happening

still figuring this out. will keep you updated.