# Strudel cheat sheet

> Strudel on one page: mini-notation symbols, functions for notes, timing, variation and effects, signals, and the names of the drums and instruments.

The parts of Strudel code you reach for most, on one page. Rows that start with a dot are functions you add to a pattern, and they chain: `s("bd*4").gain(.8).room(.3)`. New to the code? Start with the [tutorial](https://shawarma.studio/learn/tutorial).

## Mini-notation

The text inside the quotes. Everything in one pair of quotes plays in one cycle.

| You write | What it does |
| --- | --- |
| `s("bd sd hh sd")` | Steps separated by spaces share the cycle equally. |
| `s("bd ~ sd -")` | A rest. ~ and - both mean silence for that step. |
| `s("bd [sd sd] hh")` | Square brackets fit several steps into one. |
| `s("bd <sd cp>")` | Angle brackets play one item per cycle, in turn. |
| `s("bd*4, hh*8")` | A comma plays patterns at the same time. |
| `s("hh*8")` | Repeat a step, faster: eight hats in the space of one. |
| `s("[bd sd hh cp]/2")` | Slow a group down: it takes two cycles, bd sd and then hh cp. |
| `s("bd!3 sd")` | Repeat a step without squeezing it: same as bd bd bd sd. |
| `s("bd@3 sd")` | Make a step longer: bd takes three quarters of the cycle. |
| `s("hh*16?")` | Drop each step at random, half the time. |
| `s("bd(3,8)")` | Euclidean rhythm: 3 hits spread over 8 steps. |
| `s("bd(3,8,2)")` | The same, rotated by 2 steps. |
| `s("hh:2")` | Pick another recording of a sound, counting from 0. |
| `n("0 .. 7").scale("C4:major").s("piano")` | A range of numbers: 0 1 2 3 4 5 6 7. |
| `s("{bd sd hh}%4")` | Polymeter: loop 3 steps over a grid of 4 per cycle. |
| `s("bd [sd\|cp\|rim]")` | Pick one of the options at random each cycle. |

## Sounds and notes

| You write | What it does |
| --- | --- |
| `s("bd sd")` | Play sounds by name. `sound()` is the same function. |
| `note("c3 e3 g3")` | Play notes by name and octave (c3 is the C below middle C). |
| `note("48 52 55")` | Notes as MIDI numbers: 60 is middle C. |
| `note("[c3,e3,g3]")` | A chord: notes separated by commas inside brackets. |
| `n("0 2 4").scale("D4:dorian")` | Steps of a scale, counted from 0. |
| `.s("piano")` | Choose the instrument that plays the notes. |
| `.s("sawtooth")` | Built-in synths: sawtooth, square, triangle, sine, supersaw. |
| `.n("<0 1 2>")` | Pick a recording of a sample by number. |

## Combining patterns

| You write | What it does |
| --- | --- |
| `stack(a, b)` | Play patterns at the same time. |
| `cat(a, b)` | One pattern per cycle, in turn. |
| `seq(a, b)` | Fit the patterns into one cycle, one after another. |
| `arrange([4, a], [8, b])` | A song form: a for 4 cycles, then b for 8. |
| `.struct("x ~ x x")` | Play the pattern on the x steps only. |
| `.euclid(3, 8)` | Play on a Euclidean rhythm. |
| `.mask("1 0 1 1")` | Silence the steps under a 0. |

## Time

| You write | What it does |
| --- | --- |
| `setcpm(30)` | Tempo in cycles per minute. With 4 beats to a cycle, cycles = BPM / 4. |
| `setcps(0.5)` | Tempo in cycles per second. 0.5 is the default (120 BPM in 4/4). |
| `.fast(2)` | Play twice as fast. |
| `.slow(2)` | Play half as fast. |
| `.rev()` | Play each cycle backwards. |
| `.ply(2)` | Play every step twice. |
| `.swing(4)` | Swing: delay every second event in each quarter. |
| `.off(1/8, x => x.add(note(12)))` | Add a copy, shifted later and changed. |
| `.iter(4)` | Each cycle, start one quarter further into the pattern. |
| `.palindrome()` | Play forwards, then backwards, every other cycle. |

## Variation

| You write | What it does |
| --- | --- |
| `.lastOf(4, x => x.fast(2))` | Change the last of every 4 cycles. |
| `.firstOf(4, x => x.rev())` | Change the first of every 4 cycles. `every()` is the same. |
| `.sometimes(x => x.speed(2))` | Change about half the events, at random. |
| `.often(...) / .rarely(...)` | The same, for about 75% or 25% of events. |
| `.degradeBy(.3)` | Drop about 30% of events at random. |
| `.jux(rev)` | Play the pattern on the left, a changed copy on the right. |

## Sound shaping

| You write | What it does |
| --- | --- |
| `.gain(.8)` | Volume. 1 is full; keep layers below it. |
| `.lpf(800)` | Low-pass filter: cut highs above 800 Hz. `.lpq()` adds resonance. |
| `.hpf(300)` | High-pass filter: cut lows below 300 Hz. |
| `.room(.5)` | Reverb amount. `.size()` sets the room size. |
| `.delay(.3)` | Echo amount. `.delaytime()` and `.delayfeedback()` shape it. |
| `.pan("0 1")` | Stereo position, 0 left to 1 right. |
| `.speed(2)` | Sample playback speed: 2 is an octave up, -1 plays backwards. |
| `.crush(4)` | Bit crusher: lower is grittier. |
| `.shape(.5)` | Distortion, 0 to 1. |
| `.vowel("a")` | A vowel filter: a e i o u. |
| `.attack(.1).release(.5)` | Envelope: fade in and out. Also `.decay()` and `.sustain()`. |

## Movement

Signals change smoothly over a cycle. Use them anywhere a number goes.

| You write | What it does |
| --- | --- |
| `sine` | A smooth wave from 0 to 1 and back. Also cosine. |
| `saw` | Rises from 0 to 1, then jumps back. |
| `tri / square` | Triangle and square waves. |
| `rand / perlin` | Random values, jumpy or smooth. |
| `.range(300, 2000)` | Scale a signal to a range. |
| `.slow(8)` | Make the movement take 8 cycles. |
| `.segment(16)` | Turn a signal into 16 steps per cycle. |

## Sound names

Use these with `s()`. Many drums and instruments have several recordings, and a number picks one: `hh:2`.

**Drums**

`bd` `sd` `hh` `oh` `cp` `rim` `lt` `mt` `ht` `cr` `rd` `cb` `sh`

**Synths**

`sawtooth` `square` `triangle` `sine` `supersaw` `white` `pink` `brown`

**Recorded instruments**

`piano` `darbuka` `kalimba` `marimba` `vibraphone` `glockenspiel` `harp` `conga` `bongo` `tambourine` `framedrum` `cajon`

**General MIDI**

`gm_epiano1` `gm_acoustic_guitar_nylon` `gm_electric_bass_finger` `gm_synth_bass_1` `gm_string_ensemble_1` `gm_choir_aahs` `gm_trumpet` `gm_flute` `gm_pad_warm` `gm_lead_2_sawtooth` `gm_sitar` `gm_koto`

For worked examples of these, see [drum patterns](https://shawarma.studio/learn/drum-patterns) and the [example songs](https://shawarma.studio/learn/examples).

## Try it in Shawarma

Shawarma is a music editor where every song is code. Your song plays on a loop; ask the assistant for a change in plain words, listen to it, and keep it only if you like it. Or edit the code yourself, as in this guide. The editor is free, with 5 assistant replies to try it; Pro starts with 7 days free.

[Start free with Google](https://shawarma.studio/auth/google) [See pricing](https://shawarma.studio/pricing)

---

The page: https://shawarma.studio/learn/cheat-sheet
