[CM] nested loop question

Rick Taube taube@uiuc.edu
Wed, 12 May 2004 09:47:48 -0500


> The only hitch is that I want the "now" and "wait" clauses of the 
> process to apply to the inner loop, not the outer one.

you can use 'output' and 'wait' as function calls in an inner loop.

(process ...
          do
          (loop ... do ... (output (whatever))
          (wait (whatever)))


but note that a wait should apply directly to the process.


another way to do this is to recast your nexted loops as an inner 
processes sprrouted by an outer processes.

(new cycle :notes '(c2 d2 ef3)
      :name 'some-notes)

(define (doinner i r)
     (process for j in i
              output
              (new midi :time (now)
                   :duration r :keynum j)
              wait r))

(define (doit num)
   (process with r = .5
            repeat num
            for i = (next #&some-notes #t)
	      sprout (doinner i r)
            wait (* r (length i))))

(doit 60 "test.mid")