[CM] run (guile) type declarations
Carlos Pita
carlosjosepita@yahoo.com.ar
Sat, 16 Sep 2006 14:44:20 -0300 (ART)
Hi all!
Suppose I have the following simple additive
instrument definition, which envelopes its spectrum in
half a sin period:
(definstrument (add beg dur freq amp)
(let* ((start (seconds->samples beg))
(end (+ start (seconds->samples dur)))
(vec (make-vector 20)))
(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))
; (declare env float)
(let ((sum 0.0))
; (declare env float)
(do ((j 0 (1+ j))
(env 0 (+ (/ pi 20.) env)))
((= j 20))
; (declare env float)
(set! sum (+ sum (* (sin env) (oscil
(vector-ref vec j))))))
(outa i (* amp .05 sum) *output*)))))))
When running it with optimization level 4 it simply
generates a zero constant wave. I guess it have to do
with the env variable being taken as an int instead of
a floating point number. In fact, if I replace (env 0
...) by (env 0.0 ...) it works fine even for opt level
4. Is there a way to achieve the same effect by adding
a type declaration somewhere? I try putting (declare
env float) in every commented out place above but
neither of them seems to be honoured. I'm not sure
about where to put the declaration or whether it is a
valid one.
Can you help me?
Thank you in advance.
Best regards,
Carlos
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas