Reference
Transformations and groove
Transformation families, groove, passing transformations as functions, reproducible chance, choice, substitution, binding, and bit patterns.
Transformations reshape a pattern in score time: they change its rate, move or extract parts of it, copy it, add groove, gate it, or apply a change conditionally. This page lists the transformation families and covers choice, substitution, binding and repeatable randomness.
Temporal transformations act on score time. Audio-file parameters act on the resulting sound. For example, rev reverses a score, while sample-rev reverses sample playback. The sample-playback parameters are described in Samples and slicing.
| Family | Operations |
|---|---|
| Rate and phrase shape | fast, slow, rev, palindrome, hurry, rot, iter, iter-prime. |
| Placement and extraction | early, late, compress, zoom, trunc, linger, within, inside, outside. |
| Repetition and copies | ply, jux, jux-by, off, superimpose, spin. |
| Groove | swing-by, press-by. |
| Conditional application | every, sometimes and related conditional/chunk operations. |
| Echoes | echo-with, echo-spaced, echo-indexed. |
| Structural gating and selection | struct, masks, Euclidean operators, selectors and substitution functions. |
Of these, hurry changes score timing and sample read speed together.
(d1! (>> (s "bd hh sn cp")
(every 3 #'rev)))
(d1! (>> (s "hh*8")
(swing-by 1/3 4)))
(d1! (within 1/2 1 #'rev (s "bd hh sn cp")))
(d1! (>> (s "bd hh sn cp")
(jux #'rev)))
(d1! (echo-spaced 4 1/8 0.7 (s "bd ~ sn ~")))In order, these show conditional application (every), groove (swing-by), placement (within), copies (jux) and echoes (echo-spaced). Transformations can appear as steps in a >> pipeline or be called directly on a pattern.
jux expects a transformation function, as in #'rev above. When a more involved transformation needs arguments, use an explicit function rather than assume every transform expression is automatically curried.
The supplied chance operators are temporally reproducible: they derive their choices from stable temporal inputs and seeds. This is different from repeatedly consulting global random state on every scheduler fragment.
Custom pattern methods remain responsible for their own deterministic behavior; see Extending Mora.
pick floors and wraps numeric indices. pick-clamp floors and clamps instead. They take alternative patterns as separate arguments:
(d1! (pick "<0 1 2>"
(s "bd hh")
(s "sn hh hh")
(s "cp ~ hh")))pick-out, pick-squeeze, pick-reset and pick-restart vary whole-span ownership, fitting or source phase, not only index handling. pick-f selects transformations of a shared source.
inhabit substitutes named phrases while preserving their temporal behavior; squeeze fits them to selector-event intervals. String selectors need matching string keys:
(d1! (inhabit "a b a c"
"a" (s "bd hh")
"b" (s "sn hh hh")
"c" (s "cp ~")))General binding constructs a phrase from each value.
- The
inner-bind,outer-bind,pattern-bindandsqueeze-bindfamilies make attack/whole ownership and fitting explicit. - The corresponding join operations flatten patterns whose values are themselves patterns.
poly-bindandmatch-clockadditionally align authored temporal units continuously, rather than recomputing a possibly discontinuous speed ratio each cycle. Authored units are covered in Authored meter and pacing.
| Purpose | Operations |
|---|---|
| Choice | choose, cycle-choose, wchoose, rand-cat, weighted-rand-cat, shuffle, scramble, markov-pat. |
| Repeatable decisions applied to existing material | degrade-by, sometimes, often, rarely, some-cycles-by. |
| Bit patterns and generated values | binary, binary-list, binary-rand, invert-binary, random-list, random-run. |
The bit-pattern and generated-value operations distinguish event sequences, gates and collection-valued results. A vector held as one event value is not automatically a sequence of attacks. For example:
(d1! (struct (segment 16 (binary-rand :seed 20))
(s "hh")))The example combines binary-rand with an explicit :seed, segment and struct. struct belongs to the structural gating and selection family listed above; segment is described with continuous signals in Signals and patterned arithmetic.
Source references
Repository-relative paths in the Mora source where these mechanisms are implemented.
-
src/mini/transforms.lisp -
src/mini/selection.lisp -
src/mini/pattern-joins.lisp -
src/mini/simple-generators.lisp -
src/mini/weighted-rand-cat.lisp