[CM] Issue with formant-bank

Todd Ingalls TestCase at asu.edu
Fri May 19 09:58:20 PDT 2023


No problem - just going through and implementing various examples to find all the bugs in my code.

Todd Ingalls
Associate Director
School of Arts, Media and Engineering
ame.asu.edu<http://ame.asu.edu>

On May 19, 2023, at 6:30 AM, bil at ccrma.Stanford.EDU<mailto:bil at ccrma.Stanford.EDU> wrote:

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!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20230519/21fdb669/attachment-0001.html>


More information about the Cmdist mailing list