tur/mini
MiniToken
(defstruct MiniToken [])
a single lexed token from a mini-notation string.
mini-tokenize
(mini-tokenize [s])
lex a mini-notation string into a vector of tokens.
| s | mini-notation string to lex |
vec<MiniToken> in source order. (mini-tokenize "1 2 3")
parse-expr
(parse-expr [tokens index])
recursive descent parser for mini-notation tokens.
| tokens | vec<MiniToken> produced by mini-tokenize | |
| index | current position in the token vector |
Tuple of (NumPattern, remaining-index).
apply-op
(apply-op [op left right])
apply an infix operator to two patterns.
| op | operator character string | |
| left | left operand pattern | |
| right | right operand pattern |
NumPattern with the operator applied.
parse-mini
(parse-mini [s])
parse a mini-notation expression string into a pattern.
| s | mini-notation string (numbers, operators, brackets) |
NumPattern. (parse-mini "1 2 3") (parse-mini "[1 2 3]") ; => fast 2x
s
(s [expr])
inline mini-notation macro.
(s "1 2 3") ; same as (parse-mini "1 2 3")
parse-drums
(parse-drums [s])
parse drum mini-notation into a sequenced drum pattern.
| s | space-separated drum name string (e.g., "bd sd bd sd") |
Pattern<map> producing drum parameters for each step. (parse-drums "bd sd bd sd")
d
(d [expr])
drum pattern macro.
(d "bd sd") ; same as (parse-drums "bd sd")
parse-note
(parse-note [note-str & [default-octave 4])
parse a note name string into a MIDI note number.
| note-str | note string (e.g., "c4", "g#5", "eb3") | |
| default-octave | octave to use when omitted (default: 4) |
MIDI note number as int. (parse-note "c4") ; => 60 (parse-note "a4") ; => 69
parse-notes
(parse-notes [s])
parse a space-separated note string into a cycling MIDI pattern.
| s | space-separated note string (e.g., "c4 e4 g4") |
NumPattern cycling through MIDI note numbers. (parse-notes "c4 e4 g4")
n
(n [expr])
note pattern macro.
(n "c4 e4 g4") ; same as (parse-notes "c4 e4 g4")
parse-chord
(parse-chord [s])
parse bracket-delimited chord notation into a constant chord pattern.
| s | chord string (e.g., "[c4 e4 g4]") |
Pattern<vec<int>> that always returns the same MIDI note vector. (parse-chord "[c4 e4 g4]")
chord
(chord [expr])
chord pattern macro.
(chord "[c4 e4 g4]") ; same as (parse-chord "[c4 e4 g4]")
parse-rhythm
(parse-rhythm [s & [hit-value 1 rest-value 0])
parse an x/o shorthand rhythm string into a numeric pattern.
| s | string of 'x' (hit) and 'o' (rest) characters | |
| hit-value | value for hits (default: 1) | |
| rest-value | value for rests (default: 0) |
NumPattern cycling through hit/rest values. (parse-rhythm "x o x o") ; => alternating 1 and 0
r
(r [expr])
rhythm pattern macro.
(r "x o x o") ; same as (parse-rhythm "x o x o")
parse-with-repeat
(parse-with-repeat [s])
expand *n repetition notation before cycling.
| s | pattern string where tokens may include *n suffix (e.g., "bd*2 sd") |
NumPattern with expanded sequence. (parse-with-repeat "bd*2 sd") ; => cycle of bd bd sd
mini
(mini [s])
parse a complete mini-notation expression (alias for parse-mini).
| s | mini-notation string |
NumPattern.