Here are three notes, C, E and G, spread evenly across one bar. Listen to how they sit against the beat you tap with your foot.
Tap four beats along. Which of the three notes lands on a beat?
Three notes in one bar
Loading the phrase…
That bar is one line of code:
export const phrase = note("c4 e4 g4")
Now add one word, so it reads note("c4 e4 g4 b4"). Before you try it: do C, E and G stay where they are, with B tacked on the end?
They don't. All four notes squeeze into the same bar, so every one moves. E jumps from beat 1⅓ to beat 1, G from 2⅔ to 2. The bar went from floating to marching, and you only typed one word.
Same bar, three or four notes
That's the core idea of pattern languages like this one: a pattern doesn't append notes to a timeline, it divides a fixed cycle among them. Add a word and time gets shared out again.
Where this way of thinking comes from
This style of writing music comes from live coding, where musicians write and change code on stage while the audience listens (and often watches the code on a projector). Its best-known tool is TidalCycles, created by Alex McLean, which grew up alongside the "algorave" scene. Maru's Code Sequencer uses the same way of writing patterns, on Maru's own engine.
The word that matters is cycle. Here a cycle lasts four beats, so you can think of it as a bar. Everything in a pattern string gets fitted into that bar.
Try it yourself
Type the examples from this page into the Code Sequencer below and press Preview to hear them. Shared code never starts on its own; nothing plays until you press Preview, and Stop is always next to it.
Change one word at a time. Can you predict where every note will land before you press Preview?
Write a pattern
Code Sequencer
Write music in Symbolic Cycle and hear it as MIDI.
While it plays, keep editing. A valid change takes over at the start of the next cycle, so the music never stops or loses its place. If you make a typo, the last working pattern keeps playing until you fix it, so don't assume what you hear is what's on screen.
A rest holds a place
A tilde is a rest:
export const phrase = note("c4 ~ g4 ~")
Four positions, two of them silent. C lands on beat 1 and G on beat 3. If you'd deleted the words instead of resting them, C and G would spread out to fill the bar.
Silence is an instruction here, not a gap. That's how you thin a pattern without disturbing its pulse: the empty positions still count, leaving room for a snare, a breath, or another part's answer.
Brackets put two notes in one place
Square brackets divide one position further:
export const phrase = note("c4 [e4 g4] b4 ~")
Still four positions per bar, but the second one now holds two notes, each half as long. E lands on beat 2 and G on the "and" of beat 2, then B on beat 3.
Draw four boxes, then split only the second box in half. That's all the notation means. It's also why code is good for rhythm: it says how notes are grouped, not just where they ended up.
Repeat or subdivide?
Two symbols that look alike ask for different timing:
"c4*4 e4"plays four Cs squeezed into the first half of the bar, then E fills the second half. It's a drum-roll inside one slot."c4!4 e4"is the same as writing"c4 c4 c4 c4 e4": five equal positions, every note 0.8 beats long.
When notation is unfamiliar, sketch a timeline before you press Preview. Predicting a rule's result is a stronger skill than pressing play until it sounds right.
Rhythms the world already knew
One of the most beautiful tricks in pattern languages is the Euclidean rhythm: spread a number of hits as evenly as possible over a number of steps. "kick(3,8)" puts three hits across eight steps.
Three hits over eight steps
That shape, x..x..x., is the tresillo, the rhythm underneath Cuban son, reggaeton and countless pop bass lines. The computer scientist and music theorist Godfried Toussaint showed in 2005 that this simple "spread them evenly" rule produces many traditional rhythms from around the world. A one-line algorithm turns out to describe patterns that musicians in many cultures arrived at by ear.
Randomness is optional
People often assume algorithmic music means random music. Everything on this page so far is completely predictable: the same rule gives the same notes every time. That's useful when you want a hook people can remember, or when only one thing should change between two versions.
Randomness can add life when it has a job. "Choose a slightly quieter last hit" keeps a pattern recognisable; "change every pitch and length" usually doesn't. When a generator lets you set a seed, keep the seed: it lets you get back to a result you liked. A trained note model is a different kind of generator: instead of following your rule, it ranks what tends to come next in the music it learned from, and its temperature setting decides how far down that ranking it may reach. Generating notes shows how to steer one and edit what it gives you.
For code examples that combine fixed patterns with seeded phrases, see the Symbolic Cycle reference (work in progress).
Before you reach for chance, see how far one rest, one bracket or one changed ending takes you. Small rule changes are easier for you to steer and easier for a listener to follow.
Make it yours
Write three versions of a four-beat motif of your own:
- Statement: four plain notes, one per beat.
- Answer: the same notes with two of them turned into rests.
- Return: the statement with one position split in brackets for extra motion.
Before pressing Preview on each, write down where you think every note will land. Then play them in order: statement, answer, return. That's a tiny piece of music with a shape, and you made it from one idea and two rule changes.
Use Export MIDI in the sequencer's menu to keep the result as notes you can drag into a piano roll. Keep the code too. The code remembers the rule; the MIDI remembers one result of it.
Quick check
- You have
note("c4 e4 g4 b4")locked to a drum beat and want to remove the B without the other notes shifting. What do you write?note("c4 e4 g4 ~"). A rest keeps four positions. Deleting B would spread three notes across the bar and pull them off the beat. - A friend writes
"hh*8"and another writes"hh!8". Will they sound different? Not on their own: both give eight even hats in the bar. The difference shows up once more words are added, because*8stays inside its one position and!8adds eight positions. - Is a pattern "algorithmic" if it has no randomness in it? Yes. A rule like "divide the bar among these notes" or "spread three hits over eight steps" is an algorithm, and a predictable one is often the most musical.
Next steps
- Go deeper: Audio to MIDI. Rules and steps start from nothing. What if the starting point is a tune you already have in your head?
- Sideways: Form and arrangement. Song form can be written the same way, with sections as lists of cycles, and the same questions of contrast and return apply.
- Use it: Sequencers and arpeggiators. Compare written rules with patterns that come from the notes you hold.












