sound("bd hh sd hh")

Music as Code

What if you could type a line of text and hear a beat? That is how live coders make music.

1

A Beat Is a Loop

Music starts with rhythm, and rhythm is just a short pattern that repeats. This grid is a mini drum machine holding a real beat. Press play, then click squares on and off to change it.

bd = kick · hh = hi-hat · sd = snare
A real beat, made of three different drums. Press play.
The idea

This grid is a drum machine: eight steps, looping. Every beat you have ever danced to is some pattern like this, repeating under the music.

2

Write the Beat as Text

Live coders skip the clicking. They describe the pattern in words: bd is a kick, hh a hi-hat, sd a snare, and ~ is a rest. Edit the code and watch the grid follow.

try: bd hh sd hh  |  bd ~ sd ~  |  bd bd hh sd
The text is the music. Change a word, change the beat.
Real syntax

This is close to how Strudel and its ancestor TidalCycles actually work. A line like sound("bd hh sd hh") really does play that beat. You just wrote code.

3

Code Can Twist the Pattern

Here is where code beats clicking. Because the pattern is text, you can transform it with a single word: fast doubles it, rev plays it backward, double repeats each hit. Stack transforms and hear it change.

sound("bd hh sd cp")
Tap a transform, then play. Notice how the grid rewrites itself.
Why it matters

Doing "reverse this rhythm and play it twice as fast" by hand is fiddly. As code, it is two words. That power is why musicians perform live by typing.

4

Stack Patterns Into a Song

One pattern is a beat. Stack several, drums plus a bassline plus a melody, all looping together, and you have a song. Toggle each layer on and hear the track build.

drums
bass
melody
Add layers one at a time. Each is a line of code, all in sync.
Fun fact

Performances where artists project their code and build music live are called algoraves. The rule of the scene: show your screen. The code is part of the show.

Live Coder!

You turned text into rhythm, melody, and a stacked song. This is live coding: music written as patterns you can change while it plays. No piano needed, just a few lines of code. Now open the real thing and jam.

0
Patterns Played
0
Code Edits
0
Time Exploring

Rhythm Is a Loop

A beat is a short pattern of hits and rests that repeats. Draw a row of steps and you have described a rhythm.

Text Can Be a Pattern

Live coders write patterns as words: "bd hh sd hh" means kick, hat, snare, hat. The text IS the music.

Code Transforms Patterns

Because it is code, you can speed it up, reverse it, or repeat it with a single word. That is hard to do by hand.

Stack Patterns for a Song

Layer a drum line, a bassline, and a melody, each one a pattern, all looping together. Stacked patterns become a song.

Ready to Create?

Put your new knowledge into practice!

Suggest a Correction