Macro
(pattern{clause}+)
Creates a pattern from a series of definitional clauses. There are four types of clauses: variable definitions, pattern and element type specifications, item specifications and pattern initializations.
Pattern variables are named expressions that can be referenced as
items inside the pattern's data specification. Only variables are
evaluated; a pattern treats all other items as constant (unevaluated)
data. There are two types of pattern variables: normal variables declared
using with and substitution variables declared
using alias:
with var = expr {and var2 = expr2}*alias var = form {and var2 = form2}*next.;; The difference between the with and alias variable declarations. (define p (pattern with x = (random 10) cycle a x b x c x)) (next p 12) ⇒ (a 7 b 7 c 7 a 7 b 7 c 7) (define p (pattern alias x = (random 10) cycle a x b x c x)) (next p 12) ⇒ (a 2 b 9 c 3 a 3 b 1 c 5)
The pattern's type declaration consists of a pattern type followed by an optional element type:
of element-type]cycle weighting
heap line palindrome graph markov rewrite rotation. An
optional of clause specifies an element-type.
If provided it determines how items in the pattern are to be
interpreted. The element-type can be one of: notes
keynums hertz rhythms amplitudes.
;; Pattern and element type declarations. (define p (pattern cycle c d e f g a)) (next p 12) ⇒ (c d e f g a c d e f g a) (define p (pattern heap of keynums c d e f g a)) (next p 12) ⇒ (60 69 65 69 62 65 64 60 64 67 67 62) (define p (pattern cycle of rhythms q w e s tempo 90)) (next p 8) ⇒ (0.6666667 2.6666667 0.33333334 0.16666667 0.6666667 2.6666667 0.33333334 0.16666667)
Following the pattern's type declaration comes one or more item specifications. Items that are not pattern variables are unevaluated data, that is, they are are constants in the pattern. Certain pattern types ( weighting, graph, etc.) allow items to be specified within pattern node lists. In these cases the first element in the node lists is treaded as the node's item.
;; Item specification. (define p (pattern with x = (pattern cycle 1 2 3) weighting a (x :weight .5) b c (d :weight 2))) (next p 20) ⇒ (a c c d 1 2 3 c d 1 2 3 a d d d c d c a)
After the items have been specified zero or more pattern initializations can be provided, as described in the patterns topic help.
;; Pattern initializations. (define p (pattern with x = (pattern cycle 3 4 5) and y = (pattern heap 60 90 120) weighting of rhythms q w e s tempo y for x)) (next p #t) (0.33333334 0.25 0.25) (next p #t) (0.125 1.0 0.16666667 0.5) (next p #t) (0.6666667 2.0 0.25 0.16666667 1.0) (next p #t) (0.6666667 0.5 4.0) ⇒