Sie sind auf Seite 1von 6

Digital Signal Processing — Lab 2

Adaptive Noise Cancelation

This version: November 2009

LERTEKNIK
REG

Name:

P-number:

AU L Date:
T O MA RO
TI C C O N T
Passed:
LINKÖPING
1 Introduction
The task is to create an adaptive filter for active noise cancelation. The problem
is non-trivial since there is also a signal that should not be affected. For instance,
in a airplane the sound from the engine should be suppressed, but the voice of
the stewardess should not be affected.
In this lab, music is polluted by a noise signal, e.g. a sum of sine signals or a
square wave. The goal is to suppress the noise so that the music appears more
clearly. One microphone is recording the mixed sound and one microphone is
recording the noise signal. The signal processing, where the noise is suppressed,
is done in Simulink in real time and you can listen to the result in a pair of
headphones.
This lab is performed in groups of two (or one) persons during four hours
in Laboteket. To be able to finish the lab during this time, a number of prepa-
ration exercises must be done, see Section 6. The lab is completed by an oral
examination where the questions in this compendium are reviewed.
To copy the lab-files, select Start – Run in Windows, write
\\site\edu\rt\lab and press enter. Copy the folder named cancelnoise to a
suitable location on your account. Then start Matlab and go to that directory.

2 Hardware arrangement
The hardware setup must be arranged according to Figure 1. The noise mi-
crophone should be a few centimeters from the noise source to minimize its
exposure to the music. The channel microphone is placed 1-2 meters from both
sources, see Figure 2.

Figure 2: Microphone and loud-


Figure 1: Connections to the sound speaker arrangement.
card.

3 Channel model
The channel is the air between the source and the microphone, but also the
microphone itself. It is not enough to model the channel as a pure time delay,

3
since the sound is reflected in the surroundings. Thus, the signal recorded by the
microphone is the sum of multiple time delayed and damped sound reflections.
In addition, different frequencies are damped and phase shifted in different ways
so the reflected signal is not the same as the original signal. A common and
physically reasonable channel model is

y(t) = B(q)u(t−nk ) = b0 u(t−nk )+b1 u(t−1−nk )+· · ·+bnb u(t−nb −nk ), (1)

i.e, a FIR-filter of order nb with a unknown time delay nk . The time delay is
caused by the finite speed of sound in air, but also delays in the electronics and
the computer software. A rough estimate of the time delay can be calculated
by measuring the distance from the microphone to the speaker. Hence, the
measured signal y(t) and the source signal u(t) are not synchronized.
There are a number of algorithms for estimating the time delay, we will in
this lab use two simple approaches:

• Estimate a FIR filter of order nb + nk . This will result in the first nk


estimates being close to zero.

• Estimate the time delay in advance by correlating the input and output
signals. Use this time delay as nk when the FIR filter is estimated.

Note that the time delay may vary from run to run, since the recordings may
not start in an identical way.

4 Exercise 1: Channel modeling


The task is to model the channel dynamics by just considering the noise source.
Thus, the noise source is the only source used in this exercise. Make sure that
the arrangement is as described above. Open the Simulink file

>> lab2a

Set the sample frequency to 11025 Hz by defining the variable sampletime.


Start the simulation, it will continue for 10 sec. The signals from the noise and
channel microphones are stored in the Matlab workspace as 3D variables u
and y, respectively. Plot the signals and select a suitable sector about 1 second
long. (You can remove the extra dimensions by using the :-operator, see below.)
Collect data for different types of noise signals. The noise signal type is selected
in the block called “Source selector” and there are four different types:

• Bandlimited White Noise; white noise filtered by a band pass filter.

• MultiSine; a sum of a number of sine signals with different frequencies.

• Chirp; a sine whose frequency is changing linearly over time.

• Square Wave.

Model the channel dynamics with a FIR filter y(t) = B(q; θ)u(t). Do not
forget to remove the mean of the signal by using detrend. The coefficients of
the FIR filter is estimated by the following commands:

4
>> y=y(:);
>> u=u(:);
>> th=arx([y u],[0 nb nk]);
>> bhat=th.b;

Thus, it is now possible to eliminate most of the noises by using the inverse
filter ŝ = y − B(q, b̂)u.

Questions
1. Begin with the determination of nk ! Test different approaches to estimate
nk based on the preparation exercises. What are the problems with the
different approaches?

2. What is the best model order nb ? Motivate in a couple of different ways.

3. How much is the energy in ŝ decreased compared to y? Use a suitable


energy ratio and examine all the different noise types.

4. Compare the estimated model from different noise signals. Are the results
the same?

5. Which noise signal is the easiest to suppress? Explain why!

Hints
• Write a m-file that is stored in your account, so it is straightforward to
repeat the computations.

• Before using a recorded signal, check that it looks “nice”.

• Do not use the whole data set (of length 10 sec) in the estimation!

• The data set can be stored for later use with the save command.

5 Exercise 2: Real-time noise cancellation


The task is to cancel out the noise signal in real-time. Use the same arrangement
as before. Open the Simulink file

>> lab2b

Make sure that the sampling frequency is 11025 Hz by defining sampletime.


Adjust the LMS parameters [1 nb nk] by opening (double clicking) the LMS
block. Note that na is always 1 to compensate for a non-zero mean value.
The step length in LMS is decided by the parameter mu. Start the simulation.
Adjust the volume such that the sound sources are equally strong. Now the
filter should converge in a few seconds. This will be heared in the head phones.
Try moving the channel microphone and listen to how the filter converges. Also,
switch between noise canceled signal and the untreated signal to experience the
difference.

5
Questions
1. What is the difference between listen to the untreated signal in the head-
phones and putting the ear at the position of the channel microphone?
2. How can different µ be heard?
3. Assume that we know that one of the noise signals in Exercise 1 is used,
but we do not know which one. How should the parameters nb and nk be
selected in the real-time case, based on the knowledge from Exercise 1?

4. Which noise signal is easiest to cancel out? Is this the same signal that
was easiest to handle in Exercise 1? If not, explain why!

6 Preparation exercises
Given the conditions of this lab, give answers to the following questions:

1. Is it possible to estimate the time delay by

• geometrical measurements?
• visual examination of the signals by using Matlab’s plot functions?
• computing R=xcorr(y,u,M)?
• modeling th with a large nb and a small nk and then compare th.b
and th.db? (present(th) can be used)

If the answer is “yes”, explain how this can be done and if there are some
drawbacks with the method.

2. Why is the time delay nk varying?


3. How is the step length µ of the LMS affecting the performance?
4. Which measures can be used to evaluate the performance of the model?
5. What is the largest difference, in terms of order selection, between on-
line and off-line modeling in the case where the optimal model order is
changing between the runs?

Das könnte Ihnen auch gefallen