## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

)

1. (5 pts) Derive the ideal impulse response corresponding to the desired amplitude response 1, 0 ≤ ω1 ≤ |ω| ≤ ω2 ≤ π/T H(ejωT ) = 0, otherwise [Hint: Use a Fourier theorem to make use of the result given for the ideal lowpass ﬁlter in the lecture overheads and/or text.] Solution: h(n) = DT F T −1 H(ejωT ) 1 = 2π/T =

π T π −T

H(ejωT )ejωT n dω

ωc T (1)ejωT n dω 2π −ωc T 1 jωT n ωc = e −ωc 2π jT n 1 = sin(ωc T n) πn

2. (10 pts) For the ideal bandpass ﬁlter of the previous problem, with ω1 T = ω2 T = π/2 (i.e., the pass-band width is zero), design a length M = 100 real FIR bandpass ﬁlter using the window method. Deﬁne the transition bandwidth to be the width of the main lobe for the window used. Plot an overlay of the ideal and obtained amplitude responses (in dB) for the following window types (please group appropriately to save paper) : • Hamming • Kaiser with β set to give a worst-case stopband rejection of 42 dB • Hann • Kaiser with β set to give 31 dB stopband rejection • Blackman • Kaiser with β set to give 58 dB stopband rejection 1

• Kaiser with β = 10 Describe how the results for the ﬁrst three Kaiser windows compare with those for the respective ﬁrst three Blackman-Harris windows. What stopband rejection does β = 10 yield? In general, how does the stop-band rejection compare to the side-lobe level of the window functions used? Solution: This is meant to be a zero-width bandpass ﬁlter, ideally passing a frequency only at ω = π/2. One may argue that the ﬁlter width is zero, with a zero width impulse in the DTFT domain at π/2. By this reasoning, when we take the integral to go from the DTFT domain to the discrete time domain, we in fact get zero. So, mathematically, the answer really is that the ﬁlter impulse response is 0 for all time. However, any form of limiting construction shows the “engineering solution” which indicates a need for some kind of renormalization leading to an impulse in the frequency domain. We will accept the “mathematical” answer if the above is shown, but the engineer’s answer is obviously preferred. The code used to design and plot the frequency response of the ﬁlter using various windows is given below. M=100; %N=8*(M-1); %n=-(M-1)/2:(M-1)/2; N = 8*M; n = 0:M-1; hid=2*cos(pi*n/2); w=hamming(M)’; hw=hid.*w; Hw=fft(hw,N); figure(1); plot([0:1/N:0.5-1/N],20*log10(max(0.001,abs(Hw(1:N/2))/max(abs(Hw)))),’b--’); grid hold on w=hanning(M)’; hw=hid.*w; Hw=fft(hw,N); figure(1); hold on; plot([0:1/N:0.5-1/N],20*log10(max(0.0001,abs(Hw(1:N/2))/max(abs(Hw)))),’k’); grid xlabel(’normalized frequency’);ylabel(’Normalized gain(dB)’); w=blackman(M)’; hw=hid.*w; 2

Hw=fft(hw,N); figure(1);hold on; plot([0:1/N:0.5-1/N],20*log10(max(0.0001,abs(Hw(1:N/2))/max(abs(Hw)))),’r-.’); grid xlabel(’normalized frequency’);ylabel(’Normalized gain(dB)’); hold on; stem(0.25,0); legend(’hamming’,’hann’,’blackman’,’ideal’); hold off % Second set (Kaiser) w=kaiser(M,5.7)’; hw=hid.*w; Hw=fft(hw,N); figure(2); plot([0:1/N:0.5-1/N],20*log10(abs(Hw(1:N/2))/max(abs(Hw))));grid

w=kaiser(M,4.1)’; hw=hid.*w; Hw=fft(hw,N); figure(2);hold on; plot([0:1/N:0.5-1/N],20*log10(abs(Hw(1:N/2))/max(abs(Hw))),’r--’);grid w=kaiser(M,8)’; hw=hid.*w; Hw=fft(hw,N); figure(2);hold on; plot([0:1/N:0.5-1/N],20*log10(abs(Hw(1:N/2))/max(abs(Hw))),’c-.’);grid w=kaiser(M,10)’; hw=hid.*w; Hw=fft(hw,N); figure(2);hold on; plot([0:1/N:0.5-1/N],20*log10(abs(Hw(1:N/2))/max(abs(Hw))),’k:’);grid xlabel(’normalized frequency’);ylabel(’Normalized gain(dB)’); hold on stem(0.25,0); legend(’\beta=5.7’,’\beta=4.1’,’\beta=8’,’\beta=10’,’ideal’); hold off The overlaid plots are shown in Figure 1 for the Hamming, Hann and Classic Blackman and in Figure 2 for Kaiser windows. In particular, β = 5.7, 4.1 and 8 approximately give the worst-case stopband rejection of 42, 31 and 58 dB respectively. Also shown 3

0 hamming hann blackman ideal

−10

−20

Normalized gain(dB)

−30

−40

−50

−60

−70

−80

0

0.1

0.2 0.3 normalized frequency

0.4

0.5

**Figure 1: An overlay of magnitude frequency responses of Hamming, Hann and Blackman window ﬁlter design.
**

Kaiser window bandpass filter design 0 β=5.7 β=4.1 β=8 β=10 ideal

−20

−40

Normalized gain(dB)

−60

−80

−100

−120

−140

0

0.1

0.2 0.3 normalized frequency

0.4

0.5

Figure 2: An overlay of magnitude frequency responses of Kaiser window ﬁlter design with various values of β. in Figure 3 are the overlaid plots of Hamming, Hann and Blackman window ﬁlter frequency response on comparable ﬁlters using Kaiser window. The diﬀerences among windows used in the ﬁlter design are exactly what we learned about the window transform. Kaiser window oﬀers a compact energy within the mainlobe so its sidelobe level is small but at the expense of wider transition bandwidth. We have the control of the mainlobe width, hence the transition bandwidth, through β. Hamming window has equal-level sidelobes but the worst-case sidelobe is lower than that using Hann. Blackman window gives a response similar to Hann but with lower sidelob levels and slightly wider mainlobe. Finally, the stopband rejection in the case of Kaiser window with β = 10 is about -75 dB, taking half the mainlobe as a transition band. As a continuation of the initial discussion about mathemtical answers, recall the Hilbert transform discussion from lecture. We obtained inferior results when we simply win4

Normalized gain(dB)

0 −100 −200 −300 −400 0 −100 −200 −300 −400 0 −100 −200 −300 −400 0 0.1 0.2 0.3 normalized frequency 0.4 blackman kaiser(8) 0.5 0 0.1 0.2 0.3 normalized frequency 0.4 hann kaiser(4.1) 0.5 0 0.1 0.2 0.3 normalized frequency 0.4 hamming kaiser(5.7) 0.5

Figure 3: A comparison between using Hamming, Hann and Blackman window with their comparable Kaiser windows. dowed the sampled, ideal Hilbert transform kernel. That’s when we went back and modiﬁed the “ideal” speciﬁcation to be compatible with a “bandlimited environment”, and thereby avoided aliasing (and halved the necessary computations, since every other sample became zero in the desired impulse response). In this situation, the ideal response can be modiﬁed to become compatible with a “time-limited” environment. This is just another way to approach it. 3. (10 pts) For ωc T = π/2, design a length M = 100 real FIR lowpass ﬁlter using the window method. Plot the amplitude response (dB gain versus frequency) for the following windows: • Hamming • Hann • Blackman • Kaiser with β = 10 Explain why the stopband rejection is so diﬀerent from that in the previous problem. Solution: The plots of the frequency responses are shown in Figure 9. The sidelobe levels in this problem are smoother and lower than the previous one. This is because the sidelobes of the windowspectrum gets smoothed out by the convolution process in the frequency domain with the ideal lowpass ﬁlter frequency response which is a rectangular function. This may be counterintuitive, but we recall that sidelobes alternate positive and negative, thus when we sum over more of them under the ideal rect function, we get closer to zero. (This frequency domain convolution is due to multiplication in time domain of the ideal impulse response by the window.) Relevant code: M = 100; 5

Normalized gain(dB)

Normalized gain(dB)

N = 8*M; n = -M/2+1:M/2; hid=sin(pi*0.5*n)./(pi*0.5*n+eps); hid(n==0) = 1; % due to sinc exception w=hamming(M)’; hw=hid.*w; Hw=fft(hw,N); figure(3); plot([0:1/N:0.5-1/N],20*log10(max(0.000001,abs(Hw(1:N/2))/max(abs(Hw)))),’b--’); grid figure(2); subplot(411); plot([0:1/N:0.5-1/N],20*log10(max(0.000001,abs(Hw(1:N/2))/max(abs(Hw)))),’b’); grid w=hanning(M)’; hw=hid.*w; Hw=fft(hw,N); figure(3); hold on; plot([0:1/N:0.5-1/N],20*log10(max(0.000001,abs(Hw(1:N/2))/max(abs(Hw)))),’k’); grid xlabel(’normalized frequency’);ylabel(’Normalized gain(dB)’); figure(2); subplot(412); plot([0:1/N:0.5-1/N],20*log10(max(0.000001,abs(Hw(1:N/2))/max(abs(Hw)))),’b’); grid w=blackman(M)’; hw=hid.*w; Hw=fft(hw,N); figure(3);hold on; plot([0:1/N:0.5-1/N],20*log10(max(0.000001,abs(Hw(1:N/2))/max(abs(Hw)))),’r-.’); grid xlabel(’normalized frequency’);ylabel(’Normalized gain(dB)’); hold on; figure(2); subplot(413); plot([0:1/N:0.5-1/N],20*log10(max(0.000001,abs(Hw(1:N/2))/max(abs(Hw)))),’b’); grid % Kaiser w=kaiser(M,10)’; 6

Hamming 0 −50 −100 −150 0 −50 0 0.1 0.2 0.3 Hann normalized frequency 0.4 0.5

Normalized gain(dB)

−100 −150 0 0 0.1 0.2 0.3 Blackman normalized frequency 0.4 0.5

−100

−200 0

0

0.1

0.2 0.3 Kaiser normalized frequency

0.4

0.5

−100

−200

0

0.1

0.2 0.3 normalized frequency

0.4

0.5

Figure 4: The magnitude frequency responses of Hamming, Hann, Blackman and Kaiser(10) window ﬁlter design. hw=hid.*w; Hw=fft(hw,N); figure(3); hold on; plot([0:1/N:0.5-1/N],20*log10(max(0.000001,abs(Hw(1:N/2))/max(abs(Hw)))),’g:’); grid legend(’hamming’,’hann’,’blackman’,’kaiser’); hold off figure(2); subplot(414); plot([0:1/N:0.5-1/N],20*log10(max(0.000001,abs(Hw(1:N/2))/max(abs(Hw)))),’b’); grid 4. (13 pts) Download the sound ﬁle noisypeaches.wav1 containing speech embedded in white noise. (a) (5 pts) Plot the spectrogram of noisypeaches.wav to help you understand its spectral content but there is no need to submit it. Design a low pass ﬁlter using the window method with a Kaiser window of length 100 and β=10. The cut-oﬀ frequency of the ﬁlter should be 4 kHz. Plot its impulse response and magnitude of frequency response. (b) (3 pts) Apply this ﬁlter to the noisy speech signal either by the FFT method of simple ﬁltering. Listen and describe the result compared to the original. (c) (5 pts) Now downsample the original noisy speech signal by a factor of two by simply throwing away every other sample. Listen to the result and compare it to the original higher sampling rate. Repeat the same downsampling scheme on the lowpass ﬁltered speech signal and again, compare with its higher sampling rate

1

http://www-ccrma.stanford.edu/˜jos/hw421/hw6/noisypeaches.wav

7

version. Why does the latter pair (lowpass ﬁltered) sound more similar than the ﬁrst pair (unﬁltered)? Solution: Possible code for this problem, which also generates the required output ﬁles, is: % HW6q6.m %[signal,fs] = wavread(’noisyoboe.wav’); % read in signal [signal,fs] = wavread(’noisypeaches.wav’); % read in signal %%%%% filter design %%%%%%%%%%%%%%%%%%%%% M = 100; % time length of window N = 8*M; % FFT length n = -M/2+1:M/2; % time indices %w_c = 6000; % choose cutoff of 6kHz for oboe lowpass filter w_c = 4000; % choose cutoff of 6kHz for speech lowpass filter norm_rad_w_c = w_c/(fs/2)*pi; % convert to normalized rad freq hid=sin(norm_rad_w_c*n)./(norm_rad_w_c*n+eps); % ideal response hid(n==0) = 1; % due to sinc exception w=kaiser(M,10)’; hw=hid.*w; % window ideal response Hw=fft(hw,N); % frequency response %%%% part a/c: plots %%%%%%%%%%%%%%%%%%%% subplot(211); plot(n,hw); xlabel(’n’); ylabel(’amplitude’); title... (’lowpass filter using Kaiser(100,10) window: impulse and frequency response’) subplot(212); plot(-fs/2:fs/(N-1):fs/2,... fftshift(20*log10(max(0.000001,abs(Hw)/max(abs(Hw)))))); grid ylabel(’normalized dB magnitude’); xlabel(’Freq in Hz’); %%%%%% parts b/c/d: filter signal %%%%%%% filtered_signal = conv(signal,hw); % simple filtering wavwrite(filtered_signal./max(filtered_signal),fs,’hw6q6out.wav’); %%%%%% part e: downsample %%%%%%%%%%%%%%% ds_signal = signal(mod(1:length(signal),2)==0); % throw away odd samples ds_filtered_signal = filtered_signal(mod(1:length(signal),2)==0); ds_fs = fs/2; % downsampled sampling rate wavwrite(ds_signal./max(filtered_signal),ds_fs,’hw6q6ds.wav’); wavwrite(ds_filtered_signal./max(filtered_signal),ds_fs,’hw6q6dsf.wav’); (a) (10 pts) The spectrogram (Figure 6) shows rather obviously that most of the nonnoise signal energy is concentrated the band of frequency up to about 6 kHz. We can then design a lowpass ﬁlter with a cut-oﬀ frequency here to retain most of the oboe signal while getting rid of (white) noise which spreads out through the

8

Lowpass filter using Kaiser(100,10) window : impulse response 0.8

Magnitude

0.6 0.4 0.2 0 −40 −30 −20 −10 0 n 10 20 30 40

Magnitude frequency response 0

−50

dB

−100 −150

−2

−1.5

−1

−0.5

0 frequency (Hz)

0.5

1

1.5

2 x 10

4

Figure 5: The impulse response and the magnitude frequency response of the designed lowpass ﬁlter with a cut-oﬀ frequency of 5 kHz. whole spectrum. The plot of the ﬁlter’s impulse response and magnitude of the frequency response are shown in Figure 5. (b) (5 pts) By using either FFT or convolution the original signal with the ﬁlter just obtained, the output clearly has lower level of noise while the oboe sound still sounds very much the same. The spectrogram is shown in Figure 6. (c) (10 pts) Now with the speech signal, it is not clear-cut where we should place the cut-oﬀ of the lowpass ﬁlter having sibilants like “c” and “s” (Figure 8). A compromise needs to be made but a good choice may be a cut-oﬀ at 4 kHz. The impulse and frequency response of the ﬁlter are shown in Figure 7. (d) (5 pts) The output of the ﬁlter clearly shows that we lost some high frequency components in the speech along with the noise, especially “c” in “juicy” (Figure 8). (e) (10 pts) If the signal is simply downsampled by throwing away every other sample, the resulting spectrum is a stretched version of the original and aliasing can occur. This is evident in listening, and even though it may sound brighter, having more high frequency content, the aliasing can be a cause of annoyance and is irrecoverable. On the other hand, if the signal is ﬁrst bandlimited by lowpass ﬁltering to make sure that, after stretching, the spectrum will not fold over the sampling frequency, the resulting downsampled sound will sound very much like the one before the conversion. The process is also reversible. 5. (5 pts) Figure 9 shows the impulse response and the corresponding magnitude spectrum of a lowpass ﬁlter. (a) (3 pts) Without using MATLAB, sketch the magnitude spectrum of the impulse response shown in Figure 10, which was obtained from that in Fig. 9 by negating the odd-numbered samples. Explain how you obtained your answer.

9

x 10 2 1.5 1 0.5 0

4

Original

Frequency

0

0.1

0.2

0.3 Time

0.4

0.5

0.6

x 10 2 1.5 1 0.5 0

4

Filtered

Frequency

0

0.1

0.2

0.3 Time

0.4

0.5

0.6

Figure 6: The spectrogram of the original noisy oboe sound and the lowpass ﬁltered version using cut-oﬀ frequency of 5 kHz.

Lowpass filter using Kaiser(100,10) window : impulse response 1

Magnitude

0.5

0

−0.5 −50

−40

−30

−20

−10

0 n

10

20

30

40

50

Magnitude frequency response 0

−50

dB

−100 −150 −8000

−6000

−4000

−2000

0 frequency (Hz)

2000

4000

6000

8000

Figure 7: The impulse response and the magnitude frequency response of the designed lowpass ﬁlter with a cut-oﬀ frequency of 4 kHz.

Original 8000

6000

Frequency

4000

2000

0

0

0.5

1

1.5 Time Filtered

2

2.5

3

8000

6000

Frequency

4000

2000

0

0

0.5

1

1.5 Time

2

2.5

3

Figure 8: The spectrogram of the original noisy speech sound and the lowpass ﬁltered version using cut-oﬀ frequency of 4 kHz. 10

Impulse response 1 0.8 0.6 amplitude 0.4 0.2 0 −0.2 −0.4 −50 −40 −30 −20 −10 0 10 time (samples) 20 30 40 50

Magnitude Spectrum 0 amplitude (dB) −20 −40 −60 −80

0

0.5

1

1.5 2 frequency (rad/samples)

2.5

3

Figure 9: Impulse response of a lowpass ﬁlter and its magnitude spectrum

1

0.8

0.6

0.4

0.2

0

−0.2

−0.4

−0.6

−0.8

−1 −50

−40

−30

−20

−10

0

10

20

30

40

50

Figure 10: Impulse response

11

10

0

−10

−20

−30

−40

−50

−60

−70

−80

0

0.5

1

1.5

2

2.5

3

Figure 11: Magnitude spectrum of a highpass ﬁlter (b) (2 pts) Verify your answer by plotting the magnitude spectrum of the above impulse response using MATLAB. You can download a mat ﬁle ir.mat2 which contains an impulse response vector h(n) shown in Fig. 10. Solution: (a) (3 pts) Negating odd-numbered samples of h(n) is equivalent to multiplying h(n) by (−1)n = ejπn ; i.e., it has the same eﬀect of shifting the spectrum H(ω) by π in the frequency domain. Therefore, the resulting spectrum will be that of a highpass ﬁlter with the cutoﬀ frequency ωc = π − π/4 = 3π/4. (b) (2 pts) Figure 11 shows the spectrum of the impulse response hhp (n) = (−1)n h(n). 6. (5 pts) Design a real, linear-phase, FIR bandpass ﬁlter using remez() in Matlab with the following speciﬁcations: Sampling rate fs = 100 Hz, pass-band from 20 Hz to 30 Hz, stop-band from 0 to 10 Hz and 40 to 50 Hz, δs = 0.01 (−40 dB) ripple in the stop-band, and δp = 0.02 ripple in the pass-band, which is unity gain. The ﬁlter thus has transition bands from 10 to 20 Hz, and from 30 to 40 Hz. Turn in a listing of your Matlab code, and the result of its execution (e.g., using the diary command), which should include a print-out of the ﬁlter length, a listing of the ﬁlter coeﬃcients, and a plot of the ﬁlter amplitude response on a dB vertical scale. [Hint: Start with ’help remezord’ in Matlab.] Solution: >> diary ’remezproblem.txt’ >> [N,Fo,Ao,W] = remezord([10 20 30 40],[0 1 0],[.01 .02 .01],100)

2

http://ccrma.stanford.edu/˜jos/hw421/hw6/ir.mat

12

N = 17 Fo = 0 0.2000 0.4000 0.6000 0.8000 1.0000 Ao = 0 0 1 1 0 0 W = 2 1 2 >> h = remez(N,Fo,Ao,W) h = -0.0179 -0.2296 0.0108 -0.0229 0.2743 0.0324 0.0324 0.2743 -0.0229 0.0108 -0.2296 -0.0179 0.0295 -0.1709 0.0881 0.0881 -0.1709 0.0295

>> freqz(h,1,512,100); >> print -deps ’ampresponse.eps’ 3 extra points for recognizing that ripple specs are not met using remezord output (N = 17), and increasing N until they are (N = 19).

13

- M3_ExtSetups_E2uploaded bylordeldor
- M3_ExtSetups_E1uploaded byAde John Nursalim
- matched filterhw2solnuploaded bykawsik
- DUNE Manualuploaded byjr
- DuoBinary Ideal Filteruploaded byAytekin Ozdemir
- DSP Lab Manual(12-13)uploaded bySravanthithota Sravan
- chap-8uploaded byapi-19951707
- Aliasing is a Signal Processing Termuploaded byNivedh Vijayakrishnan
- ee6211 electric circuits labuploaded byapi-338316720
- MANUAL 19032012uploaded byHirankur Khillare
- Tek-TVS600Series-UM-070991600uploaded byLorraine Price
- Interpolator Controluploaded byAnonymous pHi4dX
- Model 425 Datasheetuploaded byPratik Patel
- DSAS 6 First-Order LTI Systemsuploaded byDennisIgoyDacanay
- 14 Interpolation Decimationuploaded byDhimas Arief Dharmawan
- Briefinguploaded bytkjing
- [Perman_-_bruel__kjae]_Dsp_-_application_of_the_f(BookSee.org).pdfuploaded byAbd Elkarim AbuSalim
- sigacquploaded byJessica Smith
- Bus Waitinguploaded bymidhuna94
- Sbaa 094uploaded byVitu Vitu
- The Wavelet Tutorialuploaded byArmando Malone
- Digital Signal Processing-chapter 16: MATLAB Programsuploaded bysahar
- Passive Damping Filter Design and Application for Three-Phase PV Grid-Connected Inverteruploaded byEditor IJTSRD
- GraphSignalProcessing ICIP 2013 Ortegauploaded byGaneshKanna
- Valle_Visual Display and Retrieval of Music Informationuploaded byKai Lin Zhang
- Lecture Notes 576w2013uploaded byJim Pam
- saiuploaded byAnuraag Hiremath
- digitalcontrol-3263uploaded bysarkrass
- WIDE AREA MEASUREMENT TECHNOLOGY USING GPSuploaded byShadab Sayyad
- GER-3962uploaded byM Adnan Ashraf

- 01 My Great Noveluploaded byjamesyu
- 01 My Great Novel With Numbersuploaded byjamesyu
- Menu at Sebo in San Franciscouploaded byjamesyu
- 01 thisisthebestuploaded byjamesyu
- Facebook Connect for Web Startups Design Guideuploaded byjamesyu
- 03-26 Entry Door copy 9uploaded byjamesyu
- 01 My Great Noveluploaded byjamesyu
- REST Cheatsheetuploaded byjamesyu
- 01 My Great Novel With Numbersuploaded byjamesyu
- test file text 1uploaded byjamesyu
- 03-26 Entry Door Copy 11uploaded byjamesyu
- 03-26 Entry Door Copy 4uploaded byjamesyu
- Parse Presentationuploaded byjamesyu
- Restaurants To Tryuploaded byjamesyu
- test file text 1uploaded byjamesyu
- 03-26 Entry Door Copy 8uploaded byjamesyu
- 03-26 Entry Door Copy 14uploaded byjamesyu
- 03-26 Entry Door copy 9uploaded byjamesyu
- 03-26 Entry Door Copy 13uploaded byjamesyu
- 03-26 Entry Door copy 12uploaded byjamesyu
- PDF Testuploaded byjamesyu
- 03-26 Entry Door Copy 9uploaded byjamesyu
- 03-26 Entry Door Copy 9uploaded byjamesyu
- 03-26 Entry Door Copy 15uploaded byjamesyu
- 03-26 Entry Door Copy 9uploaded byjamesyu
- 03-26 Entry Door Copy 16uploaded byjamesyu
- iPaper Animation -- Stick Figure Drawinguploaded byjamesyu
- 03-26 Entry Door Copy 12uploaded byjamesyu
- 03-26 Entry Door Copy 14uploaded byjamesyu
- 03-26 Entry Door Copy 17uploaded byjamesyu

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading