Re: [CM] make-bandpass
If the bandpass generator is getting no input, it returns 0.0. Otherwise it returns the output of the bandpass filter (normally audio samples). mus-xcoeffs is an array of filter coefficients -- these are convolved with the input to produce the output, so ;(float-vector-set! v l (bandpass b l)) ;what is output here? The output of (bandpass b 0) then (bandpass b 1). (float-vector-set! v l ((mus-xcoeffs b) l)) ;filter magnitudes The first and second filter coefficients. (flt3 (lambda (y) (+ (bandpass flt1 y) (bandpass flt2 y this adds the output of two bandpass generators. It is not the same as adding the two generator's filter coefficients. Julius Smith has written a very good introduction to filters, available for free online I think. ___ Cmdist mailing list Cmdist@ccrma.stanford.edu https://cm-mail.stanford.edu/mailman/listinfo/cmdist
[CM] make-bandpass
Yes. Understood. That's very helpful information. I see I can use mus-xcoeffs with make-bandpass. I think I wasn't indexing it properly too. If I might continue to ask, what are the numbers ouput from the generator, ex. (bandpass b)? I know the xcoeffs are the filter magnitudes but when nothing is passing thru the filter yet, as it would be if one were to call (outa i (b (* amp (oscil os, what do the output numbers of the generator represent before the filter is applied to a source? Are they random sample amplitudes, for ex.? (let* ((b (make-bandpass (hz->radians 500.0) (hz->radians 2000.0) 3)) (v (make-float-vector 3)) ) (do ((l 0 (+ l 1))) ((= l 3)) ;(float-vector-set! v l (bandpass b l)) ;what is output here? (float-vector-set! v l ((mus-xcoeffs b) l)) ;filter magnitudes (format #t "~%l: ~F v: ~0,6F" l (v l)) ) (do ((l 0 (+ l 1))) ((= l 3)) (format #t "~%j: ~F v: ~0,6F" l (v l)) ) ) ...also (sorry this long-winded) when I see a lambda func adding the two bandpass filters, ex. (flt3 (lambda (y) (+ (bandpass flt1 y) (bandpass flt2 y I cannot get the mus-xcoeffs of flt3 then, because it's now a lambda function. So my purpose was to prove to myself that the lambda func was indeed the same as adding two vectors of mus-xcoeffs. (float-vector-add! v1 v2). In other words trying to see the numbers to verify the lambda function is indeed adding the xcoeffs, not the generator outputs. I hope that makes sense. But I'm still failing in my proof. Regards, Jim From: cmdist-boun...@ccrma.stanford.edu on behalf of cmdist-requ...@ccrma.stanford.edu Sent: Thursday, June 30, 2022 9:00 AM To: cmdist@ccrma.Stanford.EDU Subject: Cmdist Digest, Vol 169, Issue 9 Send Cmdist mailing list submissions to cmdist@ccrma.stanford.edu To subscribe or unsubscribe via the World Wide Web, visit https://cm-mail.stanford.edu/mailman/listinfo/cmdist or, via email, send a message with subject or body 'help' to cmdist-requ...@ccrma.stanford.edu You can reach the person managing the list at cmdist-ow...@ccrma.stanford.edu When replying, please edit your Subject line so it is more specific than "Re: Contents of Cmdist digest..." Today's Topics: 1. Re: make-bandpass xcoeffs (b...@ccrma.stanford.edu) -- Message: 1 Date: Wed, 29 Jun 2022 12:04:42 -0700 From: b...@ccrma.stanford.edu To: James Hearon Cc: "cmdist@ccrma.Stanford.EDU" Subject: Re: [CM] make-bandpass xcoeffs Message-ID: <4bc1a174e5c876e81b11ac36a0886...@ccrma.stanford.edu> Content-Type: text/plain; charset=US-ASCII; format=flowed make-bandpass is a wrapper around make-fir-filter, returning an fir-filter generator, so mus-xcoeffs does work with it; there's an example in snd-test.scm around line 7706. make-bandpass is not itself a generator; it returns one. If you look at the code in dsp.scm you'll see (define bandpass fir-filter) -- this says the bandpass generator is an fir-filter. In the first case, I think you're setting a vector to the output of the bandpass generator, and in the second it looks like you've copied the make-bandpass code to set the vector, so you're setting the vector to two different things. -- ___ Cmdist mailing list Cmdist@ccrma.stanford.edu https://cm-mail.stanford.edu/mailman/listinfo/cmdist End of Cmdist Digest, Vol 169, Issue 9 ** ___ Cmdist mailing list Cmdist@ccrma.stanford.edu https://cm-mail.stanford.edu/mailman/listinfo/cmdist
Re: [CM] make-bandpass xcoeffs
make-bandpass is a wrapper around make-fir-filter, returning an fir-filter generator, so mus-xcoeffs does work with it; there's an example in snd-test.scm around line 7706. make-bandpass is not itself a generator; it returns one. If you look at the code in dsp.scm you'll see (define bandpass fir-filter) -- this says the bandpass generator is an fir-filter. In the first case, I think you're setting a vector to the output of the bandpass generator, and in the second it looks like you've copied the make-bandpass code to set the vector, so you're setting the vector to two different things. ___ Cmdist mailing list Cmdist@ccrma.stanford.edu https://cm-mail.stanford.edu/mailman/listinfo/cmdist
[CM] make-bandpass xcoeffs
Hi, It seems make-bandpass doesn't have the mus-xcoeffs feature as general make-filter does, but I was trying to get the numbers to do some comparisons all in one definstrument, define, or let. It seems calling the make-bandpass function as a generator and trying to place the output into a vector is the wrong approach, or maybe I have the inp variable wrong? Also it seems one can use a bandpass or fir-filter call interchangeably? How can I best get accurate xcoeffs numbers in-line, so to speak, from the make-bandpass gen? (define (gentest amp flo1 fhi1 order) (let ((flt1 (make-bandpass (hz->radians flo1) (hz->radians fhi1) order)) ;flow, fhigh, order (v (make-float-vector order)) ) (do ((l 0 (+ l 1))) ((= l order)) (float-vector-set! v l (bandpass flt1 l)) ;or (fir-filter flt1 l) (format #t "~%l: ~F bandpass: ~0,6F v: ~0,6F" l (bandpass flt1 l) (v l)) ) )) (with-sound (:srate 48000 :channels 2 :header-type mus-riff ) (gentest .5 200 400 3 ) ) As a test, I modified make-bandpass from dsp.scm to be able to print the coeffs which makes me believe the float-vector-set! approach above doesn't give the coeffs I was hoping to see. (define (mymake-bandpass flo fhi order) (let* ( (len order) (arrlen (+ 1 (* 2 len))) (arr (make-float-vector arrlen)) ) (do ((i (- len) (+ i 1))) ;-len to +len ((= i len) (make-fir-filter arrlen arr)) ;order xcoeffs (let* ((k (+ i len)) (denom (* pi i)) (num (- (sin (* fhi i)) (sin (* flo i) (set! (arr k) (if (= i 0) (/ (- fhi flo) pi) (* (/ num denom) (+ .54 (* .46 (cos (/ (* i pi) len) (do ((l 0 (+ l 1))) ((= l arrlen)) (format #t "~%l: ~F xcoeffs: ~0,6F" l (arr l)) )) ) (mymake-bandpass (hz->radians 200) (hz->radians 400) 3) Thank you for any suggestions, Jim ___ Cmdist mailing list Cmdist@ccrma.stanford.edu https://cm-mail.stanford.edu/mailman/listinfo/cmdist