Filter kernel equation for 6dB/oct linear phase low pass?

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

I need a 6dB/oct low pass filter that has zero phase shift (linear phase). I am familiar with linear phase FIR filters but don't know how to generate a kernel other than "sinc" ("brickwall" filter). Can 6dB/oct be generated from sinc by use of a special window or does it require a special kernel as well?
Last edited by Fender19 on Sun Oct 11, 2020 4:04 pm, edited 1 time in total.

Post

Fender19 wrote: Mon Apr 08, 2019 6:09 pm I have a need for a 6dB/oct low pass filter that has zero phase shift (linear phase). I am familiar with linear phase FIR filters but don't know how to generate a kernel other than "sinc" ("brickwall" filter). Can 6dB/oct be generated from sinc by use of a special window or does it require a special kernel as well?

Post

You can build a mirrored version of the impulse response of the classical 1-pole filter which looks as result like f(x)=Math.exp(-c*Math.abs(x))*w, x=-1..1 with c constant derived from the wanted cutoff frequency, w correction factor for dc~1 - the whole thing should be windowed to reduce ripple

Post

Image

Post

chi cubed wrote: Mon Apr 08, 2019 11:18 pm Image
Awesome! Thank you!

Post

chi cubed wrote: Mon Apr 08, 2019 11:10 pm You can build a mirrored version of the impulse response of the classical 1-pole filter which looks as result like f(x)=Math.exp(-c*Math.abs(x))*w, x=-1..1 with c constant derived from the wanted cutoff frequency, w correction factor for dc~1 - the whole thing should be windowed to reduce ripple
Hmmm, very quickly off the top of my head that seems to me to give a 12dB/oct:
g(t)=h(t)+h(-t)
G(w)=H(w)+H(-w)=1/(1+jw)+1/(1-jw)=2/(1+w^2)
But maybe I'm missing something.

Post

Yeah, it will. This is equivalent to the old "get zero phase by filtering twice; once forwards, once backwards" trick

Post

I suppose you could design a 6db/octave FIR a few different ways. You could brute force it, say, generate a huge (not sure what would be adequate, perhaps equivalent to 10000 point impulse response?) frequency domain kernel with the desired frequency and phase. Take the inverse FFT and window to the desired length. Or use a smarter method like Parks-Mcclellan. Probably there are other methods, I'm not that familiar with FIR design.

Post

OK then - this may be completely naive - but if mirroring the "exp" function causes the filter slope to double (12dB/oct vs desired 6dB/oct) what if I used the square root of the exp function as the filter kernel?

There are many EQ plugins out there today with all the standard filter curves (low pass, high pass, bell, shelving, etc.) that, with a click of a button, switch from minimum phase to linear phase - and their slopes don't double in linear phase mode. I just assumed there were some "cookbook" filter kernels and methods floating around for this. If not, how is it being done?

Post

if mirroring the "exp" function causes the filter slope to double (12dB/oct vs desired 6dB/oct) what if I used the square root of the exp function as the filter kernel?
i'm a bit skeptical about that mirroring being equivalent to forward/backward (aka bidirectional) filtering. bidirectional filtering actually convolves the impulse response with a flipped version of itself - which is different from just mirroring it, if i'm not mistaken. the square-root thing - i think, that *may* (or may not) work, if you do it in the frequency domain.
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

I'm a bit confused here. Wouldn't it be a totally straightforward thing to take the desired response, e.g. H(w)=1/(1+jw) for the 6dB filter, kill the phase: H(w)=1/sqrt(1+w^2) thereby making it linear phase and take inverse Fourier transform, which then can be windowed to obtain the linear phase filter kernel. Okay, maybe not 100% straightforward due to aliasing, don't have much experience with sampling impulse responses ;) but IIRC for lowpass filters that is hardly an issue. Of course inverse Fourier transform can be taken in discrete time domain instead, thereby avoiding the aliasing issue (maybe save for windowing), but then we won't be able to easily adjust the cutoff...

Post

Music Engineer wrote: Thu Apr 11, 2019 6:34 pm
if mirroring the "exp" function causes the filter slope to double (12dB/oct vs desired 6dB/oct) what if I used the square root of the exp function as the filter kernel?
i'm a bit skeptical about that mirroring being equivalent to forward/backward (aka bidirectional) filtering.
It's not equivalent to a cascade of forward/backward filtering, but it IS equivalent to running forward and backward in parallel and adding the results together. In other words: you can't treat it as a product of the one-pole transfer functions, but you CAN treat it as a sum. Since the poles are distinct, this still gives you a second order transfer function.

You actually see this type of filter design sometimes suggested for image processing, eg. for IIR gaussian filters and similar. Besides possible parallel processing opportunities, one advantage over cascades is that it simplifies the boundary handling, since you don't need to worry about the response of the second stage to the tail of the first stage that continues to decay outside the image bounds.. While you can also analytically compute the initial state of the second stage (in a cascade) from the final state of the first stage as it hits the image bounds (at least for the "constant color outside bounds" case), this can get a bit messy depending on what your filters look like.

Post

aha! yes! that makes sense
you can also analytically compute the initial state of the second stage
i'd probably be lazy and just record the first filter's "ring out" and use it (reversed) to "warm up" the second filter. i guess that counts as numerically computing the initial state. good to know that it's also possible analytically though. :D
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

Music Engineer wrote: Thu Apr 11, 2019 7:42 pm aha! yes! that makes sense
you can also analytically compute the initial state of the second stage
i'd probably be lazy and just record the first filter's "ring out" and use it (reversed) to "warm up" the second filter. i guess that counts as numerically computing the initial state. good to know that it's also possible analytically though. :D
The thing is, the main reason you would even want to use an IIR blur in the first place is because the per-pixel cost is essentially constant no matter what the blur radius, which becomes more and more profitable as the blur radius grows larger. The other well-known alternative with this property is a cascade of box blurs (eg. 3x is typically good enough), but that approach does run into some similar boundary handling issues as well (although unlike the IIR case, you can arrange for the "wrong" results to be the same on both sides, which is less of a problem). If you try to numerically handle the IIR tail, then you lose this "constant time" property and for large enough radius you could waste more time handling the "padding" than you spend on actually processing the image itself.

Note that in both cases the "constant time per pixel" pretty much assumes "serial" CPU algorithm (ie. whole thing in 4 passes). If you're working on the GPU, then either IIR or cascaded box blur generally involves O(log N) parallel passes and you might prefer the cascaded box-blur (ie. using summed area tables), since it probably ends up faster in this case.

Post

If you try to numerically handle the IIR tail, then you lose this "constant time" property and for large enough radius you could waste more time handling the "padding" than you spend on actually processing the image itself.
ok - yes - i see. in my typical audio related use cases, i have a filter ringing time that is usually much shorter than the sample to be processed anyway - so the ring-out/warm-up approach was good enough so far. should i ever run into situations where this isn't the case anymore, i may have to do some math homework :scared:
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post Reply

Return to “DSP and Plugin Development”