Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Adaptive Noise Cancellation Using

RLS Adaptive Filtering

In the following model, an RLS filter to extract useful information from a noisy
signal. The information bearing signal is a sine wave that is corrupted by additive
white Gaussian noise.
The adaptive noise cancellation system assumes the use of two microphones. A
primary microphone picks up the noisy input signal, while a secondary microphone
receives noise that is uncorrelated to the information bearing signal, but is
correlated to the noise picked up by the primary microphone.

1) The model illustrates the ability of the Adaptive RLS filter to extract
useful information from a noisy signal.
2) The information bearing signal is a sine wave of 0.055 cycles/sample.
3) The noise picked up by the secondary microphone is the input for the
RLS adaptive filter. The noise that corrupts the sine wave is a low pass
filtered version of (correlated to) this noise. The sum of the filtered noise
and the information bearing signal is the desired signal for the adaptive
filter.
4) The noise corrupting the information bearing signal is a filtered version
of 'noise'. Initialize the filter that operates on the noise.

5) Set and initialize RLS adaptive filter parameters and values:


6) Running the RLS adaptive filter for 1000 iterations. As the adaptive
filter converges, the filtered noise should be completely subtracted from
the "signal + noise". Also the error, 'e', should contain only the original
signal.
7) The plot shows the convergence of the adaptive filter response to the
response of the FIR filter.
Noise Cancellation Using Adaptive Filter
Matlab code:

%% Noise Cancellation Using Adaptive Filtering

% The information bearing signal is a sine wave that is corrupted by additive white Gaussian noise.

%%

% The program illustrates the ability of the Adaptive filter to extract useful information from a noisy
signal.

priv_drawrlsdemo
axisoff
%%

% The information bearing signal is a sine wave of 0.055 cycles/sample.

signal = sin(2*pi*0.055*(0:1000-1)');
signalSource = dsp.SignalSource(signal,'SamplesPerFrame',100,...
'SignalEndAction','Cyclic repetition');

plot(0:199,signal(1:200));
grid; axis([0 200 -2 2]);
title('The information bearing signal');
%%

% The noise picked up by the secondary microphone is the input for the RLS adaptive filter.

%The noise that corrupts the sine wave is a lowpass filteredversion of (correlated to) this noise.

% The sum of the filtered noise and the information bearing signal is the desired signal for the adaptive
filter.

nvar = 1.0; % Noise variance


noise = randn(1000,1)*nvar; % White noise
noiseSource = dsp.SignalSource(noise,'SamplesPerFrame',100,...
'SignalEndAction','Cyclic repetition');

plot(0:999,noise);
title('Noise picked up by the secondary microphone');
grid; axis([0 1000 -4 4]);
%%

% The noise corrupting the information bearing signal is a filtered version of % 'noise':

%Initialize the filter that operates on the noise%


lp = dsp.FIRFilter('Numerator',fir1(31,0.5));% Low pass FIR filter
%%
% Set and initialize RLS adaptive filter parameters and values:

M = 32; % Filter order


delta = 0.1; % Initial input covariance estimate
P0 = (1/delta)*eye(M,M); % Initial setting for the P matrix
rlsfilt = dsp.RLSFilter(M,'InitialInverseCovariance',P0);

%%
%Running the RLS adaptive filter for 1000 iterations.
%As the adaptive filter converges, the filtered noise should be completely subtracted from the "signal +
noise".
%Also the error, 'e', should contain only the original signal.
scope = dsp.TimeScope('TimeSpan',1000,'YLimits',[-2,2], ...
'TimeSpanOverrunAction','Scroll');
for k = 1:10
n = noiseSource(); % Noise
s = signalSource();
d = lp(n) + s;
[y,e] = rlsfilt(n,d);
scope([s,e]);
end
release(scope);

%%
%The plot shows the convergence of the adaptive filter response to the response of the FIR filter.
H = abs(freqz(rlsfilt.Coefficients,1,64));
H1 = abs(freqz(lp.Numerator,1,64));

wf = linspace(0,1,64);

plot(wf,H,wf,H1);
xlabel('Normalized Frequency (\times\pi rad/sample)');
ylabel('Magnitude');
legend('Adaptive Filter Response','Required Filter Response');
grid;
axis([0 1 0 2]);

You might also like