Noise Canceling in Audio Signal With Adaptive Filter
Noise Canceling in Audio Signal With Adaptive Filter
Noise Canceling in Audio Signal With Adaptive Filter
John Christakis
Logothetis Antonis
Mpalolakis Antonis
Boulgaris Konstantinos
Gogornas Ioannis
Theodore P. Chinis
Electronic Engineering
Technological Educational Institute of Athens
Agiou Spyridonos
12210
Egaleo
GREECE
Abstract: - In this paper, an adaptive noise canceller will be presented and some useful
observations will be done with the canceling process over the audio signal
1 Introduction
All the physical systems when they operate, they produce physical noise, which is a mixing of
an infinitive number of sinusoidal harmonics with different frequencies. So, the initial signal
information is corrupted with this noise. This complex signal, may be very noisy, so much that
the human ear or other system which may follow it, cannot receive correct the initial signal.
So, an algorithm has to be invented which must be able to separate the physical noise from the
information signal and to output the information signal without noise. This is not possible, as
there is not a perfect system. So, this algorithm should have the ability to reduce the noise level
as much as it can.
A good noise-canceling algorithm is the algorithm, which is presented in this paper. This
algorithm is based on the Least Mean Square algorithm. This system, operates like an automatic
control system with feedback where the feedback performs an adaptation to the filter
coefficients, otherwise it adjust the filtering of the noise in each sample.
2 Problem formulation
A simple audio signal is represented by the following mathematical equation
x(n) sin( 2 * pi * fo / fs * n)
Where f 0 is the frequency of the audio signal, fs is the sampling frequency and
c n sin 2 * pi * fo / fs * n noise n
So, the problem is to extract the useful signal from this complex signal.
Output - yk
+
Noise(n) - d(n)
Adaptive Filter
Wk+1
error(n)- e k
ek y k WkT X k
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:
0 1
max
Where max is the maximum eigenvalue of the input data covariance matrix In practice, Wk
never reaches the theoretical optimum (the Wiener solution), as the algorithm iteration step can
never be zero but it has a discrete value.
Furthermore, the LMS algorithm can be summarized in the next equation for the implementation
of the filter.
N 1
7 y k wi k * u k i
i 0
h( 1) h( ) u ( )e( )
In which: e( ) d ( ) y k
In the above equation, T denotes the transpose of the vector hinv . The desired response d ( )
can be found from the adaptive filter scheme to be
d ( ) hxT ( ) w( g )
10
u (k ) u ( ) u ( 1) ...............u ( N 1)
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 x(n)
Output y(n)
+
Noise d(n)
Adaptive Filter
Wk+1
error(n)
11 ( )
2
u k
where is a positive constant, usually less than 2 , and is a small positive constant. The
2
symbol u ( ) is the energy of the signal in a predefined buffer.
3.1 Implementation of the adaptive filter noise canceller in matlab and waveforms
The adaptive noise canceller was implemented in matlab as it offers the opportunity for a quick
and very professional way to study the whole operation of the system.
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;
%***********************
%***** 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.
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