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.

Score time and sound parameters

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.

Transformation families

FamilyOperations
Rate and phrase shapefast, slow, rev, palindrome, hurry, rot, iter, iter-prime.
Placement and extractionearly, late, compress, zoom, trunc, linger, within, inside, outside.
Repetition and copiesply, jux, jux-by, off, superimpose, spin.
Grooveswing-by, press-by.
Conditional applicationevery, sometimes and related conditional/chunk operations.
Echoesecho-with, echo-spaced, echo-indexed.
Structural gating and selectionstruct, masks, Euclidean operators, selectors and substitution functions.

Of these, hurry changes score timing and sample read speed together.

Examples

Common Lisp
(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.

Passing transformations as functions

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.

Reproducible chance

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.

Choice, substitution and binding

Picking among patterns

pick floors and wraps numeric indices. pick-clamp floors and clamps instead. They take alternative patterns as separate arguments:

Common Lisp
(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.

Substituting named phrases

inhabit substitutes named phrases while preserving their temporal behavior; squeeze fits them to selector-event intervals. String selectors need matching string keys:

Common Lisp
(d1! (inhabit "a b a c"
              "a" (s "bd hh")
              "b" (s "sn hh hh")
              "c" (s "cp ~")))

Binding and joins

General binding constructs a phrase from each value.

  • The inner-bind, outer-bind, pattern-bind and squeeze-bind families make attack/whole ownership and fitting explicit.
  • The corresponding join operations flatten patterns whose values are themselves patterns.
  • poly-bind and match-clock additionally align authored temporal units continuously, rather than recomputing a possibly discontinuous speed ratio each cycle. Authored units are covered in Authored meter and pacing.

Temporal randomness and bit patterns

PurposeOperations
Choicechoose, cycle-choose, wchoose, rand-cat, weighted-rand-cat, shuffle, scramble, markov-pat.
Repeatable decisions applied to existing materialdegrade-by, sometimes, often, rarely, some-cycles-by.
Bit patterns and generated valuesbinary, 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:

Common Lisp
(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

Documentation

Search the documentation

Results update as you type. Use the up and down arrow keys to choose a result and Enter to open it.