90 likes | 241 Views
Lab 6 (EASY). Fast Convolution. Fast Convolution. Lab objectives Implement a bandpass filter in the frequency domain, using a Hamming window function. Filter the noisy signal generated in Lab 3, and plot the result. Write the result to a .wav file for playback. Fast Convolution.
E N D
Lab 6 (EASY) Fast Convolution
Fast Convolution Lab objectives • Implement a bandpass filter in the frequency domain, using a Hamming window function. • Filter the noisy signal generated in Lab 3, and plot the result. • Write the result to a .wav file for playback
Fast Convolution In lab 3, we generated a 5 second long, 40000 sample, wave file continaining noise, a 1000 Hz. sinusoid, and a 1500 Hz. sinusoid. In this lab, we’ll process the first 8192 samples of this complex signal. We’ll create a frequency domain Hamming window, centered at 1500 Hz., to attenuate the 1000 Hz. sinusoid while passing the 1500 Hz. sinusoid
Fast Convolution When we take the 8192 point FFT of this signal, which was sampled at fs = 8000 Hz, the first 4096 samples in the FFT output represent frequencies from 0 Hz. to 4000 Hz. Samples 4097 through 8192 represent -4000 Hz to 0 Hz. Therefore, we need a gaussian window centered at
Fast Convolution The Hamming window function is given by In this case, we’ll make the window 200 points wide, so N = 200.
Fast Convolution In Matlab, index = linspace(0, 199, 200); Hamming = 0.54-0.46*cos(2 * pi * index / (199)); Now, we’ll create a vector containing the frequency response of our filter: H = zeros(8192, 1);
Fast Convolution and we’ll place the filter window so that it’s centered at sample number 1536, with a negative frequency replica at sample 8191 – 1536 = 6655: H(1436:1635) = Hamming; H(6755:-1:6556) = Hamming(200:-1:1);
Fast Convolution Next, either read your wav file from Lab 3, or generate the same noisy signal. Store the signal in a vector called x. Take the FFT of the first 8192 points in that vector, and store it in a vector xf: xf = fft(x(1:8192); Multiply xf by H, point by point: yf = xf .* H;
Fast Convolution Take the Inverse FFT of yf, and write its real part to a wav file using wavwrite or auwrite. y = ifft(yf); Turn in: an m-file implementing the above procedure, and a wav file containing the output. MAKE SURE IT WORKS BEFORE YOU SEND IT TO ME!