[CM] play-pats

Landspeedrecord landspeedrecord@gmail.com
Tue, 26 Jun 2007 19:20:26 -0400


I couldn't run the code you are quoting from the common music
dictionary either. However, I think this will fix your problem:

(define (play-pats pats trope reps rate)
  (process with dur = (* rate 2.5)
           repeat reps
           for len = (pick 8 12 16)
           for pat = (make-instance (next pats)
                                    :keynums trope
                                    :for len)
           do (loop for k in (next pat #t)
                    for x from 0 by rate
                    do (output (new midi :time (+ (now) x)
                       :keynum k
                       :duration dur)))
           wait (* rate len)))

I don't know why but Common Music doesn't seem to like "each k in
(next pat #t) as x from 0 by rate".  It is the "as x..." part that is
causing the problem.  You can work around it using the fact that:

"each i in some-list output ..."
is equivalent to
"do (loop for i in some-list do (output ...))"

FWIW the next statement following the one you are quoting is missing a
closing parenthesis.  It should be:
(define pcns
  (new weighting :of '((heap :weight 2) line cycle
                    palindrome rotation)))