[CM] clm instrument compile problem

Michael Klingbeil michael at klingbeil.com
Mon Apr 14 19:35:03 PDT 2008


I'm getting a mysterious error compiling the instrument code shown toward the end of this message. Any help would be appreciated. It looks like a possible bug where the run compiler cannot deduce the type of the generator contained in an array.

Class named NIL not found.
   [Condition of type SIMPLE-ERROR]

Backtrace:
  0: (FIND-CLASS 'NIL)
  1: (#<CCL::STANDARD-KERNEL-METHOD MAKE-INSTANCE (SYMBOL)> 'NIL)
  2: (CLM::GEN-MAKE-1 'NIL #<FILE-CHARACTER-OUTPUT-STREAM ("/Users/mkling/tear/ins/clm_combfile.c"/16) #x87DA94E> "FILTERS_array[i]" 'CLM::LC 'FILTERS 'FORMAT)
  3: (CLM::GEN-ARRAY-MAKE #S(CLM::VARINFO :NAME FILTERS :DEPTH 0 :MAX-DEPTH 1 :REFD T :PARALLEL ...) #(4 #<HASH-TABLE-VECTOR  #x87D9946> #<HASH-TABLE :TEST EQL size 52/60 #x87D98D6> NIL NIL))
  4: (MAPHASH #<HASH-TABLE :TEST EQL size 52/60 #x87D98D6> 'FORMAT)
  5: (CLM::<START> '(CLM::<START> END) #<CCL::LEXICAL-ENVIRONMENT #x893E726>)
  6: (FUNCALL #<Compiled-function CLM::<START> Macroexpander #x870026E>)
  7: (MACROEXPAND-1 '(CLM::<START> END) #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6>)

I've tested under various versions of clm-3 as well as the latest clm-4. The problem is with the type declaration for the "filters" array

(type :filters mus-any*)

Filters is supposed to be an array of comb filters. If I comment out this declaration all is well (except that the C code is now messy with a runtime type check).
*clm-debug* prints the following:

make #S(VARINFO :NAME FILTERS :DEPTH 0 :MAX-DEPTH 1 :REFD T :PARALLEL NIL :TYPE NIL :ILOC 19 :RLOC 7 :INITIALIZE T :TEMP NIL :SHADOWED NIL :GEN-TYPE MUS-ANY-ARRAY :ARR-GEN-TYPE NIL :GLOBAL NIL :CTR NIL :LOADED NIL :REF-CHAIN NIL)?
making gen array

And here is the instrument code:


(definstrument combfile (time duration frequency amplitude
                              gain filename &key
                              (amp-env '(0 1 100 1))
                              (file-start 0.0))
  (if (not duration) (setf duration (- (sound-duration filename) file-start)))
  (if (not (listp frequency)) (setf frequency`(0 ,frequency 100 ,frequency)))
  (if (not (listp gain)) (setf gain `(0 ,gain 100 ,gain)))  
  (if (/= *srate* (sound-srate filename))
    (warn "input file sampling rate does not equal output sampling rate!"))
  (setf frequency (loop for (x y) on frequency by #'cddr
                        collect x
                        collect (/ *srate* y)))
  
  (let* ((beg (floor (* time *srate*)))
         (end (+ beg (floor (* duration *srate*))))
         (srate (sound-srate filename))
         (freqenv (make-env :envelope frequency
                            :duration duration))
         (ampenv (make-env :envelope amp-env
                           :duration duration
                           :scaler amplitude))
         (gainenv (make-env :envelope gain
                             :duration duration))
         (chans (sound-chans filename))
         (maxlen (1+ (ceiling (loop for y in (cdr frequency) by #'cddr
                                    maximize y))))
         (filters (make-array chans :initial-contents
							  (loop repeat chans collect
								   (setf (aref filters n)
										 (make-comb
										  :size 0.0
										  :scaler (second gain)
										  :max-size maxlen)))))
         (input (make-file->frame filename))
         (frame (make-frame (sound-chans filename)))
         (inloc (floor (* file-start srate)))))
  (run
   (loop for i from beg to end do
		(let (freq amp gain filter)
		  (declare 
		   (type :integer i inloc chans)
		   (type :float freq amp gain)
		   (type :mus-any input frame)
		   (type :mus-any* filters)
		   )
		  (file->frame input inloc frame)
		  (incf inloc)
		  ;; apply filter
		  (setf freq (env freqenv))
		  (setf amp (env ampenv))
		  (setf gain (env gainenv))
		  (loop for n from 0 below chans do
			   (declare (type :integer n))
			   (setf filter (aref filters n))
			   (setf (mus-feedback filter) gain)
			   (frame-set! frame n (* amp (comb filter (frame-ref frame n) freq))))
		  (frame->file *output* i frame))))
  (close-input input))


And here is a full slime backtrace:

Class named NIL not found.
   [Condition of type SIMPLE-ERROR]

Restarts:
  0: [RETRY-COMPILE-FILE] Retry compiling "/Users/mkling/tear/ins/sfmcomb.ins"
  1: [SKIP-COMPILE-FILE] Skip compiling "/Users/mkling/tear/ins/sfmcomb.ins"
  2: [ABORT-REQUEST] Abort handling SLIME request.
  3: [ABORT-BREAK] Reset this process
  4: [ABORT] Kill this process

Backtrace:
  0: (FIND-CLASS 'NIL)
  1: (#<CCL::STANDARD-KERNEL-METHOD MAKE-INSTANCE (SYMBOL)> 'NIL)
  2: (CLM::GEN-MAKE-1 'NIL #<FILE-CHARACTER-OUTPUT-STREAM ("/Users/mkling/tear/ins/clm_combfile.c"/16) #x87DA94E> "FILTERS_array[i]" 'CLM::LC 'FILTERS 'FORMAT)
  3: (CLM::GEN-ARRAY-MAKE #S(CLM::VARINFO :NAME FILTERS :DEPTH 0 :MAX-DEPTH 1 :REFD T :PARALLEL ...) #(4 #<HASH-TABLE-VECTOR  #x87D9946> #<HASH-TABLE :TEST EQL size 52/60 #x87D98D6> NIL NIL))
  4: (MAPHASH #<HASH-TABLE :TEST EQL size 52/60 #x87D98D6> 'FORMAT)
  5: (CLM::<START> '(CLM::<START> END) #<CCL::LEXICAL-ENVIRONMENT #x893E726>)
  6: (FUNCALL #<Compiled-function CLM::<START> Macroexpander #x870026E>)
  7: (MACROEXPAND-1 '(CLM::<START> END) #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6>)
  8: (WALKER::WALK-FORM-INTERNAL '((CLM::<START> END) (PROGN :PROG (CLM::<COMMENT> PROGN) (CLM::<FILE2FRAME> # # #) (CLM::<SETF> 1 # 1) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) ...) (CLM::<END-1>) (CLM::<END-2> BEG END END)) '((EVAL)) '(EVAL))
  9: (WALKER::WALK-TEMPLATE-HANDLE-REPEAT-1 '((CLM::<START> END) (PROGN :PROG (CLM::<COMMENT> PROGN) (CLM::<FILE2FRAME> # # #) (CLM::<SETF> 1 # 1) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) ...) (CLM::<END-1>) (CLM::<END-2> BEG END END)) '((EVAL)) '(EVAL) '(NIL WALKER::REPEAT (EVAL)) '(PROGN (CLM::<START> END) (PROGN :PROG (CLM::<COMMENT> PROGN) (CLM::<FILE2FRAME> # # #) (CLM::<SETF> 1 # 1) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) ...) (CLM::<END-1>) (CLM::<END-2> BEG END END)) #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6>)
 10: (WALKER::WALK-TEMPLATE '(PROGN (CLM::<START> END) (PROGN :PROG (CLM::<COMMENT> PROGN) (CLM::<FILE2FRAME> # # #) (CLM::<SETF> 1 # 1) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) ...) (CLM::<END-1>) (CLM::<END-2> BEG END END)) '(PROGN (CLM::<START> END) (PROGN :PROG (CLM::<COMMENT> PROGN) (CLM::<FILE2FRAME> # # #) (CLM::<SETF> 1 # 1) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) (CLM::<SETF> 0 # #) (CLM::<ENV> # #) ...) (CLM::<END-1>) (CLM::<END-2> BEG END END)) #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> 'PROGN)
 11: (WALKER::WALK-FORM-INTERNAL '(CLM::RUN-1 (LOOP FOR I FROM BEG TO END DO (LET # # # # # # # # #))) #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> 'CLM::RUN-1)
 12: (WALKER::WALK-FORM-INTERNAL '((CLM::RUN-1 (LOOP FOR I FROM BEG TO END DO #))) '((EVAL)) '(EVAL))
 13: (WALKER::WALK-TEMPLATE-HANDLE-REPEAT-1 '((CLM::RUN-1 (LOOP FOR I FROM BEG TO END DO #))) '((EVAL)) '(EVAL) '(WALKER::CALL WALKER::REPEAT (EVAL)) '(MACROEXPAND-1 (CLM::RUN-1 (LOOP FOR I FROM BEG TO END DO #))) #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6>)
 14: (WALKER::WALK-TEMPLATE '(MACROEXPAND-1 (CLM::RUN-1 (LOOP FOR I FROM BEG TO END DO #))) '(MACROEXPAND-1 (CLM::RUN-1 (LOOP FOR I FROM BEG TO END DO #))) #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> 'MACROEXPAND-1)
 15: (WALKER::WALK-FORM-INTERNAL '(RUN (LOOP FOR I FROM BEG TO END DO (LET # # # # # # # # #))) #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> 'RUN)
 16: (WALKER::WALK-FORM-INTERNAL '((RUN (LOOP FOR I FROM BEG TO END DO #)) (CLOSE-INPUT INPUT)) #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> 'LOCALLY)
 17: (WALKER::WALK-REPEAT-EVAL #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> '((LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) (CLOSE-INPUT INPUT)))
 18: (WALKER::WALK-REPEAT-EVAL #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> '((SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) (CLOSE-INPUT INPUT)))
 19: (WALKER::WALK-REPEAT-EVAL #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> '((IF (/= *SRATE* #) (WARN "input file sampling rate does not equal output sampling rate!")) (SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) (CLOSE-INPUT INPUT)))
 20: (WALKER::WALK-REPEAT-EVAL #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> '((IF (NOT #) (SETF GAIN #)) (IF (/= *SRATE* #) (WARN "input file sampling rate does not equal output sampling rate!")) (SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) (CLOSE-INPUT INPUT)))
 21: (WALKER::WALK-REPEAT-EVAL #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> '((IF (NOT #) (SETF FREQUENCY #)) (IF (NOT #) (SETF GAIN #)) (IF (/= *SRATE* #) (WARN "input file sampling rate does not equal output sampling rate!")) (SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) (CLOSE-INPUT INPUT)))
 22: (WALKER::WALK-REPEAT-EVAL #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> '((IF (NOT DURATION) (SETF DURATION #)) (IF (NOT #) (SETF FREQUENCY #)) (IF (NOT #) (SETF GAIN #)) (IF (/= *SRATE* #) (WARN "input file sampling rate does not equal output sampling rate!")) (SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) (CLOSE-INPUT INPUT)))
 23: (WALKER::WALK-REPEAT-EVAL #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> '(LOCALLY (IF (NOT DURATION) (SETF DURATION #)) (IF (NOT #) (SETF FREQUENCY #)) (IF (NOT #) (SETF GAIN #)) (IF (/= *SRATE* #) (WARN "input file sampling rate does not equal output sampling rate!")) (SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) (CLOSE-INPUT INPUT)))
 24: (WALKER::WALK-LOCALLY ':EVAL #<CCL::LEXICAL-ENVIRONMENT #x87DA7E6> '(LOCALLY (IF (NOT DURATION) (SETF DURATION #)) (IF (NOT #) (SETF FREQUENCY #)) (IF (NOT #) (SETF GAIN #)) (IF (/= *SRATE* #) (WARN "input file sampling rate does not equal output sampling rate!")) (SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) (CLOSE-INPUT INPUT)))
 25: (WALKER::WALK-FORM-INTERNAL '(DEFINSTRUMENT COMBFILE (TIME DURATION FREQUENCY AMPLITUDE GAIN FILENAME &KEY (AMP-ENV #) (FILE-START 0.0)) (IF (NOT DURATION) (SETF DURATION #)) (IF (NOT #) (SETF FREQUENCY #)) (IF (NOT #) (SETF GAIN #)) (IF (/= *SRATE* #) (WARN "input file sampling rate does not equal output sampling rate!")) (SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) ...) #<CCL::LEXICAL-ENVIRONMENT #x87DB8C6> "/Users/mkling/tear/ins/clm_combfile.c")
 26: (DEFINSTRUMENT '(DEFINSTRUMENT COMBFILE (TIME DURATION FREQUENCY AMPLITUDE GAIN FILENAME &KEY (AMP-ENV #) (FILE-START 0.0)) (IF (NOT DURATION) (SETF DURATION #)) (IF (NOT #) (SETF FREQUENCY #)) (IF (NOT #) (SETF GAIN #)) (IF (/= *SRATE* #) (WARN "input file sampling rate does not equal output sampling rate!")) (SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) ...) #<CCL::LEXICAL-ENVIRONMENT #x87DB8C6>)
 27: (FUNCALL #<Compiled-function DEFINSTRUMENT Macroexpander #x8717DD6>)
 28: (MACROEXPAND-1 'DEFINSTRUMENT #<CCL::LEXICAL-ENVIRONMENT #x87DB8C6>)
 29: (CCL::FCOMP-FORM-1 'NIL #<SVAR CCL::*FCOMP-INDENTATION* 600 #x827A366> #<SVAR CCL::*FCOMP-LAST-COMPILE-PRINT* 601 #x827A356>)
 30: (CCL::FCOMP-FORM #<CCL::LEXICAL-ENVIRONMENT #x87DB8C6> '(DEFINSTRUMENT COMBFILE (TIME DURATION FREQUENCY AMPLITUDE GAIN FILENAME &KEY (AMP-ENV #) (FILE-START 0.0)) (IF (NOT DURATION) (SETF DURATION #)) (IF (NOT #) (SETF FREQUENCY #)) (IF (NOT #) (SETF GAIN #)) (IF (/= *SRATE* #) (WARN "input file sampling rate does not equal output sampling rate!")) (SETF FREQUENCY (LOOP FOR # ON FREQUENCY BY # COLLECT X COLLECT ...)) (LET* (# # # # # # # # # # ...)) (RUN (LOOP FOR I FROM BEG TO END DO #)) ...) #<CCL::LEXICAL-ENVIRONMENT #x87DB8C6>)
 31: (CCL::FCOMP-READ-LOOP "/Users/mkling/tear/ins/sfmcomb.ins" #P"home:tear;ins;sfmcomb.ins" #<SVAR CCL::*FCOMP-OUTPUT-LIST* 598 #x827A386> #P"home:tear;ins;sfmcomb.ins")
 32: (CCL::FCOMP-FILE "/Users/mkling/tear/ins/sfmcomb.ins" #P"home:tear;ins;sfmcomb.ins" #<CCL::LEXICAL-ENVIRONMENT #x87DB8C6>)
 33: (CCL::%COMPILE-FILE "/Users/mkling/tear/ins/sfmcomb.ins" 'NIL 'NIL 'NIL 'NIL 'NIL 'T 'T 'NIL 'NIL ':DEFAULT '(#<RESTART CCL::RETRY-COMPILE-FILE #x14EFAA6> #<RESTART CCL::SKIP-COMPILE-FILE #x14EFACE>))
 34: (COMPILE-FILE "/Users/mkling/tear/ins/sfmcomb.ins")
 35: (CCL::CALL-CHECK-REGS 'COMPILE-FILE)
 36: (SWANK::EVAL-REGION "(compile-file \"/Users/mkling/tear/ins/sfmcomb.ins\")
" 'T)
 37: (#<Anonymous Function #x840AA96> "(compile-file \"/Users/mkling/tear/ins/sfmcomb.ins\")
")



More information about the Cmdist mailing list