How to Build a Notch

DSP, Plug-in and Host development discussion.
User avatar
KVRian
979 posts since 25 Sep, 2014 from Specific Northwest

Post Sat Jun 12, 2021 11:42 pm

For the life of me, I just can't seem to do it!

My Assets:

cutoff
resonance
input
pole1
pole2

I've got LP, HP and BP covered, but no matter what I do, my notch just isn't very notchy. I only get half of the notch I should and the resonance has to be set just so. Very annoying!

So, given the above assets, how do I calculate a notch filter?

KVRAF
6400 posts since 12 Feb, 2006 from Helsinki, Finland

Post Sun Jun 13, 2021 1:12 am

syntonica wrote:
Sat Jun 12, 2021 11:42 pm
I've got LP, HP and BP covered, but no matter what I do, my notch just isn't very notchy. I only get half of the notch I should and the resonance has to be set just so. Very annoying!
It would help a bit if you could explain what type of a filter you're trying to use, but essentially you get a two-pole notch by placing the zeroes as a complex conjugate pair at the positive and negative cutoff frequencies [edit: to be specific, this means the same frequency as the poles].

For analog/BLT filters (eg. the "zdf-svf") where you have all of HP/BP/LP available simultaneously the easy way to do this is to just mix the HP and LP in equal amounts: in terms of normalized cutoff we have the zeroes placed at +i and -i which gives us numerator terms (s-i)*(s+i)=s^2+1.

Now LP transfer function (with both zeroes at infinity) is 1/(s^2+s/Q+1) and HP (with both zeroes at 0) is s^2/(s^2+s/Q+1), then sum gives the notch as (s^2+1)/(s^2+s/Q+1). We can then substitute a
(typically frequency warped) trapezoidal integrator for 1/s either in the filter structure or the transfer function, which gives us the BLT which preserves the shape of the frequency response except for the frequency warping. Now, one of the reasons the ZDF-SVF in particular is so nice is that with HP/BP/LP directly available you can literally take an analog transfer function in the form (a2*s^2+a1*s+a0)/(s^2+s/Q+1) and just use a2,a1,a0 as output (or input if you transpose the filter) mixing coefficients directly.

If you already have some other filter structure, but you don't know the exact transfer functions for the available outputs and they don't exact match the expected LP/BP/HP, then things get a bit trickier and what you probably need to do is solve for the available transfer functions from the statespace and then solve the correct mixing from these (assuming the structure is general enough). This is just some linear algebra, but can be a bit tedious to do manually.

If you clarify your problem a bit, I can try to help you further.
Preferred pronouns would be "it/it" because according to this country, I'm a piece of human trash.

KVRian
1245 posts since 9 Jan, 2006

Post Sun Jun 13, 2021 7:48 am

syntonica wrote:
Sat Jun 12, 2021 11:42 pm
For the life of me, I just can't seem to do it!

My Assets:

cutoff
resonance
input
pole1
pole2
You will also need zeros at the notch frequency

User avatar
KVRian

Topic Starter

979 posts since 25 Sep, 2014 from Specific Northwest

Post Sun Jun 13, 2021 8:27 am

Thanks for your replies, but you're making it a little more complicated than necessary. Essentially:

LP = output
HP = input- LP
BP = pole1 - pole 2
BR = ???

There's a little more to it to fine tune these with the resonance value, but there must be a simple formula for the notch that for the life of me, I'm missing. I've got a basic SVF filter in place right now, but I don't like the sound of it, although the notch is nice and notchy! Unfortunately, the resonance is really bad...

KVRAF
6400 posts since 12 Feb, 2006 from Helsinki, Finland

Post Sun Jun 13, 2021 8:55 am

syntonica wrote:
Sun Jun 13, 2021 8:27 am
Thanks for your replies, but you're making it a little more complicated than necessary. Essentially:

LP = output
HP = input- LP
BP = pole1 - pole 2
BR = ???
BR = LP + HP. If this doesn't work, then your LP and HP responses are not those of BLT.
There's a little more to it to fine tune these with the resonance value, but there must be a simple formula for the notch that for the life of me, I'm missing. I've got a basic SVF filter in place right now, but I don't like the sound of it, although the notch is nice and notchy! Unfortunately, the resonance is really bad...
With a correct notch, the only thing resonance does is change the bandwidth of the notch.

If (when) a trapezoidal SVF works, then what's the other filter you are trying to use? If it gives you proper BLT LP and HP then the formula still works, but if it gives you something random then you'll have to do a bunch of linear algebra.
Preferred pronouns would be "it/it" because according to this country, I'm a piece of human trash.

User avatar
KVRian

Topic Starter

979 posts since 25 Sep, 2014 from Specific Northwest

Post Sun Jun 13, 2021 9:17 am

mystran wrote:
Sun Jun 13, 2021 8:55 am
syntonica wrote:
Sun Jun 13, 2021 8:27 am
Thanks for your replies, but you're making it a little more complicated than necessary. Essentially:

LP = output
HP = input- LP
BP = pole1 - pole 2
BR = ???
BR = LP + HP. If this doesn't work, then your LP and HP responses are not those of BLT.
Unfortunately, that's what I thought, and BR = LP + HP = input. There's a resonance component to the HP that I don't recall (i'm on my iPad, not my programming computer), but it's it's input minus the resonance bit, I'm calling it a day! :lol: I've definitely been staring at filters too long.

