Reference

Pattern literals

The s, n, notes, p and e literal macros, bare symbols as sample names, sub for subdivision, and the ($ expression) escape to ordinary Lisp.

Pattern literals are the short forms that turn sample names, numbers, pitches and other values into temporal patterns. They are Common Lisp macros, so they sit inside ordinary Lisp code and can return to it when a value needs computing.

The literal forms

The literal forms are macros with context-sensitive coercion: the same written token can be read differently depending on which literal contains it.

FormPrimary purpose
sSound/sample names and their mini notation.
nThe legacy numeric/sample-index lane; its interpretation depends on the receiving context.
notesExplicit absolute pitches, including named and fractional pitches.
pGeneric temporal values.
eCompact Euclidean construction.

The string syntax that s accepts is described in Mini notation, which also includes an e example. Named pitches, scales and tuning are covered in Pitch, harmony, and tuning.

Symbols as sample names

Inside s, bare symbols can mean sample names:

Common Lisp
(d1! (s bd sn hh cp))

Subdividing a slot with sub

Mini notation subdivides a slot with brackets inside a string. sub subdivides a slot directly in s-expressions:

Common Lisp
(d1! (s bd (sub hh hh) sn (sub hh cp)))

Here the second slot is divided between two hh events, and the fourth between hh and cp.

Escaping to ordinary Lisp

Use ($ expression) when a literal should evaluate ordinary Lisp:

Common Lisp
(defparameter *kit* '("bd" "hh" "sn" "hh"))

(d1! (s ($ (apply #'cat *kit*))))

*kit* is an ordinary Lisp list of strings. Inside the s literal, $ evaluates (apply #'cat *kit*), which passes those strings to cat, the subdivided-succession operation listed under composition operations.

Ordinary Lisp data

Common Lisp functions, variables and control structures remain available. A list is ordinary Lisp data unless it is explicitly turned into a pattern. See Common Lisp and CLOS for why the surrounding language matters.

Source references

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

  • src/mini/

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.