tur/polyrhythm
polymeter
(polymeter [ratio p])
play a pattern with a different effective meter.
| ratio | time scaling ratio (2.0 = twice as slow, 0.5 = twice as fast) | |
| p | pattern to play with the scaled meter |
Pattern<T> evaluated with time * ratio. ((polymeter 1.5 my-pat) 1.0) ; reads my-pat at time 1.5
polyrhythm
(polyrhythm [p1 len1 p2 len2])
play two patterns with independent cycle lengths.
| p1 | first pattern | |
| len1 | cycle length for the first pattern in beats | |
| p2 | second pattern | |
| len2 | cycle length for the second pattern in beats |
Pattern<Tuple T1 T2> combining both patterns at their own tempos. ((polyrhythm kick-pat 3 snare-pat 2) 0.0)
polyrhythm-n
(polyrhythm-n [& pattern-lengths])
play any number of patterns with independent cycle lengths.
| pattern-lengths | list of [pattern length] tuples |
Pattern<vec<T>> with one element per sub-pattern.
nest
(nest [outer & [inner-time-scale 1.0])
evaluate a pattern of patterns: outer selects the inner, inner is evaluated.
| outer | Pattern producing inner patterns | |
| inner-time-scale | time scaling applied before evaluating outer (default: 1.0) |
Pattern<T> that delegates to the pattern returned by outer.
nest2
(nest2 [outer outer-time-scale inner-time-scale])
nested pattern with independent time scales for outer and inner.
| outer | Pattern producing inner patterns | |
| outer-time-scale | scaling applied to time when querying outer | |
| inner-time-scale | scaling applied to time when querying the selected inner pattern |
Pattern<T>.
canon
(canon [p copies delay])
play delayed copies of a pattern stacked together.
| p | pattern to copy | |
| copies | number of copies to create | |
| delay | time offset between successive copies in beats (default: 0.25) |
Pattern<vec<T>> with copies offset by delay * i for i in [0, copies). ((canon my-pat 3 0.25) 0.0)
canon-n
(canon-n [p & delays])
play copies of a pattern with individually specified delays.
| p | pattern to copy | |
| delays | list of per-copy delay offsets |
Pattern<vec<T>>.
spread
(spread [p copies spread-amount])
phase-spread copies of a pattern across a time window.
| p | pattern to spread | |
| copies | number of copies | |
| spread-amount | total time window to spread across in beats (default: 1.0) |
Pattern<vec<T>> with copies evenly spaced in [0, spread-amount). ((spread my-pat 4 1.0) 0.0)
spread-n
(spread-n [p & spreads])
phase-spread copies with individually specified offsets.
| p | pattern to spread | |
| spreads | list of per-copy phase offsets |
Pattern<vec<T>>.
stack-polymeter
(stack-polymeter [& pattern-meters])
stack patterns each running at their own meter.
| pattern-meters | list of [pattern meter] tuples |
Pattern<vec<T>> with one element per voice.
stack-polyrhythm
(stack-polyrhythm [& pattern-lengths])
stack patterns each with their own cycle lengths.
| pattern-lengths | list of [pattern length] tuples |
Pattern<vec<T>>.
timesig
(timesig [p & sigs])
apply a sequence of time signatures to a pattern.
| p | pattern to apply time signatures to | |
| sigs | list of [beats-per-bar sub-beats-per-bar] tuples |
Pattern<T> with normalised time within each bar.
make-timesig
(make-timesig [beats-per-bar sub-beats-per-bar])
construct a time signature specification.
| beats-per-bar | beats per bar (e.g., 4 for 4/4, 3 for 3/4) | |
| sub-beats-per-bar | sub-divisions per beat (e.g., 4 for 16th notes) |
A [beats-per-bar sub-beats-per-bar] pair.
three-against-two
(three-against-two [p1 p2])
classic 3:2 polyrhythm.
| p1 | pattern for the 3-beat group | |
| p2 | pattern for the 2-beat group |
Pattern<Tuple T1 T2>.
four-against-three
(four-against-three [p1 p2])
4:3 polyrhythm.
| p1 | pattern for the 4-beat group | |
| p2 | pattern for the 3-beat group |
Pattern<Tuple T1 T2>.
five-against-four
(five-against-four [p1 p2])
5:4 polyrhythm.
| p1 | pattern for the 5-beat group | |
| p2 | pattern for the 4-beat group |
Pattern<Tuple T1 T2>.
five-against-three
(five-against-three [p1 p2])
5:3 polyrhythm.
| p1 | pattern for the 5-beat group | |
| p2 | pattern for the 3-beat group |
Pattern<Tuple T1 T2>.
seven-against-four
(seven-against-four [p1 p2])
7:4 polyrhythm.
| p1 | pattern for the 7-beat group | |
| p2 | pattern for the 4-beat group |
Pattern<Tuple T1 T2>.
polyrhythm-offset
(polyrhythm-offset [p1 len1 offset1 p2 len2 offset2])
polyrhythm with independent phase offsets per pattern.
| p1 | first pattern | |
| len1 | cycle length for first pattern | |
| offset1 | phase offset for first pattern | |
| p2 | second pattern | |
| len2 | cycle length for second pattern | |
| offset2 | phase offset for second pattern |
Pattern<Tuple T1 T2>.
polyrhythm-phased
(polyrhythm-phased [& patterns-and-phases])
polyrhythm with per-pattern length and phase.
| patterns-and-phases | list of [pattern length phase] triples |
Pattern<vec<T>>.
metric-mod
(metric-mod [p modulation-fn])
apply an arbitrary time mapping to a pattern.
| p | pattern to modulate | |
| modulation-fn | Beats -> Beats time remapping function |
Pattern<T> evaluated at modulation-fn(time).
metric-mod-linear
(metric-mod-linear [p & breakpoints])
apply a piecewise linear time mapping.
| p | pattern to modulate | |
| breakpoints | list of [input-time output-time] pairs |
Pattern<T> with piecewise linear time mapping.
lcm
(lcm [a b])
least common multiple of two integers.
| a | first number | |
| b | second number |
LCM of a and b.
gcd
(gcd [a b])
greatest common divisor using the Euclidean algorithm.
| a | first number | |
| b | second number |
GCD of a and b.
polyrhythm-alignment
(polyrhythm-alignment [& lengths])
find the beat at which all polyrhythm patterns realign.
| lengths | list of cycle lengths |
The LCM of all lengths (time at which all patterns complete together). (polyrhythm-alignment 3 4) ; => 12
cross-rhythm
(cross-rhythm [p1 len1 p2 len2 & [phase1 0 phase2 0])
polyrhythm with per-pattern phase offsets.
| p1 | first pattern | |
| len1 | cycle length for first pattern | |
| p2 | second pattern | |
| len2 | cycle length for second pattern | |
| phase1 | phase offset for first pattern (default: 0) | |
| phase2 | phase offset for second pattern (default: 0) |
Pattern<Tuple T1 T2>.
hocket
(hocket [p voices & [selector (cycle (range 0 voices))])
distribute a pattern's output across multiple voices.
| p | source pattern | |
| voices | number of voices to distribute across | |
| selector | IntPattern selecting the active voice (default: cycle 0..voices-1) |
Pattern<vec<T>> where only the selected voice receives the pattern value. ((hocket my-pat 3) 0.0)