[CM] Issue with formant-bank

bil at ccrma.Stanford.EDU bil at ccrma.Stanford.EDU
Fri May 19 06:30:47 PDT 2023


Ouch!  I optimized formant-bank at some point, and broke
that instrument.  I think this slower version works:

(definstrument (move-formants start file amp radius move-env 
num-formants)
   (let* ((frms (make-vector num-formants))
	 (beg (seconds->samples start))
	 (dur (mus-sound-framples file))
	 (end (+ beg dur))
	 (rd (make-readin file))
	 (menv (make-env move-env :length dur)))
     (display dur) (newline)
     (let ((start-frq (env menv)))
       (do ((i 0 (+ i 1)))
	  ((= i num-formants))
	(set! (frms i) (make-formant (* (+ i 1) start-frq) radius))))
     (do ((k beg (+ k 1)))
         ((= k end))
       (let ((frq (env menv))
	    (sum 0.0)
	    (inp (readin rd)))
	(do ((i 0 (+ i 1)))
	    ((= i num-formants))
	  (set! sum (+ sum (formant (frms i) inp))))
         (outa k (* amp sum))
	(do ((i 0 (+ i 1))
	     (curfrq frq (+ curfrq frq)))
	    ((= i num-formants))
	  (if (< (* 2 curfrq) *clm-srate*)
	      (set! (mus-frequency (frms i)) curfrq)))))))

(with-sound (:srate 22050)
   (move-formants 0 "oboe.snd" 2.0 0.99 '(0 1200 1.6 2400 2.0 1400) 4))


I need to figure out how to handle the original case -- the
optimization moved all the filter innards into the some
arrays in formant-bank, so setting the original formant fields
had no effect on the formant-bank (oops... -- but it's faster!).
Thanks very much for pointing this out!



More information about the Cmdist mailing list