How do you create an impulse response to create a brickwall FIR filter?

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

How do you create an impulse to create a brickwall FIR filter?

I need to create a impulse to isolate a small band of frequencies. How do you go about creating that impulse for a convolution?

Post

google "sinc function" and have a look at (impulse) windowing functions.
Fabien from Tokyo Dawn Records

Check out my audio processors over at the Tokyo Dawn Labs!

Post

Yes, the Sinc Function and convolution. The length of the sinc impulse detemines the quality.

Post

k thank you!

Post

camsr wrote:Yes, the Sinc Function and convolution. The length of the sinc impulse detemines the quality.
Well it's not quite that simple.

Longer filter will get you a sharper transition, but it's mostly the window function used that sets the general shape (final attenuation and strength of the side-bands). Also windows that give you better attenuation also typically widen the transition, so what you probably want to do is first pick a window with a shape (in frequency domain) that works for your purposes, then adjust the length of the filter to control the transition width.

In other words, if the filter isn't sharp enough, then yeah, increasing the filter length will make it sharper. But if it's not filtering strongly enough (further away from the transition), then typically it's a better idea to choose a better window first. Similarly the other way, if you'd rather trade a bit worse stop-band performance for a sharper transition with a shorter filter, choosing another window is probably what you want.

Post

So how does a rectangular window outperform/underperform other types here?

Post

camsr wrote:So how does a rectangular window outperform/underperform other types here?
See http://en.wikipedia.org/wiki/Window_function

If I'm not mistaken, essentially any other window will have a wider main lobe, so result in more "blurring" of the response, which makes rectangular ideal(?) in terms of frequency resolution. On the other hand, among the practical windows, rectangular has the highest "side-lobes" (with the first one down some -12dB or so) and they don't really decay that fast either, so it's very poor in terms of attenuation and there is a lot of "ripple" in the response.

In practice, for audio use pretty much anything is better than rectangular. Even the commonly suggested Hann and Hamming windows place too much emphasis on narrow transition though. This is obviously a bit of a matter of opinion, but as a rule of thumb, you'd probably want to start with side-lobes down by at least around 60dB and ideally about twice that (depends a bit on application though).

So for very short filters, I'd generally start by trying Blackman (simple 2 term cosine window, see the Wikipedia page). If you can spare a few extra taps (or accept some extra transition; I'd argue that most of the time this is the case), then try Nuttall instead (also simple, 3 term cosine), that's what I usually use as my default (slightly higher first lobes compared to Blackman-Nuttall, but has the advantage of faster decay further away from transition which is useful for some applications).

Nuttall (and similar) is audibly pretty transparent in most cases, but if you're aiming for truly transparent quality, then some people here have argued for windows with even more attenuation. IIRC r8brain at least had some custom design, but I can't remember the details so see the source if you're interested.

Beyond the simple cosine-windows, if you don't mind a slightly more complex formulas then the (fairly popular) Kaiser window (approximating DPSS, which maximizes energy in main-lobe, though I'm not quite sure why that would be useful for general audio) will let you set a custom trade-off between side-lobes and main-lobe width, while Dolph–Chebyshev can give you all the side-lobes at the same level (so you get a sort of "min-max" window, which unfortunately does not mean your final filter will be min-max optimal).

tl;dr?

Well, the short version: rectangular sucks for most purposes. I'd try Nuttall as default and if you're totally convinced that it loses too much transition width, then Blackman. If you're a control-freak, then Kaiser is the simple approach for having a directly adjustable tuning parameter.

PS. However.. it DOES depend a bit on application; the above covers most situations where I would personally use windowing (whether for filter synthesis or signal analysis), but it's entirely possible that there are situations where none of this advice is useful, you don't care about side-lobes strength, and the selectivity of the rectangular is exactly what you need.

The images of window spectra on Wikipedia page are very helpful and essentially show you the ripple in the final designs. When you add more taps, you mostly just scale the width of the x-axis so the features become more concentrated to certain frequencies, but you only get extra attenuation where there is decay in the window response and only as fast (move away from transition) as the window response decays.

Post

Finally, I'd like to add that "Hann" window, while not terribly useful in practice, is indeed educationally useful and worth implementing as the first-step replacement for rectangle. Once you have that working (aligned correctly and such), it's very simple to add a few extra terms for higher order cosine-windows. :)

Post

Wasn't too long at all, thanks. Your advice is always appreciated (because it's good) :)
Refresh my memory, what's this chart depicting?
Image

Post

camsr wrote:So how does a rectangular window outperform/underperform other types here?
It results in the steepest transition band. All other windows trade steepness with passband flatness and/or stopband flatness.

Better or worse fully depends on the application.

I found that parametric windows (Kayser-Bessel, Dolf-Chebychev) to replace all other window types in practice.

The Sinc is an optimal frequency domain filter (in the sense that it has excellent frequency splitting abilities).

It's not that great in the time-domain, since it comes with pretty heavy ripples in the step response (as long as it hasn't been windowed to "death", i.e. as long it doesn't look like a gaussian).
Fabien from Tokyo Dawn Records

Check out my audio processors over at the Tokyo Dawn Labs!

Post

this has been helpful, thank you!

Post Reply

Return to “DSP and Plugin Development”