You are on page 1of 9

ECE 1563 Experiment 4 Design: Adaptive Filtering Charles Turner Farshid Momayezi 4/8/10

Executive Summary:

This design lab involved the design of an adaptive filter, to filter an interfering square wave. The filter was designed to filter a square wave from a speech wave with noise. The filter was tested with square waves with frequencies ranging from 100Hz to 1000Hz. The filter was able to suppress the first, third and fifth harmonics of the interfering square wave. The recorder module from experiment 3 was used to acquire a signal to test and the rttest.m file; also from experiment 3, was edited to include the filtering operation on an acquired square wave. Finally, the filter was used to suppress the first, third, and fifth harmonics of the noisyspeech.wav file provided and the filtered output was plotted in Matlab.

Introduction:
A real time adaptive filter was designed to filter an interfering square wave from speech. The filter was tested with speech wave files with and without noise that were provided online. An adaptive filter is a filter in which software analyzes some characteristic of the input and uses it to adapt the filter to changes in the input. For this design the fundamental frequency of the square wave was analyzed and tracked.

Methods:
The recorder function from experiment 3 was used to acquire an input square wave from the function generator. The rttest.m file was modified to acquire the signal, filter the signal and output the filtered signal. The fast Fourier transform was used on the input square wave acquired from the function generator. The maximum value of the Fourier transform was found, this corresponded to the first harmonic (fundamental frequency) of the input. The frequency at which the first harmonic occurred was multiplied by three and five to find where the third and fifth harmonics occurred. An array of ones and zeros the length of the Fourier transform was created to filter out each harmonic of the square wave. In the filter array, zeros were placed at the locations of the harmonics in the input fft. The filter array was multiplied by the input fft array element by element to acquire an output signal in the frequency domain. The inverse fft was taken to obtain the filtered signal in the time domain. To ensure the filter was working properly the filter was modified to pass the third harmonic and suppress the first and fifth harmonic. The filtered Fourier transform was graphed to show the third harmonic. The auto gain function from lab 3 was used to plot the output signal in the time domain. The filter was changed back to suppress each harmonic and was tested on the noisyspeech.wav file from the course web site. This file includes a speech wave with an interfering square wave. A sampling rate of 11025 kHz was used to test the speech files. The filtered output from the noisy speech file was plotted with Matlab. The filter was tested on the cleanspeech.wav file and the filtered output was plotted in Matlab. The filter should have minimal effect on the clean speech waveform because this file does not have the interfering square wave. The plot of the clean speech waveform was compared to the filtered plot of the noisy speech waveform.

Results:
Input Vs Time 0.6

0.4

0.2 Magnitude

-0.2

-0.4

-0.6 7.012

7.013

7.014

7.015 7.016 Time (s)

7.017

7.018

7.019

Figure 1: 500Hz square acquired from function generator


DFT of input signal 6000

Magnitude

4000

2000

0.2

0.4

0.6

0.8 1 1.2 Frequency (Hz) DFT of filtered input

1.4

1.6

1.8 x 10

2
4

1000

Magnitude

500

0.2

0.4

0.6

0.8 1 1.2 Frequency (Hz)

1.4

1.6

1.8 x 10

2
4

Figure 2: DFT of input and filtered input with 1st, 3rd, 5th harmonics filtered

DFT of input signal

Magnitude

4000 2000 0 500 1000 1500 2000 Frequency (Hz) DFT of filtered input 2500

Magnitude

2000

1000

0 500 1000 1500 2000 Frequency (Hz) 2500 3000

Figure 3: DFT of input and filtered input with 1st and 5th harmonics filtered
Output Vs Time 0.2 0.15 0.1 0.05 0 -0.05 -0.1 -0.15 -0.2 6540 6560 6580 6600 6620 6640 6660

Figure 4: Filtered output in time domain

Input Vs Time 1 0.8 0.6 0.4 0.2 Magnitude 0 -0.2 -0.4 -0.6 -0.8 -1

0.5

1.5 2 Time (ms)

2.5

3.5 x 10
4

Figure 5: noisyspeech.wav speech with interference


DFT of input signal 150 Magnitude

100

50

200

400

600

800 1000 1200 1400 Frequency (Hz) DFT of filtered input

1600

1800

2000

30 Magnitude 20 10

200

400

600

800 1000 1200 Frequency (Hz)

1400

1600

1800

2000

Figure 6: DFT of input speech and filtered speech signals

Output Vs Time 0.8

0.6

0.4

Magnitude

0.2

-0.2

-0.4

-0.6

0.5

1.5 2 Time (ms)

2.5

3.5 x 10
4

Figure 7: Filtered noisyspeech.wav signal in time domain


Input Vs Time 0.8 0.6 0.4 0.2 Magnitude 0 -0.2 -0.4 -0.6 -0.8

0.5

1.5 2 Time (ms)

2.5

3.5 x 10
4

Figure 8: cleanspeech.wav signal

DFT of input signal 40 Magnitude 30 20 10 0 200 400 600 800 1000 1200 Frequency (Hz) DFT of filtered input 1400 1600 1800 2000

30 Magnitude 20 10 0 200 400 600 800 1000 1200 Frequency (Hz) 1400 1600 1800 2000

Figure 9: DFT of input cleanspeech.wav and filtered speech


Output Vs Time 0.8

0.6

0.4

Magnitude

0.2

-0.2

-0.4

-0.6

0.5

1.5 2 Time (ms)

2.5

3.5 x 10
4

Figure 10: Filtered cleanspeech.wav file in time domain

Discussion:
The filter was successful in identifying and tracking the fundamental frequency of the square wave input. From the fundamental frequency the third and fifth harmonics were identified and filtered out of the signal as seen in figure 2. Figure 3 shows the successful filtering operation by passing the third harmonic and filtering the first and fifth harmonics. When using Matlab to design adaptive filters factors such as amplitude changes of the signal during A/D and D/A conversion need to be considered.

You might also like