Strudel cheat sheet
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.
Mini-notation
The text inside the quotes. Everything in one pair of quotes plays in one cycle.
| You write | What it does | Listen |
|---|---|---|
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") | 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 | Listen |
|---|---|---|
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") | 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 | Listen |
|---|---|---|
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 | Listen |
|---|---|---|
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 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 | Listen |
|---|---|---|
.lastOf(4, x => x | Change the last of every 4 cycles. | |
.firstOf(4, x => x | Change the first of every 4 cycles. every() is the same. | |
.sometimes(x => x | Change about half the events, at random. | |
.often(...) / | 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 | Listen |
|---|---|---|
.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) | 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 | Listen |
|---|---|---|
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
bdsdhhohcprimltmthtcrrdcbsh- Synths
sawtoothsquaretrianglesinesupersawwhitepinkbrown- Recorded instruments
pianodarbukakalimbamarimbavibraphoneglockenspielharpcongabongotambourineframedrumcajon- General MIDI
gm_epiano1gm_acoustic_guitar_nylongm_electric_bass_fingergm_synth_bass_1gm_string_ensemble_1gm_choir_aahsgm_trumpetgm_flutegm_pad_warmgm_lead_2_sawtoothgm_sitargm_koto
For worked examples of these, see drum patterns and the example songs.
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.