This looks pretty good to me, and I like the amplitude adjustment g[n] term :)

Depending on the situation you may want to modulate the frequency of the oscillator pretty fast, so it can help to use a tan approximation function and then a division and a few other operations to get your cos (w) and sin (w) rotation terms from that single approximation. I've called the rotation terms g0 and g1, and c and s are the output cos and sin quadrature oscillator values init: c = cos(2*pi*startphase) s = sin(2*pi*startphase) set frequency: g0 = cos(2*pi*frequency/samplerate) g1 = sin(2*pi*frequency/samplerate) or g = tan(pi*frequency/samplerate); gg = 2/(1 + g*g) g0 = gg-1 g1 = g*gg tick: t0 = g0*c - g1*s t1 = g1*c + g0*s c = t0 s = t1 On Thu, 21 Feb 2019 at 06:28, robert bristow-johnson < r...@audioimagination.com> wrote: > i did that wrong. i meant to say: > > x[n] = a[n] + j*b[n] = g[n-1]*exp(j*w[n]) * x[n-1] > > this is the same as > > a[n] = g[n-1]*cos(w[n])*a[n-1] - g[n-1]*sin(w[n])*b[n-1] > > b[n] = g[n-1]*sin(w[n])*a[n-1] + g[n-1]*cos(w[n])*b[n-1] > > and adjust the gain g[n] so that |x[n]|^2 = a[n]^2 + b[n]^2 converges to > the desired amplitude squared (let's say that we want that to be 1). you > can adjust the gain slowly with: > > g[n] = 3/2 - (a[n]^2 + b[n]^2)/2 > > that will keep the amplitude sqrt(a[n]^2 + b[n]^2) stably at 1 even as > w[n] varies. > > i've done this before (when i wanted a quadrature sinusoid) for doing > frequency offset shifting (not pitch shifting). worked pretty good. > > -- > > > r b-j r...@audioimagination.com > > "Imagination is more important than knowledge." > > > > > A very simple oscillator recipe is: > > > > a(t+1) = C*a(t) - S*b(t) > > b(t+1) = S*a(t) + C*b(t) > > > > Where C=cos(w), S=sin(w), w being the angular frequency. a and b are your > > two state variables that are updated every sample clock, either of which > > you can use as your output. > > > > There won't be any phase or amplitude discontinuity when you change C and > > S. However, it's not stable as is, so you periodically have to make an > > adjustment to make sure that a^2 + b^2 = 1. > > > > -Ethan > > > > > > On Wed, Feb 20, 2019 at 12:26 PM Ian Esten <i...@ianesten.com> wrote: > > > >> The problem you are experiencing is caused by the fact that after > changing > >> the filter coefficients, the state of the filter produces something > >> different to the current output. There are several ways to solve the > >> problem: > >> - The time varying bilinear transform: > >> http://www.aes.org/e-lib/browse.cfm?elib=18490 > >> - Every time you modify the filter coefficients, modify the state of the > >> filter so that it will produce the output you are expecting. Easy to do. > >> > >> I will also add that some filter structures are less prone to problems > >> like this. I used a lattice filter structure to allow audio rate > modulation > >> of a biquad without any amplitude problems. I have no idea how it would > >> work for using the filter as an oscillator. > >> > >> Best, > >> Ian > >> > >> On Wed, Feb 20, 2019 at 9:07 AM Dario Sanfilippo < > >> sanfilippo.da...@gmail.com> wrote: > >> > >>> Hello, list. > >>> > >>> I'm currently working with digital resonators for sinusoidal > oscillators > >>> and I was wondering if you have worked with some design which allows > for > >>> frequency variations without discontinuities in phase or amplitude. > >>> > >>> Thank you so much for your help. > >>> > >>> Dario > > > > > > > > > _______________________________________________ > dupswapdrop: music-dsp mailing list > music-dsp@music.columbia.edu > https://lists.columbia.edu/mailman/listinfo/music-dsp

_______________________________________________ dupswapdrop: music-dsp mailing list music-dsp@music.columbia.edu https://lists.columbia.edu/mailman/listinfo/music-dsp