Design 4 Report

download Design 4 Report

of 9

Transcript of Design 4 Report

  • 8/6/2019 Design 4 Report

    1/9

  • 8/6/2019 Design 4 Report

    2/9

    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 squarewave. The recorder module from experiment 3 was used to acquire a signal to test andthe rttest.m file; also from experiment 3, was edited to include the filtering operation onan acquired square wave. Finally, the filter was used to suppress the first, third, and fifthharmonics of the noisyspeech.wav file provided and the filtered output was plotted inMatlab.

  • 8/6/2019 Design 4 Report

    3/9

    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 providedonline. 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 thefundamental frequency of the square wave was analyzed and tracked.

    Methods:

    The recorder function from experiment 3 was used to acquire an input square wave fromthe function generator. The rttest.m file was modified to acquire the signal, filter thesignal and output the filtered signal. The fast Fourier transform was used on the inputsquare 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 threeand five to find where the third and fifth harmonics occurred. An array of ones and zerosthe length of the Fourier transform was created to filter out each harmonic of the squarewave. In the filter array, zeros were placed at the locations of the harmonics in the inputfft. The filter array was multiplied by the input fft array element by element to acquire anoutput signal in the frequency domain. The inverse fft was taken to obtain the filteredsignal in the time domain.

    To ensure the filter was working properly the filter was modified to pass the thirdharmonic and suppress the first and fifth harmonic. The filtered Fourier transform wasgraphed to show the third harmonic. The auto gain function from lab 3 was used to plotthe output signal in the time domain.

    The filter was changed back to suppress each harmonic and was tested on thenoisyspeech.wav file from the course web site. This file includes a speech wave withan interfering square wave. A sampling rate of 11025 kHz was used to test the speechfiles. 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 inMatlab. The filter should have minimal effect on the clean speech waveform because thisfile does not have the interfering square wave. The plot of the clean speech waveformwas compared to the filtered plot of the noisy speech waveform.

  • 8/6/2019 Design 4 Report

    4/9

    Results:

    7.012 7.013 7.014 7.015 7.016 7.017 7.018 7.019-0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    Input Vs Time

    Time (s)

    M a g n i t u d e

    Figure 1: 500Hz square acquired from function generator

    0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

    x 10 4

    0

    2000

    4000

    6000DFT of input signal

    Frequency (Hz)

    M a g n i t u d e

    0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2x 10

    4

    0

    500

    1000DFT of filtered input

    Frequency (Hz)

    M a g n i t u d e

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

  • 8/6/2019 Design 4 Report

    5/9

    500 1000 1500 2000 2500

    0

    2000

    4000

    DFT of input signal

    Frequency (Hz)

    M a g n i t u d e

    500 1000 1500 2000 2500 30000

    1000

    2000

    DFT of filtered input

    Frequency (Hz)

    M a g n i t u d e

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

    6540 6560 6580 6600 6620 6640 6660

    -0.2

    -0.15

    -0.1

    -0.05

    0

    0.05

    0.1

    0.15

    0.2

    Output Vs Time

    Figure 4: Filtered output in time domain

  • 8/6/2019 Design 4 Report

    6/9

    0 0.5 1 1.5 2 2.5 3 3.5

    x 104

    -1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1Input Vs Time

    Time (ms)

    M a g n i t u d e

    Figure 5: noisyspeech.wav speech with interference

    200 400 600 800 1000 1200 1400 1600 1800 2000

    50

    100

    150

    DFT of input signal

    Frequency (Hz)

    M a g n i t u d e

    200 400 600 800 1000 1200 1400 1600 1800 2000

    10

    20

    30

    DFT of filtered input

    Frequency (Hz)

    M

    a g n i t u d e

    Figure 6: DFT of input speech and filtered speech signals

  • 8/6/2019 Design 4 Report

    7/9

    0 0.5 1 1.5 2 2.5 3 3.5

    x 104

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8Output Vs Time

    Time (ms)

    M a g n i t u d e

    Figure 7: Filtered noisyspeech.wav signal in time domain

    0 0.5 1 1.5 2 2.5 3 3.5

    x 10 4

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8Input Vs Time

    Time (ms)

    M a g n i t u d e

    Figure 8: cleanspeech.wav signal

  • 8/6/2019 Design 4 Report

    8/9

    200 400 600 800 1000 1200 1400 1600 1800 20000

    10

    20

    30

    40

    DFT of input signal

    Frequency (Hz)

    M a g n i t u d e

    200 400 600 800 1000 1200 1400 1600 1800 2000

    0

    10

    20

    30

    DFT of filtered input

    Frequency (Hz)

    M a g n i t u d e

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

    0 0.5 1 1.5 2 2.5 3 3.5

    x 10 4

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8Output Vs Time

    Time (ms)

    M a g n i t u d e

    Figure 10: Filtered cleanspeech.wav file in time domain

  • 8/6/2019 Design 4 Report

    9/9

    Discussion:

    The filter was successful in identifying and tracking the fundamental frequency of thesquare wave input. From the fundamental frequency the third and fifth harmonics wereidentified 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 fifthharmonics. When using Matlab to design adaptive filters factors such as amplitudechanges of the signal during A/D and D/A conversion need to be considered.