DSPRelated.com
Forums

NLMS and ERL above 0dB

Started by Mauritz Jameson June 7, 2012
Oh ...and by the way....My simulations show that for some scenarios
the optimal update gain is above 1. I don't know if that is correct,
but that's what my simulations show for my particular NLMS simulation.
On 6/9/12 12:18 PM, Mauritz Jameson wrote:
> >> I hope you're simulating the algorithm before trying to implement it. > > Yes, I'm running simulations in MATLAB because I don't want to spend > too much time chasing errors when I finally implement it. > > >> 1. Are you using fixed-point or floating-point simulation? > > Floating point. Once I have the algorithm working in MATLAB I will > make a floating point implementation in C and then once that has been > verified to work I will translate the math to fixed point. >
the size of scalers will be important. try to figure out how big they're expected to get in the floating-point simulation. that'll help you translate well to fixed point..
> >> 2. What is your simulated unknown impulse response (including length of delay)? > > The impulse response I am using for the acoustic path has 512 filter > coefficients. The delay is 18 samples (I filtered an impulse and the > largest peak in the output happens after 18 samples).
well, that of course depends on what the NLMS is adapting to. does it appear to be the case that the last 400 or so coefficients are far closer to zero than the peak at sample 18? or smaller and really randomized in appearance? or are there additional reflections happening at later than 18 samples that you are going after? as long as the acoustic transducers are not physically moved, does the NLMS settle down to match an constant impulse response?
> >> To test your basic algorithm you should be using a white-noise source, not speech. Once you are satisfied with the basic algorithm, then start looking at specialized signals. >
i dunno if i agree with that. it might be a less robust test. i think white noise is what you want to use to throw your algorithm a soft ball.
> Ok. I didn't know that. I thought it was better to use it on actual > speech signals instead of signals which the algorithm won't encounter > in "the real world". >
test it, thoroughly, with speech as well as initially with white noise. and maybe find some other sources like car horns or rooms with a lot of people talking (which might be pinker in color).
> >> The "ideal" update gain depends on the input signal. With the NLMS, a gain of 1 is best for white noise. HOWEVER, since the LMS and NLMS estimates the Wiener filter, which requires the inverse of the input autocorrelation matrix,if the input is sinusoid type, the inverse matrix does not exist, and there is no unique solution. This can hurt fixed-point implementations if you are not careful with the update gain. > > How should I be careful ? Should the update gain be lower than > "normal" ? I have noticed that the update gain highly depends on the > power of the speaker signal. The lower the power the higher the update > gain can be. Is that a correct observation? >
one thing that is common with LMS filters that are used for speaker-phone cancellation, is that the adaptation gain is reduced when there is "double talk", when both the speaker is talking (this would be the e[n] that gets added to the "desired signal" d[n]) and there is direct and echo feedback, the d[n], which means there is some non-zero signal in x[n]. someone else here might have a far better idea than me for how that downward adjustment to the adaptation gain is done when there is "double talk".
> >> I ran a quick floating-point simulation with white noise where the magnitude of the echo was 1.5 times the input, and the algorithm ran with no problems. > > That's nice to know. I will do the same then. > > I look forward to your feedback. Thank you!! >
On 6/9/12 12:21 PM, Mauritz Jameson wrote:
> Oh ...and by the way....My simulations show that for some scenarios > the optimal update gain is above 1. I don't know if that is correct,
it might be. is that mu defined to be roughly the same if the filter order (it's "p" in the Wikipedia page on NLMS) or does it increase roughly linearly with the FIR length "p"?
> but that's what my simulations show for my particular NLMS simulation.
it sorta depends if that normalizing scaler is p ( SUM{ (x[n-i])^2 } )^(-1) i=0 or p ( (1/P) SUM{ (x[n-i])^2 } )^(-1) i=0 -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Should I remove DC from the speaker and mic signal before running it
through the NLMS algo?

It seems like I get better results if I apply this FIR filter to the
mic and spk signal before they're processed by the NLMS algo:

NUM = [1 -0.98]
DEN = 1;


> well, that of course depends on what the NLMS is adapting to. �does it > appear to be the case that the last 400 or so coefficients are far > closer to zero than the peak at sample 18?
Yes. Some are above positive and some are negative...Looks like "mountains" if you zoom in on the tail...
> acoustic transducers are not physically moved, does the NLMS settle down > to match an constant impulse response?
Yes...but the funny thing is that sometimes I see ripples waving through on both sides of the peak in the estimated FIR coefficient vector
> one thing that is common with LMS filters that are used for > speaker-phone cancellation, is that the adaptation gain is reduced when > there is "double talk", when both the speaker is talking (this would be > the e[n] that gets added to the "desired signal" d[n]) and there is > direct and echo feedback, the d[n], which means there is some non-zero > signal in x[n]. �someone else here might have a far better idea than me > for how that downward adjustment to the adaptation gain is done when > there is "double talk".
Yes, but how do you distinguish between double-talk and a temporarily unconverged NLMS filter. In both cases you are going to see a signal on the output side and it can be either echo coming through because the NLMS filter hasn't converged or it can be a near-end signal. I calculate the update gain like this: powerOfSpeakerSignal = sampleBuffer*(sampleBuffer'); updateGain = mu*sampleError/powerOfSpeakerSignal; where sampleBuffer contains the time-reversed speaker samples. where mu is a constant and where sampleError = actualMicrophoneSample - estimatedMicrophoneSample;
On Thursday, June 7, 2012 7:58:59 PM UTC-5, Mauritz Jameson wrote:
> Hi > > I'm playing around with a traditional NLMS algorithm for acoustic echo > cancellation. > > It seems like the NLMS algorithm have a hard time cancelling the echo > as soon as the ERL level creeps above 0dB. > > Is that to be expected? > > The speaker signal is pure speech (no noise) and I have linearly > filtered the speaker signal to have a simulated microphone signal. The > adaptive filter order is 512 taps. > I have made a test script which tests the NLMS algo with various step > sizes ranging from very small (0.00001) to 1. For low step sizes > nothing happens (the echo is not cancelled) and > then at some point it just breaks (the error has a huge output ...like > an impulse)... > > Is there a way to calculate the optimal step size given no > interference (i.e. no near-end signal) and also given that there is > some interference ?
Mauritz, Hi. Don't worry about double-talk at the moment. That is a different convergence problem associated with the condition that the near-end and far-end signals are correlated (review what the NLMS approximates). If you can't convergence using white noise with echos that are greater than the input, you have bigger problems. As far as being able to use coefficients greater than 1, I suggest you look at my article in IEEE Signal Processing Magazine about enhanced convergence of the NLMS. For now, use an update gain of 1, use white noise, and see if you can converge with an echo 1.5 times greater than the input. Your error signal should be very close to zero. The reason to use white noise is simple. Unless your impulse response is an impulse, it will be frequency dependent. Speech does not possess all frequencies at the same time. Therefore, your filter will converge to those frequencies present in the speech signal, then change when the speech signal changes. This means that as the frequency content changes, you could actually loose the innovation you had for the past frequencies. For now, use white noise. You can move to speech signals after you get the algorithm running. How big is you Matlab program? If not too big, share it.
On Thursday, June 7, 2012 7:58:59 PM UTC-5, Mauritz Jameson wrote:
> Hi > > I'm playing around with a traditional NLMS algorithm for acoustic echo > cancellation. > > It seems like the NLMS algorithm have a hard time cancelling the echo > as soon as the ERL level creeps above 0dB. > > Is that to be expected? > > The speaker signal is pure speech (no noise) and I have linearly > filtered the speaker signal to have a simulated microphone signal. The > adaptive filter order is 512 taps. > I have made a test script which tests the NLMS algo with various step > sizes ranging from very small (0.00001) to 1. For low step sizes > nothing happens (the echo is not cancelled) and > then at some point it just breaks (the error has a huge output ...like > an impulse)... > > Is there a way to calculate the optimal step size given no > interference (i.e. no near-end signal) and also given that there is > some interference ?
Oh yes, I forgot to add. If you do not dedicate a coefficient in your filter to the DC component, then YES you should filter it out.
On 6/11/12 12:01 PM, maury wrote:
> > If you do not dedicate a coefficient in your filter to the DC component, then YES you should filter it out.
while i do not disagree with the advise to put in a DC blocking filter, i don't understand the concept of dedicating a coefficient in the LMS filter to DC. that "DC coefficient" is actually the sum of all of the h[n] coefficients in the LMS FIR. i s'pose you could calculate and subtract the mean of the h[n], and that would be like setting that hypothetical DC component to zero. either way, it's not a bad idea to filter the DC out of the "desired" signal, d[n]. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Just to make sure I understand.

