[CM] clm instrument won't compile

Michael Klingbeil michael@klingbeil.com
Mon, 29 May 2006 00:38:24 -0400


I'm looking for help with the following clm instrument. I'm running 
clm-3 (*clm-date* => "8-Apr-06"), OpenMCL 0.14.3, MacOS X 10.3.9.

When I try to compile this instrument, I get the following error:

/Users/mkling/ins/clm_stest.c: In function `clm_stest10':
/Users/mkling/ins/clm_stest.c:106: error: `as_needed_NIL' undeclared 
(first use in this function)
/Users/mkling/ins/clm_stest.c:106: error: (Each undeclared identifier 
is reported only once
/Users/mkling/ins/clm_stest.c:106: error: for each function it appears in.)
/Users/mkling/ins/clm_stest.c:106: warning: passing arg 1 of 
`mus_src' makes pointer from integer without a cast

There is obviously something wrong with the src input function. But 
if I look in the C file, I have the as_needed_0 function there...

Maybe there is something wrong with my macro? But this worked fine with clm-2.

I noticed this ominous paragraph in the docs:

def-clm-struct is syntactically like def-struct, but sets up the 
struct field names for the run macro. There are several examples in 
prc-toolkit95.lisp, and other instruments. The fields can only be of 
a numerical type (no generators, for example).

If so that's kind of a downer...


;; ============================= begin stest.ins

;; smooth noise version

(def-clm-struct src-noise
     s (freq 440.0) (amp 1.0))

(clm::def-optkey-fun make-snoise ((frequency 440.0) (amplitude 1.0))
   (make-src-noise :s
		  (let* ((width 8)
			 (rate (/ frequency *srate*))
			 (gen (make-src :srate 0.0 :width width)))
		    ;; now run the generator to clear latency in src generator
		    (loop repeat (* width (/ 1.0 rate))
		       do
			 (src gen rate
			      #'(lambda (dir) (centered-random amplitude))))
		    gen)
		  :freq (hz->radians frequency)
		  :amp amplitude))

(defmacro snoise (gen bwmod)
   `(* (src-noise-amp ,gen)
       (src (src-noise-s ,gen)
	   ;; the noise bandwidth is specified in radians per sample rate
	   ;; (this is consitent with frequency modulation in other 
clm generators)
	   ;; we need to convert this to a srample rate scaling 
factor which is relative to the output sample rate
	   ;; (since we are generating new random values at each sample)
	   ;; 1/two-pi = 0.15915494309189535
	   (* (+ ,bwmod (src-noise-freq ,gen)) 0.15915494309189535)
	   #'(lambda (dir) (centered-random 1.0)))))


(definstrument stest (start dur amp)
   (let* ((beg (floor (* start *srate*)))
          (end (+ beg (floor (* dur *srate*))))
	 (noise (make-snoise 100)))
     (run
      (loop for i from beg to end do
	  (outa i (* amp (snoise noise 0.0)))))))