My filter is definitely not a BLT, it uses no coefficients. The one I have in place right now is Andy Cytomic's SVF filter. I may just have to pack it all in and design a new filter... (oh, my headache is beginning just thinking about it... :bang: )

KVRAF
6400 posts since 12 Feb, 2006 from Helsinki, Finland

Post Sun Jun 13, 2021 11:42 am

syntonica wrote:
Sun Jun 13, 2021 8:27 am
Thanks for your replies, but you're making it a little more complicated than necessary.
I want to quote this because... I'm really NOT making it more complicated than necessary and it actually isn't all that complicated, but you really can't avoid math if you want predictable responses.
Preferred pronouns would be "it/it" because according to this country, I'm a piece of human trash.

User avatar
KVRian

Topic Starter

979 posts since 25 Sep, 2014 from Specific Northwest

Post Sun Jun 13, 2021 12:05 pm

mystran wrote:
Sun Jun 13, 2021 11:42 am
syntonica wrote:
Sun Jun 13, 2021 8:27 am
Thanks for your replies, but you're making it a little more complicated than necessary.
I want to quote this because... I'm really NOT making it more complicated than necessary and it actually isn't all that complicated, but you really can't avoid math if you want predictable responses.
Sorry that I wasn't more clear in my original post. I think in shorthand and always forget nobody else understands it. I was just looking for N = L + H, or some variation thereof, to make sure I want totally off the plot.

To me, I see infinite series and Euler and imaginary numbers and my first response is to panic and hide. So, I avoid math wherever possible, despite having been quite good at it once upon a time.

Anyway, it wasn't my intention to offend or dismiss you, and I'm sorry if I came off that way. You are probably the most helpful person in this sub-forum, and for that, I am most grateful and indebted to you for your time and patience.

KVRAF
6400 posts since 12 Feb, 2006 from Helsinki, Finland

Post Sun Jun 13, 2021 2:01 pm

syntonica wrote:
Sun Jun 13, 2021 12:05 pm
Anyway, it wasn't my intention to offend or dismiss you, and I'm sorry if I came off that way.
Wait.. what?!?

I did not sense any attempt at any kind of offence, nor did I intend any offence myself. I am not big on this whole getting offended on the internet thing that's getting a bit ridiculous. I was just trying to make the point that notch filters happen to be one of those where it really won't work well unless the math is exactly right, because you really need the zeroes at the unit circle in order to have a deep notch and you really need the frequency to match that of the poles, so that your DC/Nyquist limit gains are equal (ie. so you don't get a shelf of sorts).
Preferred pronouns would be "it/it" because according to this country, I'm a piece of human trash.

User avatar
KVRian

Topic Starter

979 posts since 25 Sep, 2014 from Specific Northwest

Post Sun Jun 13, 2021 2:20 pm

mystran wrote:
Sun Jun 13, 2021 2:01 pm
syntonica wrote:
Sun Jun 13, 2021 12:05 pm
Anyway, it wasn't my intention to offend or dismiss you, and I'm sorry if I came off that way.
I did not sense any attempt at any kind of offence, nor did I intend any offence myself.
No worries then. :hug: I wasn't offended, either. I'm on the autism spectrum and face-to-face human relations are hard enough for me. Internet interactions give me even fewer cues to go by.

I got my filter sorted out for now. I just fixed the resonance so that the notch stays at its widest and deepest. Now I'm off to work on a new, more flexible filter that hopefully sounds even better. The one I have now is akin to a ladder filter, which I prefer over biquads and apparenty SVF filters, although SVF certainly leaves room for me to explore further.

KVRAF
6400 posts since 12 Feb, 2006 from Helsinki, Finland

Post Sun Jun 13, 2021 3:24 pm

syntonica wrote:
Sun Jun 13, 2021 2:20 pm
I got my filter sorted out for now. I just fixed the resonance so that the notch stays at its widest and deepest. Now I'm off to work on a new, more flexible filter that hopefully sounds even better. The one I have now is akin to a ladder filter, which I prefer over biquads and apparenty SVF filters, although SVF certainly leaves room for me to explore further.
Right.

A variation of the transposed Sallen-Key (see the Art of VA filter design) can be arranged to have non-linear behaviour fairly similar to a ladder (while getting a proper 2-pole resonance by taking a difference of the poles instead of just the second pole), but when you do (with a trapezoidal "zdf" implementation) it gives you proper LP=1/(s^2+s/Q+1) and BP=(s/Q)/(s^2+s/Q+1) and with input=(s^2+s/Q+1)/(s^2+s/Q+1) we can then derive HP as input-BP-LP = s^2/(s^2+s/Q+1) or notch directly as input-BP=(s^2+1)/(s^2+s/Q+1). This is probably what I'd suggest for a general 2-pole if SVF is not your thing.

edit: This is assuming "normalized" BP with peak gain = 1, but if you have a filter where the bandpass has a gain of Q instead (ie. increasing the resonance increases the peak gain) then you can always divide that out.
Preferred pronouns would be "it/it" because according to this country, I'm a piece of human trash.

User avatar
KVRian

Topic Starter

979 posts since 25 Sep, 2014 from Specific Northwest

Post Sat Jun 19, 2021 10:39 am

Just to report my final results after a few nights good sleep. To make the Notch, I used:

Code: Select all

input - resonance * (pole1 - pole2)
and removed the resonance component from the pole1 calculation. Now, it's pretty darn notchy and the rez knob works as expected. No more goofy kludge. Yay!

Return to “DSP and Plug-in Development”