Lesson 29 +10 XP

Playing Multiple Patterns

You can run several separate patterns at once with stack.

Two patterns side by side

Use stack to play two patterns at the same time:


strudel
stack(
  note("<c e g b>").sound("gm_xylophone"),
  sound("bd*2, [~ hh]*4").bank("RolandTR909")
)

Why use stack?

The comma inside sound(...) combines into one pattern. stack keeps them as separate patterns, which is easier to read and control - especially for longer pieces.

Add more patterns


strudel
stack(
  note("<c e g b>").sound("gm_xylophone"),
  note("<c2 g2 e2 b2>").sound("gm_acoustic_bass"),
  sound("bd*2, [~ hh]*4").bank("RolandTR909")
)

Formatting tip

Each pattern gets its own line, ending with a comma - like a list. This is the style used in the [Strudel REPL](https://strudel.cc/) examples.

TL;DR

  • stack(pattern1, pattern2, ...) plays patterns together.
  • Great for keeping separate voices readable.
  • Common format: one line per pattern, comma-separated.