Welcome back! Last time we took a look at the various types of IIR filters, what makes them different, and how to use each type. In this tutorial we are going to shift focus from IIR to FIR. Don't know the difference? Fret not! We are going to look at just what a FIR filter is, how they differ from IIR, and how to use them. Ready? Read on!
If you read the previous article, you probably have a decent guess as to what FIR even stands for. Even if you are new to the series, take a stab at it! Ready?
Finite Impulse Response. Alright, so maybe that is not very exciting, but they are very interesting filters.
While Infinite Impulse Response (IIR) filters are based on the idea of a never ending (analog) filter, FIR do in fact have an ending. Why does this matter? Because they cannot exist in the analog domain! (At least not easily.) This makes FIR filters for the most part completely digital.
The properties of a FIR are as follows:
- Impulse response has a finite duration.
- The impulse response will settle at zero.
- They do not require feedback.
- They are always stable (don't act oddly at extreme cut off frequencies).
- They are easily converted to linear phase.
Wait, what was that last part? Linear phase?
The biggest advantage of an FIR to an audio engineer is the idea of linear phase. The more we push an IIR filter, the more of a phase shift we introduce. While small amounts may not be noticeable, large amounts can smear transients and reduce the clarity of a recording.
A linear phase filter, however, will not smear the transients. Instead, a linear phase filter simply creates equal delay across all frequencies in place of a phase shift. Almost every single linear phase filter you have every used is a FIR filter.
As with everything else in life, there are drawbacks to using a FIR filter. Here are the primary problems:
- Significant delay when used in linear phase operations
- Can be difficult to achieve a specific frequency response and thus...
- Has the potential to cost more memory/CPU usage
So picking a FIR over an IIR (or vice versa) should be decided on a case-by-case basis. Furthermore, just as we had different IIR filters, we can also have variations on FIR filters as well.
No, not the operating system! Windows in FIR filter design are the way in which we determine where exactly the finite point in a FIR is. Or should we say, where we want the finite point to be.
Remember up above where we said the FIR filters are not very good at achieving specific frequency response? Well, IIR filters are good at this job, but we want them to be finite. Since they never truly settle at zero, we need to make them, by truncating the impulse. Voila zero! This act of truncating is called windowing.
Typically, FIR filters are based off the Ideal Filter (see the previous article), and are then truncated to have a finite impulse response. However, there is more than one way to window an impulse.
Now that we know what windowing is, let's take a look at the various windows available to see how they affect the ideal filter.
The rectangular window (sometimes called a boxcar) is by far the most basic windowing approach available. Why? Because it evenly weights all values inside the rectangle (the window) and cuts off everything outside it.
Sounds great right? Well unfortunately the attenuation is not very good. Add in the overshoot and ringing and it can sound just ugly.
So why use it? Because they have the sharpest transition band and highly selective of particular frequencies.
- Poor attenuation (usually only 20dB/octave)
- Causes ringing and overshoot on transients
- Has the steepest transition between the pass band and stop band
- Can easily select specific frequencies
- Best used when you need linear phase removal of very specific frequencies
- Excellent for detecting transients
Hanning and Hamming
These windows are used when you need a fair bit of selectivity. The difference between the two is that the Hanning reaches zero while the Hamming doesn't quite. The Hamming is a little more selective than its counterpart, while the leakage is lower on the Hanning. The only major drawback is that both windows have a tendency to smear transients.
- Moderate attenuation and selectivity makes it common in telecommunications.
- Works as general linear phase tone shaper.
- Performs better on smoother sources that do not include sharp transients, such as bass.
If there was a general purpose window, it would probably be the Blackman-Harris. It offers good attenuation and good selectivity. Sure, it's not as surgical as a rectangle, or even a Hanning, but it can still focus in well enough for audio purposes.
- Common as a linear phase EQ tone control
- Good attenuation characteristics
- Not highly surgical but not too broad either
- Can handle a wide variety of sources well (smooth to highly transient)
Notes on Lobes
If you noticed, a FIR filters frequency response has these very odd and very ugly lobes that occur. These are simply artifacts of the FIR filter and cannot be avoided. Different windows produce different sizes and intensities of the lobes, but they will still persist.
When determining how much attenuation the window can achieve, we measure from the tops of the lobes. Most EQs draw this line and not the lobes themselves, hence why you do not see them inside your plugin!
As you can see, FIR filters, while used for the same purposes as IIR, are made in a much different way. While we covered the main window functions here, there are a multitude of available options to shape the impulse response, each with their own benefits and drawbacks. There are even different methods other than the windows to make an FIR, but for audio they are a little too esoteric to be seen.
The big draw for us as audio engineers is that almost every FIR we use is made to be linear phase. This of course comes with the drawback of delay. However, unless you are mixing live, you should easily be able to live with delay.
Simply make sure you choose a window that fits your needs. Need transient accuracy above all else? Maybe for a custom de-esser? Go rectangle. Need some notch filtering? Hanning and Hamming are good bets. Just general tone control? Roll with a Blackman-Harris.
So go out their and choose the FIR that is right for you! Thanks for reading.
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post