Are you saying that I should remove DC from the error signal?

Right now I am just pre-filtering the microphone and speaker signal.
The DC-suppressed mic and speaker signal are then handed over to the
NLMS algorithm.

I will share the MATLAB code later today...

Thank you for all the feedback so far...
On 6/11/12 3:49 PM, Mauritz Jameson wrote:
> Just to make sure I understand. > > Are you saying that I should remove DC from the error signal?
it wasn't what i meant to say. i meant x[n] which is the speaker signal, if you are doing speakerphone feedback cancellation. the "error signal", e[n], is actually your net microphone signal after your NLMS attempts to remove (via subtraction in the digital domain) the acoustic coupling into the microphone from the loudspeaker. i guess it's d[n], the "desired signal" is the raw data that comes in from your mic.
> > Right now I am just pre-filtering the microphone and speaker signal. > The DC-suppressed mic and speaker signal are then handed over to the > NLMS algorithm.
that might be okay. i might do it to the speaker and not the mic, but because of the DC offset that might occur with the mic preamp and A/D conversion, it might be a good idea to DC block the mic input also. if you DC block both x[n] and e[n] and if your NLMS is behaving well, the mean value (or sum) of the FIR coefficients *should* tend to add to zero on average. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Maury,

Here is a link to the code:

https://www.dropbox.com/s/ptw44onhtydv8d0/nlmsAlgorithm.zip