How to Build a Notch
 KVRian
 979 posts since 25 Sep, 2014 from Specific Northwest
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?
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
It would help a bit if you could explain what type of a filter you're trying to use, but essentially you get a twopole 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 "zdfsvf") 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 (si)*(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 ZDFSVF 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
 979 posts since 25 Sep, 2014 from Specific Northwest
Topic Starter
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...
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
BR = LP + HP. If this doesn't work, then your LP and HP responses are not those of BLT.
With a correct notch, the only thing resonance does is change the bandwidth of the notch.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...
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.
 KVRian
 979 posts since 25 Sep, 2014 from Specific Northwest
Topic Starter
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! 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... )

 KVRAF
 6400 posts since 12 Feb, 2006 from Helsinki, Finland
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.
 KVRian
 979 posts since 25 Sep, 2014 from Specific Northwest
Topic Starter
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 subforum, 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
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.
 KVRian
 979 posts since 25 Sep, 2014 from Specific Northwest
Topic Starter
No worries then. I wasn't offended, either. I'm on the autism spectrum and facetoface 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
Right.syntonica wrote: ↑Sun Jun 13, 2021 2:20 pmI 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.
A variation of the transposed SallenKey (see the Art of VA filter design) can be arranged to have nonlinear behaviour fairly similar to a ladder (while getting a proper 2pole 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 inputBPLP = s^2/(s^2+s/Q+1) or notch directly as inputBP=(s^2+1)/(s^2+s/Q+1). This is probably what I'd suggest for a general 2pole 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.
 KVRian
 979 posts since 25 Sep, 2014 from Specific Northwest
Topic Starter
Just to report my final results after a few nights good sleep. To make the Notch, I used:
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!
Code: Select all
input  resonance * (pole1  pole2)