I know if you’ve made it this far in this Digital Signal Processing course, you might have had a few moments where you’d have thought of jumping out the window. But bear with me and leave the windowing technique to FIR filters. Trust me, it is not as complicated as it seems.
Introduction to Windowing Method
It would seem straightforward to think that to obtain causal FIR filters we can just truncate the infinite Fourier series of the non-causal Infinite Impulse Response (IIR) filter.
However, in practice, the abrupt nature of the truncation causes oscillations to show up on the passband and stopband of the filtered response. This is also known as Gibb’s phenomenon that we had previously discussed.
The Windowing Technique, in which the windowing function is multiplied with the desired frequency response, helps minimize the effects of these oscillations giving us a more desirable output from the truncation of the IIR filter.
But how do you determine the frequency range to ensure you design an effective filter. This is where the windowing technique comes in.
Visualize sending an infinite function into a window to get back a finite part of it that enables us to analyze it with more ease. That is essentially what we are trying to achieve with the Windowing method.
Breaking things down, first, we have to choose a proper frequency-selective IIR filter. This filter usually has a non-causal (has both negative and positive points) and infinite duration impulse response. The specification of the frequency response is usually given in the form of . Here is the waveform of the frequency response.
This frequency response should be converted to unit sample response using the Fourier transform relation shown below
Now, we want to send this waveform,, through a window. Basically, truncate the waveform so that we obtain a causal and linear-phase FIR filter (opposite of what we had before, which basically means finite and probably positive). The filter is truncated to a particular length; this length is also known as the window length. Let’s say it is truncated at the point n. Which means the FIR filter length would be M=n+1. Let the rectangular window be w(n), which is given as
Let the waveform of w(n) look like this:
Now we are combining the two waveforms, and w(n) to obtain h(n), the unit sample response of the FIR filter.for n=0,1,…,M-1;0 otherwise
Hence, the graph of h(n) would look like this which is basically the convolution of and w(n)
For a bit of perspective, let us take the equation of a linear phase FIR filter where the order M is even.
where is the real magnitude function
We are going to start off by minimizing the mean square error between the actual filter and a desired filter. The coefficient of the actual filter is represented by h[k].
where represents the desired response and represents the actual response
The desired filter is also a linear phase FIR filter with the same group delay, let this equation be represented by
where the mean squared error is represented by–(1)
where this represents the shift to the left and applying Discrete-time Fourier Transform(DTFT) to a[k] you will obtain .
The Parseval’s theorem (See properties of DFT) states that the integral of the magnitude squared in the frequency domain is equal to the sum of the magnitude squared in the time domain, hence equation(1) can also be written as–(2)
where a[k] is non-zero for the interval
expanding equation(2) we get
We have to choose a[k] accordingly so that the first term becomes 0, to satisfy that
This is actually equivalent to multiplying infinite response with a windowing function
This is the same as
Here is a graphical representation of the convolution happening in the above equation
The discrete-time Fourier Transform ofwhich is
The Rectangular Window function is shown below
Taking the Discrete-time Fourier Transform of the windowing function we get the graph of This graph by the main lobe having a width of . The first peak side of the lobe goes down to -13dB relative to the main lobe.
So, the convolution of the window function and the desired filter’s magnitude response will give us the graph below
As you can see from the graph, there are many isolations and ripples present in the stopband and the passband. The main lobe of the graph of determines the transition bandwidth and the width of the side lobes determine the passband and stopband ripples.
These ripples are not acceptable for a filter of quality. Too many ripples on the passband and stopband will not let a filter do its function well enough. Typically, other windows are used to trade the main lobe width (transition band) for the sidelobe widths (ripples).
Types of Windows
Advantages and Disadvantages of the Windowing Technique
- It is a simple method to implement to get the desired response.
- It does not have much flexibility as there are an equal amount of passband and stopband ripples present in the response that limits the ability of the designer to make the output more ideal.
- There is minimum computation involved in executing this technique.
- No matter how much we increase the value of m, the maximum magnitude of the ripple is fixed (except when using the Kaiser Window.)
- Due to the convolution of the desired frequency response and the spectrum of the windowing function, it is not possible to find out the specific values of the passband and the stopband frequencies.
- When the filter order, m is increased this leads to a narrower frequency response in which the smoothing is reduced. This leads to big side lobes that are coupled with a lower transition width which is Gibb’s phenomenon that was previously mentioned. However, the Blackman-Harris Window helps to reduce the effects of Gibb’s phenomenon and keep it to a minimum.
Steps for solving problems using the windowing method
Let us look at how to utilize these functions that we have learned about in a problem. First, let us go through the steps to solving a problem relating to the windowing method of FIR filters.
- The equation can be given directly in the equation
- The value of m can be given and you have to calculate α=(m-1)/2
- The phase delay is given, the value of α, with which you can find out
- This value can be given directly
- The cutoff frequency, can be given with which you have to find
- The sampling frequency, can be given with which you have to find
Now, we find the value of h(n) of the IIR filter response by taking the Inverse Discrete Fourier Transform of
For a Low Pass Filter,
For a High Pass Filter,
You will have to find h(n) for all vales of n based on m
However, when n=α
Hence, the integral term will be cancelled off.
Now, you have to identify the windowing function based on what window you are using as you see from the table. Substitute the values of n into the function to get the coefficients pertaining to the window function. You can form a table similar to the one below for better understanding
|Value of n||Desired Frequency Response, hd(n)||Windowing Function, w(n)||Function after performing Windowing method, h(n)= hd(n). w(n)|
|0||hd(0)||w(0)||h(0)= hd(0). w(0)|
|1||hd(1)||w(1)||h(1)= hd(1). w(1)|
|m-1||hd(m-1)||w(m-1)||h(m-1)= hd(m-1). w(m-1)|
Now, we have to find the final equation after the windowing technique has been applied. To identify which of the values from the table above should be included, you need to solve this equation and substitute the respective values from the table above:
Simplifying and solving this equation will give you the final transfer function
We are not done just yet, we have to transform this final equation using the z-transform into the 'z' domain.
Example using rectangular window
Given the frequency specifications as follows and the information that we are using a rectangular window, find the truncated filter response
Taking into account the limits we can graph the frequency like the one shown below
Drawing the waveform, we understand it is a low pass filter as it allows the low-frequency range to pass.
Now apply inverse discrete transform while changing the limits respectively,
Outside the limits the expressions tend to 0 cancelling of those terms leaving us with
Using the formula
This value is an infinite function
Now, in the question we are also given that the windowing function is as shown below
Therefore, multiplying the windowing function and the unit sample response, we get the truncated filter response as
Transforming this into the 'z'-plane, we get
So, hope you understand what really is the whole deal with this rectangular window. But, there is more to it. As mentioned, above there are several types of filters that are used to get an optimum response from the filter. The rectangular filter does not do enough as mentioned, it causes many ripples in the passband and stopband.
Also while using the rectangular window, remember how infinite is turned to finite, unfortunately, some information may be lost along with this process as well because the convolution of the two functions may lead to the flattening of the waveform.
This flattening of the waveform can be reduced by increasing the value of M as will get narrower. These discrepancies lead to large side lobes which bring about the ringing effect in the FIR filter and make it inaccurate.
Now hold up, what is this ringing effect? No, it is not the bells you hear when you know you are in trouble during an exam. In fact, it is called Gibb’s phenomenon. It is just a fancy name for the annoying distortions around sharp edges in photos and videos. To avoid this ringing effect we have the other window types that we previously mentioned.
Let us look at a problem where one of the other windowing functions are used so you can understand how to implement them when the window function is not just simply equal to 1.
Example using Hamming window
Design a FIR Filter for the given specification by using a hamming window.
Using the formuals --(3)
From 3 we can deduce that α=3
For a hamming window, we know the function is
n=0 to 6 as m=7 and equation becomes 0 when α=3
simplifying h(3), we realise we get an indeterminate value
Hence, applying the L'Hopital Rule
we can deduce
Figure out the magnitude response--(4)
We have calculated for n=3,
it is time to find h(n) for n=0,1,2,4,5,6
Hence, the values will be symmetric
Note: Make sure your calculator is in radian mode while doing these calculations.
Now, that we have the values for n=0 to 6 , we can substitute them back into the equation (4) to get
and your final equation
Transforming this to the z-plane, we have the final transfer function
This article equips you with all the fundamental knowledge required to solve windowing problems on your own. To get a better hang of it, go ahead and solve some problems.