---
title: Mini Notation
layout: ../../layouts/MainLayout.astro
---

import { MiniRepl } from '../../docs/MiniRepl';
import { JsDoc } from '../../docs/JsDoc';

# Mini-notation

Just like [Tidal Cycles](https://tidalcycles.org/), Strudel uses a so called "Mini-Notation", which is a custom language that is designed for writing rhythmic patterns using little amounts of text.

## Note

This page just explains the entirety of the Mini-Notation syntax.
If you are just getting started with Strudel, you can learn the basics of the Mini-Notation in a more practical manner in the [workshop](http://localhost:3000/workshop/first-sounds).
After that, you can come back here if you want to understand every little detail.

## Example

Before diving deeper into the details, here is a flavour of how the Mini-Notation looks like:

<MiniRepl
  client:idle
  tune={`note(\`[
  [
    [e5 [b4 c5] d5 [c5 b4]]
    [a4 [a4 c5] e5 [d5 c5]]
    [b4 [~ c5] d5 e5]
    [c5 a4 a4 ~]
    [[~ d5] [~ f5] a5 [g5 f5]]
    [e5 [~ c5] e5 [d5 c5]]
    [b4 [b4 c5] d5 e5]
    [c5 a4 a4 ~]
  ],[
    [[e2 e3]*4]
    [[a2 a3]*4]
    [[g#2 g#3]*2 [e2 e3]*2]
    [a2 a3 a2 a3 a2 a3 b1 c2]
    [[d2 d3]*4]
    [[c2 c3]*4]
    [[b1 b2]*2 [e2 e3]*2]
    [[a1 a2]*4]
  ]
]/16\`)`}
/>

## Mini Notation Format

The snippet above is enclosed in backticks (`), which allows you to write multi-line strings.

You can also use regular double quotes (`"`) for single line mini-notation, as we have done already.

If you do just want to get a regular string that is _not_ parsed as mini-notation, use single quotes (`'`).

## Sequences of events in a cycle

We can play more notes by separating them with spaces:

<MiniRepl client:idle tune={`note("c e g b")`} punchcard />

Here, those four notes are squashed into one cycle, so each note is a quarter second long.
Try adding or removing notes and notice how the tempo changes!

<MiniRepl client:idle tune={`note("c d e f g a b")`} punchcard />

Note that the overall duration of time does not change, and instead each note length decreases.
This is a key idea, as it illustrates the 'Cycle' in TidalCycles!

Each space-separated note in this sequence is an _event_.
The time duration of each event is based on the speed or tempo of the cycle, and how many events are present.
Taking the two examples above, we have four and eight events respectively, and since they have the same cycle duration, they each have to fit their events inside the same amount of time.

This is perhaps counter-intuitive if you are used to adding notes in a sequencer or piano roll and the overall length increasing.
But, it will begin to make sense as we go through more elements of mini-notation.

## Division

We can slow the sequence down by enclosing it in brackets and dividing it by a number (`/2`):

<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]/2")`} punchcard />

The division by two means that the sequence will be played over the course of two cycles.
You can also use decimal numbers for any tempo you like (`/2.75`).

<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]/2.75")`} punchcard />

## Angle Brackets

Using angle brackets `<>`, we can define the sequence length based on the number of events:

<MiniRepl client:idle tune={`note("<e5 b4 d5 c5>")`} punchcard />

The above snippet is the same as:

<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]/4")`} punchcard />

The advantage of the angle brackets, is that we can add more events without needing to change the number at the end.

<MiniRepl client:idle tune={`note("<e5 b4 d5 c5 e5>")`} punchcard />

<MiniRepl client:idle tune={`note("<e5 b4 d5 c5 e5 b4>")`} punchcard />

This is more similar to traditional music sequencers and piano rolls, where adding a note increases the perceived overall duration.

## Multiplication

Contrary to division, a sequence can be sped up by multiplying it by a number using the asterisk symbol (`*`):

<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]*2")`} punchcard />

The multiplication by two here means that the sequence will play twice per cycle.

As with divisions, multiplications can be decimal (`*2.75`):

<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]*2.75")`} punchcard />

## Subdividing time with bracket nesting

To create more interesting rhythms, you can _nest_ or _enclose_ sequences (put sequences inside sequences) with brackets `[]`, like this:

Compare the difference between the following:

<MiniRepl client:idle tune={`note("e5 b4 c5 d5 c5 b4")`} />
<MiniRepl client:idle tune={`note("e5 [b4 c5] d5 c5 b4")`} />
<MiniRepl client:idle tune={`note("e5 [b4 c5] d5 [c5 b4]")`} />
<MiniRepl client:idle tune={`note("e5 [b4 c5] d5 [c5 b4 d5 e5]")`} />
<MiniRepl client:idle tune={`note("e5 [b4 c5] d5 [c5 b4 [d5 e5]]")`} />

What's going on here? When we nest/enclose multiple events inside brackets (`[]`), their duration becomes the length of one event in the outer sequence.

This is a very simple change to make, but it has profound consequences.
Remember what we said earlier about how the cycles in tidal stay the same length, and the individual event lengths are divided up in this cycle?
Well, what this means is that in TidalCycles, not only can you divide time any way you want, and you can also subdivide time any way you want!

## Rests

The "~" represents a rest, and will create silence between other events:

