[CM] clm-3 help

Michael Klingbeil michael@klingbeil.com
Wed, 30 Mar 2005 01:04:24 -0500


I'm looking for some help with an instrument that won't compile. It 
seems to work fine under clm-2. With clm-3 I get a .c file but the 
compilation fails with errors about undeclared variables. This is on 
MacOS X and OpenMCL. I tried without success using clm-3 16-Mar-05 
(in Rick's CM.app) and also with clm-3 23-Mar-05.

I tried adding in some declare statements but that didn't seem to 
help. I wonder if there is an issue with the run macro compiler. I 
got some similar errors with another instrument (undeclared 
variables) but I was able to fix the problem by getting rid of a let 
statement in the run macro. Are let blocks a bad idea within run?

I am including the compiler errors and the instrument definition. Any 
advice is appreciated.

Regards,

Michael

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Compiling #4P"proj:ins;noisetone.ins.newest".; Writing 
"/Users/mkling/Desktop/mand/ins/clm_noisetone.c"
; Compiling "/Users/mkling/Desktop/mand/ins/clm_noisetone.c"
/Users/mkling/Desktop/mand/ins/clm_noisetone.c: In function `clm_noisetone14':
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:154: error: `G1060' 
undeclared (first use in this function)
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:154: error: (Each 
undeclared identifier is reported only once
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:154: error: for each 
function it appears in.)
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:154: error: array 
subscript is not an integer
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:155: error: array 
subscript is not an integer
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:156: error: `G1060_r' 
undeclared (first use in this function)
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:156: error: 
`DEGREE_ENV_r' undeclared (first use in this function)
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:164: error: array 
subscript is not an integer
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:165: error: array 
subscript is not an integer
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:166: error: 
`DISTANCE_ENV_r' undeclared (first use in this function)
/Users/mkling/Desktop/mand/ins/clm_noisetone.c: In function `clm_noisetone14':
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:154: error: `G1060' 
undeclared (first use in this function)
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:154: error: (Each 
undeclared identifier is reported only once
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:154: error: for each 
function it appears in.)
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:154: error: array 
subscript is not an integer
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:155: error: array 
subscript is not an integer
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:156: error: `G1060_r' 
undeclared (first use in this function)
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:156: error: 
`DEGREE_ENV_r' undeclared (first use in this function)
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:164: error: array 
subscript is not an integer
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:165: error: array 
subscript is not an integer
/Users/mkling/Desktop/mand/ins/clm_noisetone.c:166: error: 
`DISTANCE_ENV_r' undeclared (first use in this function)
; Loading #4P"proj:ins;noisetone.dfsl.newest".; Compiling 
"/Users/mkling/Desktop/mand/ins/clm_noisetone.c"
>  Error in process listener(4): Error opening shared library 
>"/Users/mkling/Desktop/mand/ins/clm_noisetone.dylib": dyld: 
>/Applications/CM.app/Contents/MacOS/dppccl can't open library: 
>/Users/mkling/Desktop/mand/ins/clm_noisetone.dylib  (No such file or 
>directory, errno = 2)
>
>  While executing: OPEN-SHARED-LIBRARY
>  Type :POP to abort.
Type :? for other options.
1 > :q
?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;;      file: noisetone.ins
;;;;

(definstrument noisetone (start dur amp ampfunc  ;; amplitude 
envelope (must be envelope)
                                 freqfunc bwfunc  ;; frequency and 
bandwidth (can envelopes or scalar)
                                 &key
                                 (bwbase 0.0)
                                 (ampbase 10)  ;; base for amplitude envelope
                                 (mix 1.0) ;; control mix between 
noisy sinusoid = 1.0 ---> 0.0 = pure sinusoid
                                 (degree 45.0)
                                 (distance 1.0)
                                 (reverb 0.1)  ;; how much signal to 
send to reverberator
                                 )
   (let* ((beg (floor (* start *srate*)))
          (end (+ beg (floor (* dur *srate*))))
          (ampenv (if ampbase
                    (make-env :envelope ampfunc :duration dur :scaler 
amp :base ampbase)
                    (make-env :envelope ampfunc :duration dur :scaler amp)))

          (noise (make-rand-interp (if (numberp bwfunc) (+ bwfunc 
bwbase) bwbase)))
          (bwenv (if (listp bwfunc)
                   (make-env :envelope bwfunc :duration dur :scaler 
(hz->radians 1.0))
                   nil))
          (freqenv (if (listp freqfunc)
                     (make-env :envelope freqfunc :duration dur 
:scaler (hz->radians 1.0))
                     nil))
          (mixenv (if (listp mix)
                    (make-env :envelope mix :duration dur)))
          (mixscaler (if (listp mix) 0.0 mix))
          (sine (make-oscil (if (numberp freqfunc) freqfunc 0.0) 
(centered-random pi)))  ;; random phase on oscilator
          ;;
          ;; locsig stuff follows:
          ;;
          (update-rate 10)
          (degree-env (if (listp degree)
                        (make-env :envelope degree :duration (/ dur 
update-rate))
                        nil))
          (distance-env (if (listp distance)
                          (make-env :envelope distance :duration (/ 
dur update-rate))))
          (place (make-locsig :degree (if (numberp degree) degree 45.0)
                              :distance (if (numberp distance) distance 1.0)
                              :reverb (if (numberp reverb) reverb 0.0)
                              :type mus-sinusoidal))
          )
     (run
      (loop for i fixnum from beg to end do
            (let (deg dist wave freqmod bwmod mixmod)
              #-just-lisp (declare (type :integer beg end update-rate)
                                   (type :mus-any ampenv noise bwenv 
freqenv mixenv sine
                                         degree-env distance-env place)
                                   (type :float mixscaler deg degree 
distance dist wave freqmod bwmod mixmod mixscaler))
              (if (or degree-env distance-env)
                (if (= 0 (mod (- i beg) update-rate))
                  (setf deg (if degree-env (env degree-env) degree))
                  (setf dist (if distance-env (env distance-env) distance))
                  (move-locsig place deg dist)))
              (setf freqmod (if freqenv (env freqenv) 0.0))
              (setf bwmod (if bwenv (env bwenv) 0.0))
              ;; mix is not equal power
              (setf mixmod (if mixenv (env mixenv) mixscaler))
              (setf wave (oscil sine freqmod))
              (locsig place i (* (env ampenv)
                                 (+ (* mixmod wave (rand-interp noise bwmod))
                                    (* (- 1.0 mixmod) wave)))))
            ))))