DSPRelated.com
Forums

problem with reference signal in LMS algoritm

Started by ralph November 18, 2005
I want to use LMS algoritm to adaptive noise cancellation. The problem
is that I have only primary signal and thats all what I have, I don't
know anything aboyt reference signal, and my question is: how can I get
reference signal? What should I take as reference signal? Please help
me with this problem

Ralph,

Have you read anything about LMS adaptive filtering?  What have you
read? What have you learned? What is the application?  Do you have some
reason to believe adaptive filtering will work?

Dirk

I have application in MATLAB, I have offcourse read more about LMS
adaptive filtering, and I  don't know if the LMS will work without
reference signal witg ref mic

"ralph" <rklimski@o2.pl> wrote in news:1132325514.108631.22490
@o13g2000cwo.googlegroups.com:

> I want to use LMS algoritm to adaptive noise cancellation. The problem > is that I have only primary signal and thats all what I have, I don't > know anything aboyt reference signal, and my question is: how can I get > reference signal? What should I take as reference signal? Please help > me with this problem > >
The first thing to consider is what are the characteristics of the signal that you are trying to separate (What would an ideal reference signal be?) If by noise you mean broadband (white) noise, then usually a short delay is inserted in the signal path to represent the reference. This is called a single channel ANC. The basic idea is that white noise is only correlated to itself at the same time but the desired signal will still be highly correlated to itself a short time later. This is all explained in any of the adaptive filter books. I like Widrow & Stearns book the best. -- Al Clark Danville Signal Processing, Inc. -------------------------------------------------------------------- Purveyors of Fine DSP Hardware and other Cool Stuff Available at http://www.danvillesignal.com
So I have input signal and I generated white noise in MATLAB
(randn(1,len)) and my primary signal is: PRIMARY = SIGNAL + WHITENOISE,
and then I generated another whiteNoise and use it as a reference
signal, so it should work, but it didn't, what did I wrong?

"ralph" <rklimski@o2.pl> wrote in news:1132326355.317896.84410
@g44g2000cwa.googlegroups.com:

> So I have input signal and I generated white noise in MATLAB > (randn(1,len)) and my primary signal is: PRIMARY = SIGNAL + WHITENOISE, > and then I generated another whiteNoise and use it as a reference > signal, so it should work, but it didn't, what did I wrong? > >
It needs to be the same white noise. -- Al Clark Danville Signal Processing, Inc. -------------------------------------------------------------------- Purveyors of Fine DSP Hardware and other Cool Stuff Available at http://www.danvillesignal.com
Off course if I use the same white noise it works well, but in same
situations I only know that signal, which I have is with white noise,
but I haven't got that white noise. So I generate my own white noise -
could it works good?

Ralph,

Let me try again.

Have you read Widrow's IEEE article on adaptive filtering?  If not,
what have you read, and what level of understanding do you have?

Second, IN DETAIL, what is your application? What is the character of
the clean signal, the character of the noise, how are they combined,
how is the mixed signal obtained? What have you tried? Why did you try
what you did?

It works better if you have gotten what information you can and have
given it some thought before you post a question and if you tell us as
much information information about your problem, and attempted
solutions. A WHOLE LOT of people coming here don't understand that.

Dirk

Dirk,
   I have read about adaptive filtering in "Advanced Signal Processing
and Digital Noise Reduction" and some books in polsish. What level of
understanding? So I think that I knew much about the LMS algoritm, this
is code which I use in MATLAB, the main loop:
-------------------------------
 for n = 1:N;
   %offset n so we can reference the correct value in zero-padded fref
   if (n > 100)
       mu=0.1; % the step first mu = 0.32
   end;
   m = n + noCoefficients -1;
   frefblock = frefpad(m-noCoefficients+1:1:m)';  % its my reference
signal
   refP(n) = w(n,:)*(frefblock);
   output(n) = primary(n) - refP(n);
   w(n+1,:) = w(n,:) + mu.*frefblock'.*output(n);  % updating weights
end;
-----------
and this is all application with comment:
-----------------------------------------------------------------

clear all;
close all;

noCoefficients = 3;

y = wavread('primary.wav'); %whiteNoise_1 = randn(1,N)/4; primary =
signal + whiteNoise_1; wavwrite(primary,10000,8,'primary.wav');
signal = y';


N = length(signal);
t=1:N;

primary = signal;

fref = wavread('whiteNoise.wav')'; % whiteNoise = randn(1,N)/4;
wavwrite(szum,10000,8,'whiteNoise.wav');
% whiteNoise_1 is not equal whiteNoise, but both of them were generated
by randn() function in MATLAB
w(1,:) = ones(1,noCoefficients);
mu = .32;

%Zero pad so we can start filter at 0 and not throw of the index
frefpad = [zeros(1,noCoefficients-1) fref]; %wstawienie dwoch zer
-------------------
the clean signal is speech, the character of the noise: white noise, I
generated white noise in matlab using function: randn(); my primary
signal = sinal clean + whiteNoise_1; I tried to cleaning my primary
signal using the whiteNoise_1 (and off course it works well), and
suppose we only have primary signal (we didn't have reference signal)
and suppose we know that the primary signal is mixed with white noise,
so I tried go generated my own whiteNoise_2 using the same fnction in
MATLAN (randn()) and it did/t work; I also tried to using my primary
signal as a reference signal by delay, exactly like that:
ref = signal(200:length(signal))
ref=[ref signal (1:200)]
------- it also did't work
My question is:
How can I get the clean output having on input only primary signal?



for n = 1:N;
   %offset n so we can reference the correct value in zero-padded fref
   n
   if (n > 100)
       mu=0.1;
   end;
   m = n + noCoefficients -1;
   frefblock = frefpad(m-noCoefficients+1:1:m)';
   refP(n) = w(n,:)*(frefblock);
   output(n) = primary(n) - refP(n);
   w(n+1,:) = w(n,:) + mu.*frefblock'.*output(n);
end;

w(length(w),:)


figure;hold on
for ii = 1:noCoefficients;
   plot(w(:,ii),'r');
end;

figure;
subplot(3,1,1);
plot(primary);axis([0 length(primary) min(primary) max(primary)]);
title('primary microphone signal');
subplot(3,1,2);
plot(output);axis([0 length(primary) min(signal)-.5 max(signal)+.5]);
title('filtered output');

wavwrite(primary,10000,8,'primary.wav');
wavwrite(output,10000,8,'output1.wav');

Ralph,

The reference signal is not going to be another generated white noise
signal. To work the two white noise signals would have to be
correlated.  The reference signal will commonly be a delayed version of
the noisy input signal (which you said you tried).  The delay would
normally be a multiple of the pitch period. You must also chose the
proper output (the difference output or the predictive filter output).
You would chose the first output when you put exactly the same noise in
as a reference, and the second output when you put in the delayed noisy
speech as a reference.

And, UNFORTUNATELY, if the system is working perfectly it may not work
well enough to be real impressive.

Dirk