<< Chapter < Page | Chapter >> Page > |
IIRfilter
filtering function.
Comment on how the signal looks and sounds before and after filtering.How would you expect changes in
to change the filtered output?
Would a value of
be effective for this application?
Why might such a value for
be ill-advised? (Consider the spectrum
of the desired signal around
.)
Download the file nspeech2.mat for the following section.
Oftentimes it is necessary to design a good approximation to an ideal lowpass, highpass or bandpass filter. [link] illustrates the typical characteristics of a real low-pass filter.The frequencies are known as the passband, and the frequencies are the stopband. For any real filter, . The range of frequencies is known as the transition band. The magnitude of the filter response, , is constrained in the passband and stopband by the followingtwo equations
where and are known as the passband and stopband ripple respectively.Most lowpass filter design techniques depend on the specification of these four parameters: , , , and .
To illustrate the selection of these parameters
consider the problem of filtering out backgroundnoise from a speech signal.
[link] shows the magnitude of the DTFT
over a window of such a signal, called nspeech2.Notice that there are two main components
in nspeech2: one at the low frequenciesand one at the high.
The high frequency signal is noise, and it is band limitedto
. The low frequency signal
is speech and it is band limited to
.
Download the file
nspeech2.mat .
and load it into the Matlab workspace.It contains the signal
nspeech2
from
[link] .
Play the
nspeech2
using the
sound
command
and note the quality of the speech and background noise.
In the following sections, we will compute low-pass filters for separating the speech and noiseusing a number of different methods.
Ideally, a low-pass filter with cutoff frequency should have a frequency response of
and a corresponding impulse response of
However, no real filter can have this frequency response because is infinite in duration.
One method for creating a realizable approximation to an ideal filter is totruncate this impulse response outside of .
[link] shows the magnitude response of the lowpass filter with cutoff frequency , with the impulse response truncated to . Notice the oscillatory behavior of the magnitude response nearthe cutoff frequency and the large amount of ripple in the stopband.
Due to the modulation property of the DTFT, the frequency response of the truncated filter is the result of convolving the magnitude response of the ideal filter (a rect) with the DTFT of the truncating window . The DTFT of the truncating window, shown in [link] , is similar to a sinc function since it is the DTFT of a sampledrectangular window. Notice that this DTFT has very large sidelobes, which leadto large stopband ripple in the final filter.
A truncated impulse response is of finite duration, yet the filter is still noncausal.In order to make the FIR filter causal, it must be shifted to the right by units. For a filter of size this shifted and truncated filter is given by
This time shift of units to the right corresponds to multiplying the frequency response by . It does not affect the magnitude responseof the filter, but adds a factor of to the phase response. Such a filter is called linear phase because the phase is a linear function of .
It is interesting to see that the filter formula of [link] is valid for both even and odd. While both of these filters are linear phase,they have different characteristics in the time domain. When is odd, then the value at is sampled at the peak of the function, but when is even, then the two values at and straddle the peak.
To examine the effect of filter size on the frequency
characteristics of the filter,write a Matlab function
LPFtrunc(N)
that computes the truncated and shifted impulse response
of size
for a low pass filter
with a cutoff frequency of
.
For each of the following filter sizes,plot the magnitude of the filter's DTFT in decibels.
Hints:The magnitude of the response in decibels is given by
.
Note that the logcommand in Matlab computes
the natural logarithm.Therefore, use the log10
command to compute decibels.To get an accurate representation of the DTFT
make sure that you compute at least 512 sample points using the command
[X,w]=DTFT(filter_response,512)
.
Now download the noisy speech signal
nspeech2.mat , and
load
it into the Matlab workspace.
Apply the two filters with the above sizes to this signal.Since these are FIR filters,
you can simply convolve them with the audio signal.Listen carefully to the unfiltered and filtered signals, and note
the result. Can you hear a difference between the two filteredsignals? In order to hear the filtered signals better, you may
want to multiply each of them by 2 or 3 before using
sound
.
Notification Switch
Would you like to follow the 'Purdue digital signal processing labs (ece 438)' conversation and receive update notifications?