Noise Canceling in Audio Signal With Adaptive Filter: 2 Problem Formulation
Noise Canceling in Audio Signal With Adaptive Filter: 2 Problem Formulation
Noise Canceling in Audio Signal With Adaptive Filter: 2 Problem Formulation
th
k
Controls the stability
and rate of convergence.
The steepest descent algorithm in the
previous equation still requires knowledge
of R and P , since
k
is obtained by the
next equation.
( ) 0 2 2 4 = + = = RW P
dW
dJ
k
The LMS algorithm is a practical method of
obtaining estimations of the filter weights
W
k
in real time without the matrix inversion
of the next equation or the
direct computation of the autocorrelation
and cross correlation. The Widrow Hopf
LMS algorithm for updating the weights
from sample to sample is given by
P R W
opt
1
=
( )
k k k k
e X W W 2 5
1
+ =
+
+
Where:
k
T
k k k
X W y e =
Clearly, the LMS algorithm above does not
require prior knowledge of the signal
statistics (that is the correlations R and P ),
but instead uses their instantaneous
estimations. The weights obtained by the
LMS algorithm are only estimations, but
these estimations improve gradually with
time as the weights are adjusted and the
filter learns the characteristics of the signal.
Eventually, the weights converge. The
condition of convergence is:
( )
max
1
0 6
> <
Where
max
is the maximum eigenvalue of
the input data covariance matrix In practice,
never reaches the theoretical optimum
(the Wiener solution), as the algorithm
iteration step can never be zero but it has a
discrete value.
k
W
Furthermore, the LMS algorithm can be
summarized in the next equation for the
implementation of the
filter.
( ) ( ) ( ) ( )
+
=
=
1
0
* 7
N
i
i
i k u k w k y
( ) ) ( ) ( ) ( ) 1 ( 8 e u h h + = +
In which: ( ) k y d e = ) ( ) (
Adaptive
Filter W
k+1
Volume 45, Number 6, 2004 601
In the above equation, denotes the
transpose of the vector . The desired
response
T
inv
h
) ( d can be found from the
adaptive filter scheme to be
( ) ) ( ) ( ) ( 9 g w h d
T
x
=
The notation ) ( u denotes a vector of
samples arranged as
( ) [
T
N u u u k u ) 1 ( . . .. . . . ) 1 ( ) ( ) ( 10 + = ]
Where is the order of the filter. N
3 Problem solution
The problem solution may be based on
standard adaptive techniques and especially
on the adaptive filter noise canceller.
This filter gets the physical noise and
filters it in such a way that the algebraic
addition with the complex signal produces a
new signal with a very low level of noise.
The schematic diagram of the adaptive filter
noise canceller was given above and it is
presented again in the following diagram.
Audio signal with noise
c( n) - u
k
Output - y
k
Noise
d(n)
error - e
k
Fig.4 The used adaptive noise canceller
As it can be observed, the adaptive filter
noise canceller is a system with feedback as
a system with automatic control. For this
reason, there is stability problem. The
problem arises when the error signals
amplitude increases in accordance with time
or when no convergence is obtained.
The mathematical algorithm, which is
used by the adaptive filter for the filters
coefficients update, is called LMS (Least
mean square) algorithm. This algorithm
tries to minimize the square of the error
signal so; the audio signal has been
reconstructed quite well.
The system output is the error signal. The
error signal is the algebraic subtraction
between the audio signal with noise and the
noise. When the LMS algorithm performs a
good convergence then the only error signal
is the audio signal. So, the error signal must
be the noise canceller output.
The LMS algorithm has also an initial
step variable , which is the step of the
convergence in each iteration. In the matlab
code where the adaptive filter noise
canceller is built, the NLMS algorithm
used. The only difference is that the step
variable , changes in each iteration with
the next equation:
( )
( )
2
) ( 11
k u +
=
where is a positive constant, usually less
than , and 2 is a small positive constant.
The symbol
2
) ( u is the energy of the
signal in a predefined buffer.
3.1 Implementation of the adaptive
in matlab and
waveforms
filter noise canceller
+
The adaptive noise canceller was
implemented in matlab as it offers the
opportunity for a quick and very
operation of the system.
professional way to study the whole
The matlab code, which was written, is
presented now.
function [x] = noice_canceller
clear all;
%**********************
%**** Time Base *******
%**********************
N = 2000;
n = 1:1:N;
%***********************
%**** System Vars
%***********************
fo = 500;
Fs = 44100;
db = 5;
%***********************
Adaptive
Filter W
k+1
ACTA ELECTROTEHNICA 602
%***** Signal Generation
%***********************
audio = sin(2*pi*fo/Fs*n); %+
0.7*sin(2*pi*5*fo/Fs*n));
%**********************
%**** Noise Generation
%*********************
%noise_plus_audio = awgn(audio,db);
noise = wgn(1,N,db)/2;
%noise = 0.1*randn(1,N);
for i=1:1:N
noise_plus_audio(i) = (audio(i) + noise(i)/2);
end
%**************************************
%**** Initialization of Noise Canceller
%**************************************
w0 = zeros(1,32); % Initial filter coefficients
%wi = zeros(1,255);
mu = 0.4; % LMS step size
S = initnlms(w0,mu,[],1);
%***************************************
%***** Apply Noise Canceller over signal
%***************************************
for i=1:1:N
[y,canceller_output(i),S] =
adaptnlms(noise(i),noise_plus_audio(i),S);
%***************************************
%***** Calculate FFT of Signals
%***************************************
ff_mix = abs(fft(noise_plus_audio,1024));
ff_output = abs(fft(canceller_output,1024));
%***************************************
%***** Calculate Error
%***************************************
error(i) = audio(i) - canceller_output(i);
%***********************
%*** Plots *************
%***********************
subplot(6,1,1);
plot(noise_plus_audio,'r');
axis([0 N -2 2]);
title('Signal and Noise');
subplot(6,1,2);
plot(audio,'g');
axis([0 N -2 2]);
title('Audio Signal');
subplot(6,1,3);
plot(canceller_output,'b');
title('Canceller Output');
axis([0 N -2 2]);
subplot(6,1,4);
plot(ff_mix,'r');
title('FFT of Mixed Signal');
subplot(6,1,5);
plot(ff_output,'r');
title(' FFT of Output');
subplot(6,1,6);
plot(error,'g');
axis([0 N -2 2]);
title('Error of FFT');
drawnow;
end
The output waveforms of the system are
plotted in the next figure.
Fig.5 Noise canceller output waveforms
4 Conclusion
To sum up, the adaptive noise canceller is
a very efficient and useful system in many
applications with sound, video etc. The only
disadvantage is that it needs digital signal
processor DSP for its operation.
References:
[1] Simon Haykin, Adaptive Filter Theory,
Prentice Hall 2002
[2] LMS adaptive-filtering
algorithm: Taylor, John T. and Qiuting
Huang: Electrical Filters. New York:
CRC Press, 1997 pp. 207-214.
[3] B. Widrow, J. R. Glover, Jr., J. M.
McCool, J. Kaunitz, C. S. Williams, R.
H. Hearn, J. R. Zeidler, E. Dong, Jr., and
R. C. Goodlin, "Adaptive noise
cancelling: Principles and applications,"
Proc. IEEE, vol. 63, pp. 1692--1716,
Dec. 1975.