0% found this document useful (0 votes)
86 views5 pages

Lab 5

This document provides instructions for designing and implementing Butterworth filters to remove noise from an audio signal. It describes filter specifications and the process for designing lowpass Butterworth filters, including calculating the filter order and cutoff frequency based on specifications. Students are asked to design a filter to remove noise from a musical recording, analyze the filtered signal, and discuss the impact of filtering on the sound quality.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views5 pages

Lab 5

This document provides instructions for designing and implementing Butterworth filters to remove noise from an audio signal. It describes filter specifications and the process for designing lowpass Butterworth filters, including calculating the filter order and cutoff frequency based on specifications. Students are asked to design a filter to remove noise from a musical recording, analyze the filtered signal, and discuss the impact of filtering on the sound quality.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Digital Signal Processing

Page 1 of 5
LAB # 5. Filter design

I. OBJECTIVES
By the end of this laboratory assignment, you should be able to:
- Design lowpass Butterworth filters to given specifications.
- Define filter specifications to remove noise from an audio signal.

II. BACKGROUND
Using ideal filters, the frequencies in the passband appear in the output all with the
same gain and having the same time delay while the frequencies in the stopband are
completely eliminated; the bandwidth of the transition from passband to stopband is
infinitely narrow.
Ideal filters are non-causal. This means that all future values of the input signal are
needed to determine the filter output at the current time, and therefore they are not
realizable for practical applications. In this lab, you will learn how to design and
implement LTI filters.

Filter specifications
It is important to have a means for specifying the performance required for the filter
implementation. Once you know how performance is tied to characteristics of the filter
frequency response, you can evaluate the performance trade-offs between different filter
designs. Figure 1 shows the continuous time filter specifications.
The parameter o
1
indicates how much ripple, or variation in gain, you will allow in the
passband; e
p
is the frequency at the edge of the passband, defined as the point where the
passband magnitude is decreasing and crosses through 1-o
1
; o
2
indicates how much
attenuation is required in the stopband; and e
s
is the frequency at the edge of the
stopband, defined to be the point such that gains at all frequencies beyond it in the
stopband are attenuated to o
2
. Note that the gain in the passband, for the purposes of
specifying o
1
and o
2
, is normalized to one. For highpass filters, these parameters are
similarly defined. In the case of bandpass and stopband filters, there are two transition
regions, so two sets of passband and stopband frequencies should be specified.
In general, we would like filters to have very little ripple in the passband, have narrow
transition bandwidth, and have large attenuation in the stopband, the same as ideal filters.
Since achieving the ideal is impossible, a number of different techniques for designing
filters have been developed that emphasize different sets of these objectives. By
designing a filter, we mean determining a transfer function, or equivalently the
system poles, zeros and gain. One of the most common types of filter is called a
Butterworth filter. Butterworth filters are maximally smooth, i.e., no oscillation appears
in the magnitude of the frequency response in either the passband or stopband.
Digital Signal Processing
Page 2 of 5

Figure 1. Definitions for filter specifications.

Butterworth filter design
The smooth frequency response for a Butterworth lowpass filter is achieved by placing
the poles in the semicircular arrangement shown in Figure 2, where N is the number of
poles and the filters order. e
c
is the cut-off frequency, and at this frequency the filters
gain is reduced by 707 . 0 2 1 ~ , or in decibels, -3 dB. Note that all the poles have the
magnitude e
c
, and they are equally spaced with angular spacing between poles of t/N.
By increasing the order of the filter, the slope of the frequency response increases, what
results in a narrower transition band.
Designing a Butterworth filter means selecting a filter order N and cut-off frequency e
c

such that the desired specifications are met. The magnitude of the frequency response for
a Butterworth filter is given by:
( )
N
c
H
2
1
1
|
|
.
|

\
|
+
=
e
e
e (1)
There are three steps to determine the filter order and the cut-off frequency given the
frequency specifications as defined in Figure 1.
1. Find the values for the selectivity factor, k, and the discrimination factor, d, from
the filter specifications using the following expressions:
s
p
k
e
e
= ,
( )
1
1 1
2
2
2
1

o
o
d (2)
Passband Stopband Transition
Digital Signal Processing
Page 3 of 5
2. Determine the order of the filter required to meet the specifications using the
design formula:
( )
( ) k
d
N
10
10
log
log
> (3)
N must be rounded to the next highest integer.
3. Given N, compute e
c
using the following equation:
( ) ( )
N
p
c
2
1
2
1
1 1
=

o
e
e (4)


Figure 2. Fifth order Butterworth filter. Top: poles, bottom: frequency response.

Once you have determined e
c
and N such that the design specifications are satisfied, then
you can determine the pole locations as illustrated in Figure 2. The lowpass filter transfer
function H(s) can be determined from these poles p
k
and the gain G desired for your
application:
Digital Signal Processing
Page 4 of 5
( )
( )( ) ( )
N
p s p s p s
G
s H

=
...
2 1
(5)

III. REFERENCES
1. Stonick, V. and Bradley, K. Labs for Signals and Systems using MATLAB.
International Thompson Publishing. 1996.
2. Kamen, E. W. and Heck, B. S. Fundamentals of Signals and Systems Using the Web
and MATLAB. 3
rd
edition. Prentice Hall 2006.

IV. LAB PREPARATION
1. Design a Butterworth filter that has a passband ripple of -3dB and a stopband
attenuation of -20dB. The passband must reach to 900Hz and the stopband must start
at 1.4 kHz.
a) Determine the order N and the cutoff frequency e
c
.
b) Sketch the poles of the filter in the s-plane.

V. MATERIALS AND METHODS
Procedure:
A sample piece of music is stored in bluesA1.wav. When the same audio signal was
recorded onto a tape, noise was introduced. The resultant signal is in file bluesA2.wav.
1. Import the audio files to MATLAB using the command wavread.
2. Listen to both signals. Note that the sampling frequency is 11025Hz. The high
frequency hiss should be clearly audible in the second signal.
3. Calculate the spectrum of the signals using fft, reorganize the spectra with the
function fftshift.
4. Define a normalized vector of frequencies from -1 to 1 with the same length that the
signals. Use the function linspace. Plot the magnitude of the spectra of the two
signals vs the normalized frequency in the same window (using the command
subplot).
Q1. Identify the noise in the spectrum. What kind of filter do we need in order to remove
that noise? What could be the cutoff frequency?
Digital Signal Processing
Page 5 of 5
The Signal processing Toolbox in MATLAB contains several functions for designing
digital Butterworth filters. Two of them are listed below. These functions can also be
used to design continuous time filters.

BUTTORD: Butterworth filter
order selection.
[N, Wn] = BUTTORD(Wp, Ws,
Rp, Rs)
Returns the order N of the lowest order digital
Butterworth filter that loses no more than Rp dB in
the passband and has at least Rs dB of attenuation
in the stopband.
BUTTER: Butterworth digital and
analog filter design.
[B,A] = BUTTER(N,Wn)
Designs an Nth order lowpass digital Butterworth
filter and returns the filter coefficients in length
N+1 vectors B (numerator) and A (denominator).
The coefficients are listed in descending powers of
z. The cutoff frequency Wn must be normalized to
1 rad, i.e., 0.0 < Wn < 1.0, with 1.0 corresponding
to half the sample rate.
5. Use the function buttord to obtain the order of the filter N, and its cutoff
frequency. Choose appropriate values for e
p
, and e
s
according to the graph of the
spectrum. Select a value for the attenuation in the passband R
p
no greater than 3dB
and a value for the attenuation in the stopband R
s
of at least 10dB.
Q2. If you increase the attenuation in the stopband, what happens to the filters order?
6. Use the function butter to obtain the coefficients of the transfer function of the
filter. Provide the values of the normalized cutoff frequency and the order that you
calculated in the previous step.
7. Filter the signal using the command filter. This function requires the coefficients
of the filters transfer function and the input signal, and provides the filtered signal as
output. Use the coefficients of the filter that you obtained with the command
butter.
8. Playback the filtered signal. Calculate and plot its spectrum. Where you able to
remove the noise? If not, go back to numeral 5 and design your filer again.
Q3. Describe the changes in the sound of the signal after the filtering operation. Compare
it to the noisy signal and to the original signal and comment the differences.

VI. DISCUSSION
Answer the questions in the procedure and upload the Matlab .m file to SAVIO.

You might also like