[CM] arpeggio in snd
Juan Reyes
juanig@ccrma.Stanford.EDU
Sat, 16 Sep 2006 12:59:40 -0700
Now that we are in the mood for Snd's instruments here is an example of
Guile code for Risset's arpeggio documented on Dodge and Jerse's
Computer Music pages 98~102.
--* Juan
(define arpeggio
(lambda* (beg dur freq amp
#:key
(ampenv '(0 0 0.5 1 1 0))
(offset 1.0))
(let* ((start (floor (* beg (srate))))
(end (+ start (floor (* dur (srate)))))
(waveshbank (make-vector 12))
(amp-env (make-env :envelope ampenv
:scaler (* amp .25)
:start start
:end end))
(output (make-vct end)))
(do ((i 0 (1+ i)))
((= i 12))
(vector-set! waveshbank i (make-waveshape
:frequency (+ freq (* offset (1+ (* i 0.1))))
:partials '(1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9))
))
(do ((i 0 (1+ i)))
((= i end))
(let ((wvsum 0.0))
(do ((j 0 (1+ j)))
((= j 12))
(set! wvsum
(+ wvsum (waveshape (vector-ref waveshbank j)))))
(vct-set! output i (* (env amp-env) wvsum ))))
(vct->channel output start end ))))
;;; (load "arpeggio.scm")
;;;
;;; (arpeggio 0 10 400 0.5)
;;; (arpeggio 0 10 400 0.5 :offset 1.25)
;;;