<MiniRepl client:idle tune={`note("[b4 [~ c5] d5 e5]")`} punchcard />

## Parallel / polyphony

Using commas, we can play chords.
The following are the same:

<MiniRepl client:idle tune={`note("[g3,b3,e4]")`} />
<MiniRepl client:idle tune={`note("g3,b3,e4")`} punchcard canvasHeight={80} />

But to play multiple chords in a sequence, we have to wrap them in brackets:

<MiniRepl client:idle tune={`note("<[g3,b3,e4] [a3,c3,e4] [b3,d3,f#4] [b3,e4,g4]>")`} punchcard />

## Elongation

With the "@" symbol, we can specify temporal "weight" of a sequence child:

<MiniRepl client:idle tune={`note("<[g3,b3,e4]@2 [a3,c3,e4] [b3,d3,f#4]>")`} punchcard />

Here, the first chord has a weight of 2, making it twice the length of the other chords. The default weight is 1.

## Replication

Using "!" we can repeat without speeding up:

<MiniRepl client:idle tune={`note("<[g3,b3,e4]!2 [a3,c3,e4] [b3,d3,f#4]>")`} punchcard />

## Mini-notation review

To recap what we've learned so far, compare the following patterns:

<MiniRepl client:idle tune={`note("<g3 b3 e4 [a3,c3,e4] [b3,d3,f#4]>")`} />
<MiniRepl client:idle tune={`note("<[g3,b3,e4] [a3,c3,e4] [b3,d3,f#4]>")`} />
<MiniRepl client:idle tune={`note("<[g3,b3,e4]/2 [a3,c3,e4] [b3,d3,f#4]>")`} />
<MiniRepl client:idle tune={`note("<[g3,b3,e4]*2 [a3,c3,e4] [b3,d3,f#4]>")`} />
<MiniRepl client:idle tune={`note("<[g3,b3,e4] _ [a3,c3,e4] [b3,d3,f#4]>")`} />
<MiniRepl client:idle tune={`note("<[g3,b3,e4]@2 [a3,c3,e4] [b3,d3,f#4]>")`} />
<MiniRepl client:idle tune={`note("<[g3,b3,e4]!2 [a3,c3,e4] [b3,d3,f#4]>")`} />

## Euclidian rhythms

Using round brackets after an event, we can create rhythmical sub-divisions based on three parameters: `beats`, `segments` and `offset`.
This algorithm can be found in many different types of music software, and is often referred to as a [Euclidean rhythm](https://en.wikipedia.org/wiki/Euclidean_rhythm) sequencer, after computer scientist Godfriend Toussaint.
Why is it interesting? Well, consider the following simple example:

<MiniRepl client:idle tune={`s("bd(3,8,0)")`} punchcard canvasHeight={50} />

Sound familiar?
This is a popular Euclidian rhythm going by various names, such as "Pop Clave".
These rhythms can be found in all musical cultures, and the Euclidian rhythm algorithm allows us to express them extremely easily.
Writing this rhythm out in full require describing:

<MiniRepl client:idle tune={`s("bd ~ ~ bd ~ ~ bd ~")`} punchcard canvasHeight={50} />

But using the Euclidian rhythm notation, we only need to express "3 beats over 8 segments, starting on position 1".

This makes it easy to write patterns with interesting rhythmic structures and variations that still sound familiar:

<MiniRepl client:idle tune={`note("e5(2,8) b4(3,8) d5(2,8) c5(3,8)").slow(4)`} punchcard canvasHeight={50} />

Note that since the example above does not use the third `offset` parameter, it can be written simply as `"(3,8)"`.

<MiniRepl client:idle tune={`s("bd(3,8)")`} punchcard canvasHeight={50} />

Let's look at those three parameters in detail.

### Beats

`beats`: the first parameter controls how may beats will be played.
Compare these:

<MiniRepl client:idle tune={`s("bd(2,8)")`} punchcard canvasHeight={50} />
<MiniRepl client:idle tune={`s("bd(5,8)")`} punchcard canvasHeight={50} />
<MiniRepl client:idle tune={`s("bd(7,8)")`} punchcard canvasHeight={50} />

### Segments

`segments`: the second parameter controls the total amount of segments the beats will be distributed over:

<MiniRepl client:idle tune={`s("bd(3,4)")`} punchcard canvasHeight={50} />
<MiniRepl client:idle tune={`s("bd(3,8)")`} punchcard canvasHeight={50} />
<MiniRepl client:idle tune={`s("bd(3,13)")`} punchcard canvasHeight={50} />

### Offsets

`offset`: the third (optional) parameter controls the starting position for distributing the beats.
We need a secondary rhythm to hear the difference:

<MiniRepl client:idle tune={`s("bd(3,8,0), hh cp")`} punchcard />
<MiniRepl client:idle tune={`s("bd(3,8,3), hh cp")`} punchcard />
<MiniRepl client:idle tune={`s("bd(3,8,5), hh cp")`} punchcard />

## Mini-notation exercise

The most fun thing about the mini-notation, is that everything you have just learned can be combined in various ways!

Starting with this one `n`, can you make a _pattern string_ that uses every single mini-notation element above?

<MiniRepl client:idle tune={`n("60")`} />

<br />

Next: How do [Samples](/learn/samples) play into this?
