Every way to build a Sequencer and send it to an instrument. Four notations for the same idea, and one message — to: — that puts any of them on stage.

1. The shape of every pattern

In Coypu a sound is produced by attaching a Sequencer to an instrument name — an ordinary Pharo symbol such as #kick or #snare. The Sequencer says when to trigger; the engine behind your Performer decides how that sounds.

Every creation method in this guide follows the same two-part shape:

"build a pattern  →  send it to an instrument"
<pattern expression> to: #instrumentName.
The house style Coypu aims for one readable line per part. As the author puts it: if Pharo's syntax fits on a postcard, Coypu's fits on a business card.

A Sequencer sent to a key that is already occupied replaces what was there, which is what makes live editing work — re-evaluate a line and the part changes at the next step.

2. Binary arrays

The most literal notation: an array of 1s and 0s. Send it asSeq to turn it into a Sequencer.

#( 1 0 0 1 0 0 0 0 ) asSeq to: #kick.
ElementMeaning
1Trigger the instrument on this step
0Rest — do not trigger
"four-on-the-floor kick"
#( 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 ) asSeq to: #kick.

"snare on beats 2 and 4 of a 16-step grid"
#( 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 ) asSeq to: #snare.

Array length is free — 8, 16, 32 all work, and a shorter array simply loops sooner. The related asRhythm converts an array into a Rhythm object rather than a Sequencer, which is what the named rhythms in §3 answer.

Why asSeq and not just the array asSeq builds a Sequencer with sensible defaults around your gates: one note per trigger at MIDI 60, a duration derived from the spacing of your triggers, and a gate time of 0.8. Those defaults are what you override with notes:, durations: and the rest — see Player & Message API.

3. Named rhythms

Coypu ships 31 named rhythms drawn from musical traditions around the world. Send asRhythm to a symbol to get a ready-made Sequencer:

#rumba       asRhythm to: #conga.
#cumbiaClave asRhythm to: #conga.
#banda       asRhythm to: #kick.
asRhythm on a symbol always gives you 16 steps #trueAksak asRhythm is 16 steps of a 13-step pattern, which truncates mid-cycle. To get a whole number of cycles, call the rhythm on an integer instead — 13 trueAksak — as in §3.1. The Rhythm Library lists every pattern's true length.

3.1 Shorthand: to: on a symbol

You can skip asRhythm and send to: straight to the symbol:

#plena to: #conga.
#banda to: #kick.

The more useful form sends the rhythm name to an integer, which sets the length explicitly and is the notation used throughout this manual:

16 claveSon  to: #conga.
13 trueAksak to: #perc.     "13 steps — a whole cycle"
32 jungleKick to: #kick.   "jungle patterns are 32 steps"

3.2 Listing what is available

Rhythm list.   "Cmd-I / Ctrl-I to inspect the result"

This returns a Dictionary of every selector carrying the <rhythmCreation> pragma, with its source comment. The Rhythm Library is generated from that same pragma, with step visualisations and notes on where each pattern comes from.

4. Hex patterns

A compact notation: each hexadecimal digit encodes four steps. Four digits give a 16-step pattern, eight digits give 32, and so on — the length follows the length of the string.

'F000' hexBeat to: #kick.
"F = 1111, 0 = 0000 → triggers on the first 4 steps of 16"

'020F' hexBeat to: #snare.
"0=0000 2=0010 0=0000 F=1111 → a syncopated pattern"

'FFFF' hexBeat to: #ch.
"all 16 steps active — sixteenth-note closed hat"
Hex digitBinaryMeaning
00000Four rests
81000Only the first step
A1010Every other step
F1111All four steps

Hex is how Coypu stores the three jungle patterns internally — jungleKick is '88000000', eight digits and therefore 32 steps. It is worth learning for exactly that reason: long patterns stay readable.

5. Grid helpers

Several rhythms are not patterns so much as grid divisions. They take the length as the receiver and fill it according to a rule:

ExpressionFillsTriggers
16 semiquaversEvery step16
16 trigsEvery step — identical to semiquavers16
16 quaversSteps 1 and 3 of each group of 48
16 downbeatsEvery 4th step4
16 upbeatsThe 3rd step of each group of 44
16 restsNothing0
16 quavers     to: #ch.
16 semiquavers to: #oh.
16 downbeats   to: #kick.
16 upbeats     to: #ch.
The receiver is the number of steps, not triggers 8 quavers is eight steps containing four triggers, and 32 quavers is thirty-two steps containing sixteen. Only semiquavers and trigs put a trigger on every step, which is why their step count and trigger count happen to match.

These are the fastest way to get a bed going, and a good base to modify: start with 16 semiquavers on a hat and thin it out with an offset or a random gate.

6. Joining and repeating

Pharo's comma concatenates collections, and Coypu extends it to Sequencers. Use it to build a longer pattern out of shorter ones:

"16 quavers followed by 16 semiquavers → a 32-step hat part"
16 quavers , 16 semiquavers to: #oh.

"a named rhythm followed by a hand-written array"
#rumba asRhythm , #( 1 0 1 0 ) asSeq to: #conga.

* repeats a Sequencer, and times: does the same thing with a keyword:

8 downbeats * 4  to: #kick.      "32 steps: the 8-step pattern four times"
(8 downbeats times: 4) to: #kick.  "the same thing"
Joining joins everything , concatenates the gates, the notes and the durations together, so a joined Sequencer keeps whatever pitches and lengths each half carried. That makes it a real arrangement tool rather than only a rhythm one.

7. Adding notes

A rhythm on its own plays one repeated note. notes: gives it pitches, as MIDI note numbers:

(16 claveSon notes: #( 36 38 42 46 38 )) to: #perc.

Many named rhythms also take the notes inline, as a string, which avoids the parentheses:

16 claveSon: '36 38 42 46 38' to: #perc.

Not every rhythm has that variant. The Rhythm Library tags the ones that do. Notes are consumed one per trigger and wrap around, so you need no more notes than the pattern has triggers — fewer is fine and will cycle.

For melodic writing, string notations carry rests and durations as well as pitches — see Melody & Scales and Rhythms: Advanced.

8. Pattern length and the loop point

Coypu has a single global transport. Every Sequencer wraps independently at its own length, which means two patterns of different lengths drift against each other and realign only at the least common multiple of the two.

That is a feature — it is how you get polymetre for free:

16 downbeats to: #kick.    "16 steps"
13 trueAksak to: #perc.    "13 steps — realigns after 208"

But it is also the commonest source of a pattern that sounds wrong: give a 13-step rhythm a length of 16 and it truncates mid-cycle every time round. When you want a rhythm to sound as intended, give it a multiple of its own length — the Rhythm Library lists every one.

9. Where to go next

DocumentWhat it covers
Rhythm LibraryAll 31 named rhythms, with step patterns and origins.
Rhythms: AdvancedEuclidean patterns, offsets, mini-notation and random walks.
Melody & ScalesGiving these patterns pitch.
PerformingRunning several parts at once and changing them live.

10. Troubleshooting

The pattern evaluates but nothing plays

The transport is not running, or no Performer is set. p play, and check Setup §4.

8 quavers gave me four hits, not eight

The receiver is the step count, not the trigger count — §5.

A named rhythm sounds cut off or lurches every cycle

Its length does not divide the length you gave it. Use a multiple of the pattern's own length — §8.

16 bomba: '36 38' raises doesNotUnderstand

A bug in the Coypu source — bomba: never assigns its pattern. Plain 16 bomba works; add notes with notes: instead. See the Rhythm Library troubleshooting.

Sending a second pattern to the same instrument replaced the first

That is intended — one Sequencer per key. Use a second instrument name, or join the two patterns with , — §6.

My hex string produced more steps than I expected

Each digit is four steps, so eight digits is 32 — §4.