; ambientprocesses.cm
; by Anthony M. Kozar Jr.
; May 8, 2001
; On the web at 
; Email 
; (C) 2001, Anthony M. Kozar Jr.  All rights reserved.
; The author grants to you a license to use 
; this Lisp source code under the terms of the
; Creative Commons Attribution-ShareAlike License.
; If you do not accept the terms of this license, 
; then you are not permitted to copy, distribute, 
; perform, broadcast, or make derivative works of
; this work.  Contact me if you want to license
; this work under different terms.
; To view a copy of the CC license, visit
; http://creativecommons.org/licenses/by-sa/2.0/
; or send a letter to 
; Creative Commons
; 559 Nathan Abbott Way
; Stanford, California 94305, USA.
(defprocess noteloop (thepitch looptime endtime)
  (process 
    until (> (now) endtime)
    do
    (output (new midi time (now) 
               amplitude (* .01 (between 50 70)) 
               duration 2 
               keynum thepitch
            )
    )
    (wait looptime)
  )
)
(defprocess eno-ambient (pitches length dur-lower dur-upper)
  (process
    for i in pitches
    do 
    (sprout (noteloop i (+ dur-lower (* .001 (between 0 (* 1000 (- dur-upper dur-lower))))) length)
            (now))
    (wait (* .1 (between 4 50)))
  )
)
#| example invocations
(events (eno-ambient '(d2 a2 c3 d3 f3 g3 a3 b3 d4 e4) 60 4 10) "ambient1.midi")
(events (eno-ambient '(d1 a1 f2 c3 d2 e3 d3 e4 f4 a3 g3 b4 c5 d5 a5) 1200 5 16) "ambient2.midi")
(events (eno-ambient '(c3 d3 e3 fs3 g3) 120 5 16) "ambient3.midi")
(events (eno-ambient '(bf1 f2 c3 d3 g3 c4 e4 f4 bf4 d5 e5 g5 c6 c7) 600 3 8) "ambient4-1.midi")
(events (eno-ambient '(c3 d3 g3 e4 f2 c4 d5 e5 bf1 c6 g5 f4 bf4 c7) 600 4 20) "ambient4-2.midi")
(events (eno-ambient '(c3 d3 g3 e4 f2 c4 d5 e5 bf1 c6 g5 f4 bf4 c7) 600 4 12) "ambient4-3.midi")
|#