[CM] cl/clm mutliple combs

Bill Schottstaedt bil at ccrma.Stanford.EDU
Tue Jun 24 14:13:13 PDT 2014


It looks like you're mixing up scheme ("set!") and CL ("run");
Here is a CL version:

(definstrument mult-combs (beg dur freq amp)
  (let* ((start (floor (* beg *srate*)))
	 (end (+ start (floor (* dur *srate*))))
	 (os (make-oscil freq))
	 (combs (make-array 3))
	 (sum 0.0))

     (setf (aref combs 0) (make-comb .10 600))
     (setf (aref combs 1) (make-comb .20 300))
     (setf (aref combs 2) (make-comb .30 100))

     (run
     (loop for k from start to end do
	   (setf sum 0.0)
	   (let ((x (oscil os)))
	     (do ((i 0 (+ i 1))) 
		 ((= i 3))    
		 (setf sum (+ sum (comb (aref combs i) x)))))
	   (outa k (* amp sum))
	   (outb k (* amp sum))))))
       
; (with-sound (:channels 2 :srate 48000 :header-type mus-riff :data-format mus-lfloat :output 
"mytest.wav") (mult-combs 0 5 200 .1))


and a scheme version:

(definstrument (mult-combs beg dur freq amp)
  (let* ((start (floor (* beg *clm-srate*)))
	 (end (+ start (floor (* dur *clm-srate*))))
	 (os (make-oscil freq))
	 (combs (make-vector 3))
	 (sum 0.0))
     (set! (combs 0) (make-comb .10 600))
     (set! (combs 1) (make-comb .20 300))
     (set! (combs 2) (make-comb .30 100))

     (do ((k start (+ k 1)))
	 ((= k end))
       (set! sum 0.0)
       (let ((x (oscil os)))
	 (do ((i 0 (+ i 1))) 
	     ((= i 3))    
	   (set! sum (+ sum (comb (combs i) x))))
	 (outa k (* amp sum))
	 (outb k (* amp sum))))))
	 ))))
       
; (with-sound (:channels 2 :srate 48000 :header-type mus-riff :output "mytest.wav") (mult-combs 0 5 
200 .1))



In CL, mus-riff output, you need to give a compatible data-format.   In both cases,
you need to make the array (or vector) before loading it.



More information about the Cmdist mailing list