Reference

Pipelines and composition

Threading a pattern through steps with >>, combining patterns with stack, cat, time-cat, arrange, align and merge-left, and routing source channels to output orbits.

Mora composes patterns in two directions: along a pipeline, where >> threads one pattern through transformations and clauses, and across time and voices, where operations such as stack, cat and arrange combine several patterns. This page also separates a channel’s source pattern from the SuperDirt orbits its events are sent to.

The pipeline operator

>> threads a pattern through transformations and clauses from left to right:

Common Lisp
(d1! (>> (s "bd hh sn hh")
         (fast 2)
         (gain 0.8)))

Construction and composition go through open protocols, including apply-transform, normalize-clause, apply-clause and pattern-merge-style. Some construction objects are transient. Extending Mora covers defining new transformations.

The same operator also threads visual operators, under defined ordering rules; see Shader composition.

Steps in a bang form

A bang form also accepts consecutive steps after the pattern:

Common Lisp
(d1! (s "bd hh sn hh")
     (fast 2)
     (gain 0.8))

Parallel voices are not parameter merging

Use stack for simultaneous voices:

Common Lisp
(d1! (stack
       (>> (s "bd ~ bd ~")
           (cut 1))
       (>> (s "~ sn ~ sn")
           (cut 2))
       (>> (s "hh*8")
           (cut 3))))

Combining layers is a different operation from stacking voices:

  • An ordinary pattern layer can combine values through align.
  • Parameter annotations use merge-left, so each existing event keeps its multiplicity while receiving its parameter.

The open pattern-merge-style protocol selects that behavior.

Composition operations

Useful temporal composition forms include:

OperationPurpose
stack, overlayParallel patterns.
cat, fast-catSubdivided succession.
slow-catSuccession across cycles.
time-catFit phrases into proportional weighted spans.
arrangeAllocate actual cycle durations to sections.
alignCombine temporal value layers according to their spans.
merge-leftAnnotate existing events without turning sibling voices into one event.

Weights are not durations

time-cat weights are proportions of a span. arrange allocates actual cycle durations to sections. Do not use time-cat weights as if they were arrange durations. Arrangement and transitions covers arrange and its section clocks.

Source channels and output orbits

A Mora channel owns a source pattern. A SuperDirt orbit is an audio output/effect bus. The lanes of one stack can use separate orbits:

Common Lisp
(d1! (stack
       (>> (s "bd ~ bd ~")
           (orbit 0))
       (>> (s "~ sn ~ sn")
           (orbit 1))
       (>> (s "hh*8")
           (orbit 2))))

Orbit indices are zero-based here. The receiver and DAW must already be configured for the requested buses.

Because a channel can send its events to several orbits, a channel is not a universal audio submix. The mixer forms level and xfade address each channel’s configured target orbit: they do not automatically discover and fade every overridden orbit inside an arbitrarily routed stack. A multi-orbit composition needs matching routing and mix ownership; see Arrangement and transitions and From pattern to audio.

Source references

Repository-relative paths in the Mora source where these mechanisms are implemented.

  • src/mini/transforms.lisp
  • src/mini/clauses.lisp
  • src/mini/d-bang-bangs.lisp
  • src/core/combinators.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.