Biquad Resonator

I’m trying to do a simple resonator as a biquad filter. The thing works in principle, however when changing sample rate, the gain changes vastly.

The thing was derived as a direkt zero pole diagram with zeros on zero and poles at

radius * e^(+-i*omega)

with radius < 1.
The filter coefficients then read

m_b0 = 1
m_b1 = 0;
m_b2 = 0;

m_a1 = -2 * m_radius * cos(2 * M_PI * m_freq / m_samplerate);
m_a2 = m_radius * m_radius;

m_a0 is normalized as 1.

What am I doing wrong? If these coefficients are right then the biquad implementation is probably wrong, but I can’t find an error in neither.

not sure about your issue regarding the sample rate, but this page and its subsections explain the gain variations when varying the resonator’s freq (and how to compensate them) :

1 Like

Hmmm while looking at your link, I realized that the two might be related. When changing the sample rate to double, I will only use the first half of the z-domain unit circle as the filter range. When the filter is not gain compensated (it is not) then I will get different gains.

But this begs the question: Will changing the samplerate change the frequency response of every digital filter ever? Since you basically have the same problem.

Ok I implemented the gain compensation and it helped a lot, the gain variance has gone from ripping my ears appart to slightly notable.

I think can fix the rest by introducing an empirically designed function which changes gain depending on the sample rate set.
Tanks! :slight_smile: