(in-package :cm) (in-syntax :midi) ;;; ;;; Example of the rewrite pattern. Uses same grammer as Tom Johnson in ;;; his piece "Formulas for String Quartet": given alphabet {+ -}, rewrite + ;;; with + - + and rewrite - with - - +. In our example we use a step ;;; stream where + is defined as a whole step up and - is a whole step down. ;;; use a quartet of voices spaced 5th apart in different tempi. ;;; (merge tj () (loop with tempo = 100 for r in '(16 8 4 2) for n in '(c5 f4 bf3 ef3) do (let ((r (rhythm r tempo)) (n n)) (algorithm nil midi-note (note n amplitude .4 end 20 rhythm r duration r) (vars (s (steps (2 to (2 -2 2)) (-2 to (-2 -2 2)) in rewrite initially 2 initially-from note))) (setf note (item s)))))) #| write tj test.midi 0 |#