[CM] run (guile) type declarations
Bill Schottstaedt
bil@ccrma.Stanford.EDU
Sat, 16 Sep 2006 11:20:26 -0700
Here's one way:
(definstrument (add beg dur freq amp)
(let* ((start (seconds->samples beg))
(end (+ start (seconds->samples dur)))
(vec (make-vector 20))
(env 0))
(do ((i 0 (1+ i))) ((= i 20))
(vector-set! vec i (make-oscil (* (1+ i) 100))))
(run
(lambda ()
(declare env float)
(do ((i start (1+ i)))
((= i end))
(let ((sum 0.0))
(do ((j 0 (1+ j)))
((= j 20))
(set! sum (+ sum (* (sin env) (oscil (vector-ref vec j)))))
(set! env (+ env (/ pi 20.))))
(outa i (* amp .05 sum) *output*)))))))
but it seems perverse -- I'll look into making the optimizer's type checker smarter
about this sort of case.