Design an fir filter that eliminates the noise components


COMPUTER ASSIGNMENT: Notch Filter Design

This assignment is an introduction to notch filters. You will study the structure of notch filters and use them to remove narrowband noise components. In particular, you will create a Matlab function which would determine the location of noise components and the coefficients of corresponding FIR/IIR notch filters to eliminate the narrowband noise components from the noisy input signal.

Accessing Data: You have access to the Matlab data file ELE632 Data.mat which in- cludes two audio signals sampled at 16 kHz. After copying the data file to your working directory enter the command
>> load ELE632 Data
to access the speech samples stored in the following arrays:

Array Name

Fs [kHz]

No of samples

Duration [s]

sp16

16

40,000

2.50

sp16 noisy

16

40,000

2.50

The audio/speech data contained in ELE632 Data.mat file was originally sampled from a CBC news broadcast at 8 kHz and then upsampled to 16 kHz.

Listening to Audio/Sound Samples: You can use the built-in Matlab command sound to listen to audio samples. For example, either of the following two commands allows you to listen to noisy audio samples:
>> sound( sp16 noisy, Fs);
where Fs = 16000 is the sampling frequency.

Practice Problem:

A speech signal with bandwidth B = 3.8 kHz has been sampled at Fs = 16 kHz. The speech signal is corrupted by two sinusoids with frequencies: F1 = 800 Hz and F2 = 1.2 kHz. Display the power spectral density function of the speech samples using the Matlab function psd, e.g. psd( sp16 noisy, 2048, Fs ) (you can ignore the Matlab Warning message).

(a) Design an FIR filter that eliminates the noise components F1 and F2.

(b) Set the maximum gain of the filter to unity. Plot the magnitude response and the phase response of the filter. Process the noisy speech samples by filtering through the

FIR filter. Playback the processed speech samples and compare with the noise free speech samples.

(c) Does the filter fulfill your objectives? How can you further improve your design in part (a)? In the context of this problem, improvement means to reduce the bandwidth of the notches in the magnitude response of the filter. Compare the magnitude response of your design in part (a) and of your improved design. Also compare the filter output in both cases.

PROBLEM 1: Notch Filter Design and Implementation:

Consider a real-valued discrete-time sequence x[n], which has exactly two noise components at digital frequencies Ω1 and Ω2 where 0 < Ω1 < Ω2 < π. The objective is to design a notch/comb filter that will remove the noise components at Ω1 and Ω2. You can assume that Ωi = 2πFi and each Fi, i = 1, 2 is a rational number and all noise components have the same power. The maximum gain of the filter has to be set to unity.

Write a Matlab function notch.m which analyzes the input signal x[n] and determines the coefficients of the notch filter which would remove the frequency components as described above. The notch filter is assumed to have the transfer function H(z):

H(z) = G ∑k=0M.bkz-k/∑k=0M.k=0 akz-k (1)

where G is a gain factor; {bk}k=0M and {ak}k=0M are the real-valued numerator and denominator coefficients, respectively. The call to the notch.m function should be in the form:

[ b, a ] = notch( x, FType );

where

x: 1-dimensional, real-valued "noisy" input sequence, which can be a row or column vector;

FType: filter type; a string variable set to 'fir' or 'iir';

b: real-valued numerator coefficients of the notch filter described by the transfer function H(z) as shown in Equation (1);

a: real-valued denominator coefficients of the notch filter described by the transfer function H(z) as shown in Equation (1). If FType = ‘fir', then a0 = 1 and ak = 0, for k = 1, . . . , M.

Remark: Please note that the two noise components Ω1 and Ω2 are not known. It is the responsibility of your code to analyze the input signal and identify the frequencies of the noise components. You can use the noisy signal in sp16 noisy as a test signal, however your code should also function correctly with other test signals.

PROBLEM 2: Testing the Notch Filter:

(a) Open the Simulink model Scrambler.slx. The Simulink model implements a simple scrambler using basic discrete-time signal processing operations of filtering and mod- ulation. You can study the structure of the scrambler by clicking on the Simulink block Scrambler. The scrambler uses lowpass filters with the following specifications (all specifications are with respect to Fs = 16 kHz):
- Passband edge frequency = 3.8 kHz,
- Stopband edge frequency = 4 kHz,
- Stopband attenuation = 80 dB.

You can open the Digital Filter block in the Scrambler model and select the View Filter Response option.

The Scrambler uses a digital oscillator whose output frequency is set to π/2 rad/sec (equivalent to 4 kHz for Fs = 16 kHz).

Study the operation of the Scrambler. How does it alter input signal characteristics? In particular, determine the spectrum of the signal at the output of the scrambler when the input to the scrambler is a baseband signal with bandwidth 4 kHz and a frequency hole from 0 to 0.2 kHz. How would you unscramble a scrambled signal?

(b) Determine the coefficients of FIR and IIR notch filters if the notch filter is to be used to remove all affects of the two noise components at F1 = 0.8 kHz and F2 = 1.2 kHz for the following two cases:
(i) at the input of the scrambler;
(ii) at the output of the scrambler.

Calculate the FIR and IIR filter coefficients for both cases, clearly identify all your assumptions. Compare the magnitude spectra of your analytically determined filters with those from the filters generated by your Matlab function notch.m. Comment on any differences observed. Note: For the IIR notch filters you design, magnitudes of system poles should not exceed 0.95.

(c) Test the effectiveness of your notch filter by implementing it in Simulink. The Digital Filter/Notch Filter block in the Simulink model Scrambler.slx have all its coefficients set to 1 such the output of the Digital Filter/Notch Filter block equals its input.

First enter the notch filter coefficients you calculated in part b-(i) into the Digi- tal Filter/Notch Filter block (double-click on the Digital Filter/Notch Fil- ter block and a dialog box will open). Test your notch first with the noisy non- scrambled signal (sp16 noisy) using the signal flow chain:

Audio Signal Input (sp16 noisy) → Notch Filter → To Audio Device

How does the filtered signal sound? How does the spectrum of the filtered signal com- pare with that of the "clean" signal (sp16)? What are the differences you observe/hear between the FIR notch and IIR notch filters?

(d) Test the effectiveness of your notch filter by testing it on scrambled signal. Using the results you obtained in part (a) create a Descrambler block and incorporate it into your Simulink block. First, test the descrambler using the signal flow chain:

Audio Signal Input (sp16) → Scrambler → Descrambler → To Audio Device

You can now test the effectiveness of the notch filter you designed in part b-(ii) using the scrambled signal xs[n] as its input. In particular, use the signal flow chain:

Audio Signal Input (sp16 noisy) → Scrambler → NotchFilter →

Descrambler → To Audio Device

How does the filtered+descrambled signal sound? How does the spectrum of the filtered+descrambled signal compare with that of the "clean" signal (sp16)? What are the differences you observe/hear between the FIR notch and IIR notch filters?

Remark: The Simulink model Scrambler.slx has its simulation stop time set to 3.5 s which corresponds approximately to the duration of the test signals. If you want to have longer simulation run times, you need to adjust the stop time accordingly. For example, if you change the simulation stop time to Inf, then the simulation will continuously run until you pause or stop it. In this scenario the same 2.5 s long test signal will be cyclicly repeated.

Attachment:- Data Files.zip

Solution Preview :

Prepared by a verified Expert
Electrical Engineering: Design an fir filter that eliminates the noise components
Reference No:- TGS02336638

Now Priced at $60 (50% Discount)

Recommended (96%)

Rated (4.8/5)