Contents

Sequencing & Timing

Timing and sequencing functions create rhythmic patterns, triggers, and automation curves synchronized to the global clock.

For voice allocation across notes (poly, mono, legato, spread), see polyphony. For breakpoint envelopes (timeline), see timelines. For chord voicings (anchor, mode, voicing, addVoicings), see chords.

clock

Clock - Returns the current clock position.

ParamTypeDefaultDescription
---No parameters

Returns the current position in the clock cycle. Use with other timing functions or for sync.

// Use clock for tempo-synced effects
saw(110) |> delay(@, clock() / 4, 0.4) |> out(@)

Related: trigger, lfo


lfo

LFO - Low Frequency Oscillator with optional duty cycle.

ParamTypeDefaultDescription
ratesignal-Rate in Hz
dutynumber0.5Duty cycle for pulse (0-1)

A low-frequency oscillator for modulation. The duty parameter controls the pulse width.

// Vibrato
sine(220 + lfo(5) * 10) |> out(@)
// Tremolo
saw(220) * (0.5 + lfo(4) * 0.5) |> out(@)
// Filter sweep
saw(110) |> lp(@, 500 + lfo(0.2) * 1500) |> out(@)

Related: clock, trigger


trigger

Trigger - Generates trigger pulses at division of the beat.

ParamTypeDefaultDescription
divnumber-Triggers per beat

Generates short impulses at regular intervals. A div of 4 means 4 triggers per beat (16th notes at 4/4).

// Kick drum on quarter notes
sine(55) * ar(trigger(1), 0.01, 0.2) |> out(@)
// Hi-hat on 8th notes
noise() |> hp(@, 8000) * ar(trigger(2), 0.001, 0.05) |> out(@)
// Fast arpeggio triggers
n"c4 e4 g4 c5"
    |> ((f) -> saw(f) * ar(trigger(8)))
    |> out(@)

Related: euclid, lfo


euclid

Euclidean Rhythm - Generates Euclidean rhythm patterns.

ParamTypeDefaultDescription
hitsnumber-Number of hits in pattern
stepsnumber-Total steps in pattern
rotnumber0Rotation offset
dursignal4Pattern span in cycles (audio-rate)

Creates rhythms by distributing hits as evenly as possible across steps. Classic patterns: (3,8) = Cuban tresillo, (5,8) = West African bell.

The default dur=4 spans the pattern over 4 cycles (= 1 bar at 4/4 under nkido’s cycle=beat model), matching the classic Strudel/Tidal tresillo feel. Pass a smaller dur for a busier pattern (dur=1 packs all steps into a single beat), or a larger dur to stretch the pattern over multiple bars. dur is audio-rate, so you can modulate it with an LFO or pattern.

// Tresillo pattern (3 hits over 1 bar)
sine(55) * ar(euclid(3, 8), 0.01, 0.15) |> out(@)
// West African bell
noise() |> hp(@, 6000) * ar(euclid(5, 8), 0.001, 0.03) |> out(@)
// Rotated pattern
saw(110) * ar(euclid(5, 16, 2)) |> lp(@, 800) |> out(@)
// Stretched pattern: 5 hits over 2 bars (8 cycles)
sine(110) * ar(euclid(5, 16, 0, 8), 0.005, 0.4) |> out(@)

Note: .fast(N) / .slow(N) are pattern transforms and do not apply to euclid() (which is a signal generator). Use the dur parameter instead: euclid(3, 8, 0, 8) is the closest equivalent to euclid(3, 8).slow(2). For pattern-style transforms over an Euclidean rhythm, use mini-notation Euclidean syntax: n"c4(3,8)".slow(2).

Related: trigger, timelines

Pattern transforms

Compile-time event-list rewriters that wrap a pattern. All compose via dot-call (n"…".slow(2).rev()) and the equivalent functional form.

early

early(pattern, amount) shifts events earlier by amount cycles, wrapping within [0, 1).

n"c4 e4 g4 b4".early(0.25)  // each event plays 1/4 cycle earlier

late

late(pattern, amount) shifts events later by amount cycles, wrapping.

palindrome

palindrome(pattern) plays the pattern forward then reversed, doubling cycle_length.

// c4 e4 g4 b4 b4 g4 e4 c4 over 2× cycles
n"c4 e4 g4 b4".palindrome()

compress

compress(pattern, start, end) squashes the entire pattern into the sub-window [start, end) of the cycle (silence outside).

Note: this name was previously aliased to the audio compressor; the audio compressor is now reachable as comp(...) or compressor(...).

ply

ply(pattern, n) repeats each event n times within its slot.

linger

linger(pattern, frac) keeps the first frac of the pattern and loops it across the cycle (equivalent to zoom(0, frac).fast(1/frac)).

zoom

zoom(pattern, start, end) plays only the [start, end) portion of the pattern, stretched to fill the full cycle. Events that straddle the window are clipped.

segment

segment(pattern, n) samples the pattern at n evenly-spaced points and emits n equal-duration events carrying the value active at each sample.

swing / swingBy

swing(pattern, grid=8) applies a 1/3 swing on a grid-slice grid. swingBy(pattern, amount, grid=8) lets you set the swing amount explicitly.

s"bd hh sd hh".swing()           // default 1/3 on 8 slices
s"bd hh sd hh".swingBy(0.5, 8)   // half-amount on 8 slices
s"bd hh sd hh".swing(4)          // grid=4 for the pre-Phase-2b default

Phase 2b note. The default grid is now 8 (was 4 in pre-Phase-2b releases). Pass an explicit grid: 4 to restore the legacy behavior.

iter / iterBack

iter(pattern, n) rotates the pattern’s start by 1/n per cycle (forward); iterBack rotates the opposite way. Implemented as a runtime rotation on the SequenceState; no compile-time event explosion.

n"c4 e4 g4 b4".iter(4)  // advance start by 1/4 each cycle

Pattern generators

Pattern constructors that emit an event stream directly from numeric input. Compose with transforms via dot-call.

run

run(n) produces n events at times i/n carrying values 0, 1, ..., n-1 each of duration 1/n. Useful as a rising/integer index pattern.

// ascending chromatic from C4
run(8) |> mtof(@ + 60) |> saw(@)

binary

binary(n) produces a trigger pattern from the binary representation of n (MSB first; bits = floor(log2(n)) + 1). Set bits emit triggers, unset bits emit rests.

binary(178) |> sampler(@, "hh")  // 0b10110010 = 8-step rhythm

binaryN

binaryN(n, bits) is the zero-padded fixed-width form. Truncates n to the lower bits bits.

binaryN(5, 8)  // 00000101 = 8 events with bits at positions 5 and 7