From j_hearon at hotmail.com Mon Dec 11 15:26:49 2017 From: j_hearon at hotmail.com (James Hearon) Date: Mon, 11 Dec 2017 23:26:49 +0000 Subject: [CM] generators Message-ID: Hi, I've been using the generators in generators.scm for a while, and enjoy making sound with them, but for the life of me I cannot seem to understand how they work. I'm confused about the lambda part and the use of fm. What is fm doing? I'd be grateful if someone could explain that. Such as in nxycos, It seems like (set! angle (+ angle fm frequency)) is critical, but is (+ angle fm frequency), simply the sum of those variables, such as (+ 3 1 2), > 6? Or does the fm part contribute to the radians value of angle in some other way in that bit of code. I've tried using display and formatted output to look at output values such as x, y, den, angle in radians in lambda, but nothing is really making sense to me yet. I've also experimented with input of different values and viewing the fft outputs to see the frequency in hz, ratio, n, and also angle or phase start in the waveform view of snd. For ex. if I do something like: ... (outa i (* .5 (nxycos gen 0.1)))))) such as adding a value for fm, then the frequency really takes off, so I'm not sure I'm understanding what fm does in the generator or how it's supposed to be used. Thank you, Jim (defgenerator (nxycos :make-wrapper convert-frequency) (frequency 0.0) (ratio 1.0) (n 1) (angle 0.0) fm) (define nxycos (let ((+documentation+ "(make-nxycos frequency (ratio 1.0) (n 1)) creates an nxycos generator. (nxycos gen (fm 0.0)) returns n cosines from frequency spaced by frequency * ratio.")) (lambda* (gen (fm 0.0)) (let-set! gen 'fm fm) (with-let gen (let* ((x angle) (y (* x ratio)) (den (sin (* y 0.5)))) (set! angle (+ angle fm frequency)) (if (< (abs den) nearly-zero) 1.0 (/ (* (cos (+ x (* 0.5 (- n 1) y))) (sin (* 0.5 n y))) (* n den)))))))) ; n=normalization #| (with-sound (:clipped #f :statistics #t :play #t) (let ((gen (make-nxycos 300 1/3 3))) (do ((i 0 (+ i 1))) ((= i 20000)) (outa i (* .5 (nxycos gen)))))) |# -------------- next part -------------- An HTML attachment was scrubbed... URL: From bil at ccrma.Stanford.EDU Mon Dec 11 15:59:49 2017 From: bil at ccrma.Stanford.EDU (bil at ccrma.Stanford.EDU) Date: Mon, 11 Dec 2017 15:59:49 -0800 Subject: [CM] generators In-Reply-To: References: Message-ID: <63cf94df33ae1ea8bad0a7e5d52f568f@ccrma.stanford.edu> The fm part is normally imitating fm in an oscil. If you have (with-sound (:play #t) (let ((gen (make-oscil 300))) (do ((i 0 (+ i 1))) ((= i 20000)) (outa i (* .5 (oscil gen .01)))))) the .01 fm is just a constant added to the phase-increment which changes the (constant) frequency of the oscil. The same thing in nxycos makes the n cosines jump out (if they were fusing before) mostly because you've raised the pitch. Here is fm in nxycos: (with-sound (:play #t) (let ((gen (make-nxycos 300 1/3 3)) (fm (make-oscil 300))) (do ((i 0 (+ i 1))) ((= i 20000)) (outa i (* .5 (nxycos gen (* .01 (oscil fm)))))))) (+ angle fm frequency) is just like (+ 1 2 3). From anders.vinjar at bek.no Mon Dec 18 06:55:32 2017 From: anders.vinjar at bek.no (anders.vinjar at bek.no) Date: Mon, 18 Dec 2017 15:55:32 +0100 Subject: [CM] resample biquad - from 22.05 -> 44.1 ? Message-ID: <876094t7a3.fsf@bek.no> To all the dsp-gurus here. 20 years ago i set up a biquad filter using the tools in CLM. This special filter was used at a SR of 22.05 kHz. It's got that "very special sound" (?), and i'd like to find coefficients for a biquad giving the same response, only with 44.1 kHz. Any suggestions? Thanks, -anders From rbastian at musiques-rb.org Mon Dec 18 09:04:33 2017 From: rbastian at musiques-rb.org (=?UTF-8?B?UmVuw6k=?= Bastian) Date: Mon, 18 Dec 2017 18:04:33 +0100 Subject: [CM] resample biquad - from 22.05 -> 44.1 ? In-Reply-To: <876094t7a3.fsf@bek.no> References: <876094t7a3.fsf@bek.no> Message-ID: <20171218180433.59d00166@lenovo> On Mon, 18 Dec 2017 15:55:32 +0100 anders.vinjar at bek.no wrote: > To all the dsp-gurus here. > > 20 years ago i set up a biquad filter using the tools in CLM. This > special filter was used at a SR of 22.05 kHz. > > It's got that "very special sound" (?), and i'd like to find > coefficients for a biquad giving the same response, only with 44.1 > kHz. > > Any suggestions? > > Thanks, > > -anders The coeffs a1, a2, b0, b1, b2 are functions of SR. You need to change SR in a fundamental file. cf http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt ren? > -- r.bastian www.pythoneon.org From anders.vinjar at bek.no Tue Dec 19 07:21:40 2017 From: anders.vinjar at bek.no (anders.vinjar at bek.no) Date: Tue, 19 Dec 2017 16:21:40 +0100 Subject: [CM] resample biquad - from 22.05 -> 44.1 ? References: <876094t7a3.fsf@bek.no> <20171218180433.59d00166@lenovo> Message-ID: <87shc6g2uz.fsf@bek.no> Hi Ren?. R> cf http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt Thanks for the link above. The explanations seem to achieve coefficients from wanted response. Would you perhaps know how to go the other way, and calculate the amp+phase response (given SR=22050) from the biquad-coefficients i've got? -anders