DSPRelated.com
Forums

adaptive sine-wave cancellation

Started by Robert Adams November 18, 2008
On Nov 19, 2:33&#4294967295;pm, Glen Herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
> Robert Adams wrote: > > Thanks for the suggestions. Yes, the frequency is very well known, so > > on initial startup I could do as you suggest. The problem is that the > > frequency varies over about a 2:1 range over a period of a few > > seconds, and as the frequency varies the phase of the cancellation > > path can vary by a lot; so I would need to "re-start" which means > > setting the cancellation path to zero and then trying a few different > > cancellation phases to see which one pushes the error in the right > > direction; and the listener would of course experience a loss of > > cancellation during this time. > > I think you should be able to follow it if it is sufficiently > slow, and not if the change is too fast. &#4294967295;The PLL literature > should explain the how fast phase can change and keep the lock > as a function of the PLL parameters. > > It seems to me that you want a PLL for the phase/frequency > part and additional circuitry to lock the amplitude. > (Call it ALL for Amplitude Locked Loop.) &#4294967295;Then you need > sufficient damping in the two such that the combination > doesn't oscillate. > > -- glen
I already have a locked frequency, but the phase is the problem. I only have access to the microphone signal to steer the adaptation algorithm and this is the sum of the signal I am trying to cancel and the phase-shifted anti-noise signal I am generating. So what do I use as a reference to lock the phase to? Bob
On Nov 19, 1:44&#4294967295;pm, maury <maury...@core.com> wrote:
> On Nov 18, 6:45&#4294967295;pm, Robert Adams <robert.ad...@analog.com> wrote: > > > > > > > I am trying to solve the following problem; > > > I drive a speaker with a sine-wave of known frequency = w. > > A second speaker is driven with a signal that attempts to cancel the > > sound of the first speaker at a nearby microphone. > > > So the problem is to find the amplitude and phase of the cancellation > > signal that drives the cancellation speaker. > > > The transfer function from either speaker to the microphone is unknown > > and possibly slowly time-varying. It is not possible to measure it, as > > the user does not expect to hear any "calibration" signals. > > > Currently I use the following algorithm > > > let the microphone signal = M, and the cancellation signal C = A*cos > > (w*t) + B*sin(w*t) > > > update A and B according to > > > A sub(n+1) = A sub(n) + alpha*M*cos(w*t) > > > B sub(n+1) = B sub(n) - alpha*M*sin(w*t) > > > where alpha is a small update coefficient. > > > This works well when the phase-shift of the path from cancellation > > speaker to microphone is small (< 90 degrees), but with large phase > > shifts the polarity of the adaptive algorithm is reversed and the > > whole thing blows up. > > > If the speaker-to-mic phase shifts were known, one could of course pre- > > compensate the phase of the compensation signal and life would be good > > again; but this is not possible. Also, the signal to the main speaker > > cannot be tuned off. > > > Another complication is that the listener must perceive the sound > > gracefully decaying to zero, so this rules out any trial-and-error > > type of procedure. > > > Any suggestions? > > > Bob Adams > > It seems that you need to know in which direction to drive the anti- > signal. &#4294967295;That implies a gradient. &#4294967295;Also, it looks lilke you might be > trying to apply the gradient with your update equations. &#4294967295;IF THAT IS > THE CASE, I may be wrong, but it appears to me that > > A(n+1) = A(n) + alpha M cos(wt), &#4294967295;and > B(n+1) = B(n) + alpha M sin(wt) > > is NOT the gradient of the squared error, [M - (A'cos(wt) + B'sin(wt))] > ^2, where A' &#4294967295;and B' are estimates A and B in M = Acos(wt) + Bsin > (wt). &#4294967295;Nor is it the gradient of the error M - (A'cos(wt) + B'sin > (wt)). > > As I said, I may be wrong, but you might want to address your update > equations again. > > Maurice Givens- Hide quoted text - > > - Show quoted text -
Maurice I agree that this is not the ideal gradient but it works extremely well when the phase shift between the correction speaker and the microphone is small. I think ANY gradient will become confused (and in fact will switch polarity completely) in the presence of large amounts of phase shift. In a sense this problem is similar to the problem solved by the Filtered-X LMS algorithm, where there is another transfer function in series with the adaptive FIR before the error is taken. In my case the "other" trasnfer function is the cancellation-speaker-to-microphone path, but since we are talking only about sine-waves here, this path can be characterized simply by the amplitude and phase at the frequency of interest. In the Filtered-X LMS, the problem is solved by having a copy of the transfer function that exists in series with the adaptive FIR. In my case I cannot measure this path, which is the problem; if I knew the amplitude/phase of the cancellation-speaker-to-microphone path I could easily compensate for it. Bob Bob
Glen Herrmannsfeldt wrote:
> Robert Adams wrote: > >> Thanks for the suggestions. Yes, the frequency is very well known, so >> on initial startup I could do as you suggest. The problem is that the >> frequency varies over about a 2:1 range over a period of a few >> seconds, and as the frequency varies the phase of the cancellation >> path can vary by a lot; so I would need to "re-start" which means >> setting the cancellation path to zero and then trying a few different >> cancellation phases to see which one pushes the error in the right >> direction; and the listener would of course experience a loss of >> cancellation during this time. > > I think you should be able to follow it if it is sufficiently > slow, and not if the change is too fast. The PLL literature > should explain the how fast phase can change and keep the lock > as a function of the PLL parameters. > > It seems to me that you want a PLL for the phase/frequency > part and additional circuitry to lock the amplitude. > (Call it ALL for Amplitude Locked Loop.) Then you need > sufficient damping in the two such that the combination > doesn't oscillate.
The time lag between speaker output and microphone input is likely to make this a very difficult loop to stabilize if the signal to be canceled can vary at all rapidly. If the canceling speaker is within a tenth of a wavelength of the microphone at all frequencies with significant gain, simple negative feedback from microphone to speaker should work. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Robert Adams wrote:
> On Nov 19, 1:44 pm, maury <maury...@core.com> wrote: >> On Nov 18, 6:45 pm, Robert Adams <robert.ad...@analog.com> wrote: >> >> >> >> >> >>> I am trying to solve the following problem; >>> I drive a speaker with a sine-wave of known frequency = w. >>> A second speaker is driven with a signal that attempts to cancel the >>> sound of the first speaker at a nearby microphone. >>> So the problem is to find the amplitude and phase of the cancellation >>> signal that drives the cancellation speaker. >>> The transfer function from either speaker to the microphone is unknown >>> and possibly slowly time-varying. It is not possible to measure it, as >>> the user does not expect to hear any "calibration" signals. >>> Currently I use the following algorithm >>> let the microphone signal = M, and the cancellation signal C = A*cos >>> (w*t) + B*sin(w*t) >>> update A and B according to >>> A sub(n+1) = A sub(n) + alpha*M*cos(w*t) >>> B sub(n+1) = B sub(n) - alpha*M*sin(w*t) >>> where alpha is a small update coefficient. >>> This works well when the phase-shift of the path from cancellation >>> speaker to microphone is small (< 90 degrees), but with large phase >>> shifts the polarity of the adaptive algorithm is reversed and the >>> whole thing blows up. >>> If the speaker-to-mic phase shifts were known, one could of course pre- >>> compensate the phase of the compensation signal and life would be good >>> again; but this is not possible. Also, the signal to the main speaker >>> cannot be tuned off. >>> Another complication is that the listener must perceive the sound >>> gracefully decaying to zero, so this rules out any trial-and-error >>> type of procedure. >>> Any suggestions? >>> Bob Adams >> It seems that you need to know in which direction to drive the anti- >> signal. That implies a gradient. Also, it looks lilke you might be >> trying to apply the gradient with your update equations. IF THAT IS >> THE CASE, I may be wrong, but it appears to me that >> >> A(n+1) = A(n) + alpha M cos(wt), and >> B(n+1) = B(n) + alpha M sin(wt) >> >> is NOT the gradient of the squared error, [M - (A'cos(wt) + B'sin(wt))] >> ^2, where A' and B' are estimates A and B in M = Acos(wt) + Bsin >> (wt). Nor is it the gradient of the error M - (A'cos(wt) + B'sin >> (wt)). >> >> As I said, I may be wrong, but you might want to address your update >> equations again. >> >> Maurice Givens- Hide quoted text - >> >> - Show quoted text - > > Maurice > > I agree that this is not the ideal gradient but it works extremely > well when the phase shift between the correction speaker and the > microphone is small. I think ANY gradient will become confused (and in > fact will switch polarity completely) in the presence of large amounts > of phase shift. > > In a sense this problem is similar to the problem solved by the > Filtered-X LMS algorithm, where there is another transfer function in > series with the adaptive FIR before the error is taken. In my case the > "other" trasnfer function is the cancellation-speaker-to-microphone > path, but since we are talking only about sine-waves here, this path > can be characterized simply by the amplitude and phase at the > frequency of interest.
Think of it as a servo. Phase is only a frequency-dependent manifestation of delay.
> In the Filtered-X LMS, the problem is solved by having a copy of the > transfer function that exists in series with the adaptive FIR. In my > case I cannot measure this path, which is the problem; if I knew the > amplitude/phase of the cancellation-speaker-to-microphone path I could > easily compensate for it.
Can't you find that with a test tone? If you know the delay, you can calculate phase at any frequency. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Nov 20, 1:17&#4294967295;am, Jerry Avins <j...@ieee.org> wrote:
> Robert Adams wrote: > > On Nov 19, 1:44 pm, maury <maury...@core.com> wrote: > >> On Nov 18, 6:45 pm, Robert Adams <robert.ad...@analog.com> wrote: > > >>> I am trying to solve the following problem; > >>> I drive a speaker with a sine-wave of known frequency = w. > >>> A second speaker is driven with a signal that attempts to cancel the > >>> sound of the first speaker at a nearby microphone. > >>> So the problem is to find the amplitude and phase of the cancellation > >>> signal that drives the cancellation speaker. > >>> The transfer function from either speaker to the microphone is unknown > >>> and possibly slowly time-varying. It is not possible to measure it, as > >>> the user does not expect to hear any "calibration" signals. > >>> Currently I use the following algorithm > >>> let the microphone signal = M, and the cancellation signal C = A*cos > >>> (w*t) + B*sin(w*t) > >>> update A and B according to > >>> A sub(n+1) = A sub(n) + alpha*M*cos(w*t) > >>> B sub(n+1) = B sub(n) - alpha*M*sin(w*t) > >>> where alpha is a small update coefficient. > >>> This works well when the phase-shift of the path from cancellation > >>> speaker to microphone is small (< 90 degrees), but with large phase > >>> shifts the polarity of the adaptive algorithm is reversed and the > >>> whole thing blows up. > >>> If the speaker-to-mic phase shifts were known, one could of course pre- > >>> compensate the phase of the compensation signal and life would be good > >>> again; but this is not possible. Also, the signal to the main speaker > >>> cannot be tuned off. > >>> Another complication is that the listener must perceive the sound > >>> gracefully decaying to zero, so this rules out any trial-and-error > >>> type of procedure. > >>> Any suggestions? > >>> Bob Adams > >> It seems that you need to know in which direction to drive the anti- > >> signal. &#4294967295;That implies a gradient. &#4294967295;Also, it looks lilke you might be > >> trying to apply the gradient with your update equations. &#4294967295;IF THAT IS > >> THE CASE, I may be wrong, but it appears to me that > > >> A(n+1) = A(n) + alpha M cos(wt), &#4294967295;and > >> B(n+1) = B(n) + alpha M sin(wt) > > >> is NOT the gradient of the squared error, [M - (A'cos(wt) + B'sin(wt))] > >> ^2, where A' &#4294967295;and B' are estimates A and B in M = Acos(wt) + Bsin > >> (wt). &#4294967295;Nor is it the gradient of the error M - (A'cos(wt) + B'sin > >> (wt)). > > >> As I said, I may be wrong, but you might want to address your update > >> equations again. > > >> Maurice Givens- Hide quoted text - > > >> - Show quoted text - > > > Maurice > > > I agree that this is not the ideal gradient but it works extremely > > well when the phase shift between the correction speaker and the > > microphone is small. I think ANY gradient will become confused (and in > > fact will switch polarity completely) in the presence of large amounts > > of phase shift. > > > In a sense this problem is similar to the problem solved by the > > Filtered-X LMS algorithm, where there is another transfer function in > > series with the adaptive FIR before the error is taken. In my case the > > "other" trasnfer function is the cancellation-speaker-to-microphone > > path, but since we are talking only about sine-waves here, this path > > can be characterized simply by the amplitude and phase at the > > frequency of interest. > > Think of it as a servo. Phase is only a frequency-dependent > manifestation of delay. > > > In the Filtered-X LMS, the problem is solved by having a copy of the > > transfer function that exists in series with the adaptive FIR. In my > > case I cannot measure this path, which is the problem; if I knew the > > amplitude/phase of the cancellation-speaker-to-microphone path I could > > easily compensate for it. > > Can't you find that with a test tone? If you know the delay, you can > calculate phase at any frequency. > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;- Hide quoted text - > > - Show quoted text -
Jerry The problem with this is that the frequency varies slowly over a period of a few seconds, and it just so happens that the lowest frequency is in the "resoanance" range of the speaker, and hence undergoes a pretty dramatic change in phase shift. I thought about pre-computing a table of frequency versus phase shift for the speaker plus the acoustic path; however, speaker manufacturing tolerances as well as acoustic paths are known to be highly variable, so I am worried about robustness. There is also the fact that the listener in this application would not expect any test tones or other un-natural sounding experiements to determine the phase. Bob
Robert Adams wrote:

> > I already have a locked frequency, but the phase is the problem. I > only have access to the microphone signal to steer the adaptation > algorithm and this is the sum of the signal I am trying to cancel and > the phase-shifted anti-noise signal I am generating. So what do I use > as a reference to lock the phase to?
I think the answer is "you don't". You adapt the phase as you've been trying to do by changing sin/cos coefficients. See my other post about adaptive filters. Maybe it would work better if you thought of it this way: Cancelling signal = A*sin(wt + B) where A and B are what you adapt with. Otherwise using A*sin(wt) + B*cos(wt) means you are changing both amplitude and phase all the time. Consider a FIR filter (as in my other post) and you modify its coefficients manually. Here's what I would do: Make but one coefficient nonzero (setting the location of the nonzero coefficient is a delay adjustment - which is directly related to phase). Just for discussion purposes, set the value of the nonzero coefficient such that the output of the cancelling speaker is nearly the same as the output of the speaker to be cancelled. - Now, vary the location of the nonzero coefficient in the filter until the combined speaker output is minimized. Mind you that this is only going to be valid at one point in space because the speakers are a 2-element array with a beam pattern. .... unless the wavelengths are long compared to the speaker spacing, etc. etc. in which case the cancellation can be universal. - Once the location of the nonzero coefficient (the delay) is established, then the signals are out of phase ... cancelling as best they can. - Now adjust the amplitude of the coefficient so that the signals are of equal amplitude and perfectly cancel. This is a process of seeking a minimum in each of two dimensions independently. If all is perfect then the first step is guaranteed to find THE minimum you seek. Obviously, if the amplitudes are very different then the first step won't work as well in practice. So, there's an implied seek for a "good" amplitude that precedes this step ... where I said make the amplitudes of the speaker outputs nearly equal. Then the phase opposition minimum should be easy to see. Fred
On Nov 20, 11:17&#4294967295;am, "Fred Marshall" <fmarshallx@remove_the_x.acm.org>
wrote:
> Robert Adams wrote: > > > I already have a locked frequency, but the phase is the problem. I > > only have access to the microphone signal to steer the adaptation > > algorithm and this is the sum of the signal I am trying to cancel and > > the phase-shifted anti-noise signal I am generating. So what do I use > > as a reference to lock the phase to? > > I think the answer is "you don't". &#4294967295;You adapt the phase as you've been > trying to do by changing sin/cos coefficients. &#4294967295;See my other post about > adaptive filters. > > Maybe it would work better if you thought of it this way: > > Cancelling signal = A*sin(wt + B) where A and B are what you adapt with. > Otherwise using A*sin(wt) + B*cos(wt) means you are changing both amplitude > and phase all the time. > > Consider a FIR filter (as in my other post) and you modify its coefficients > manually. > Here's what I would do: > Make but one coefficient nonzero (setting the location of the nonzero > coefficient is a delay adjustment - which is directly related to phase). > Just for discussion purposes, set the value of the nonzero coefficient such > that the output of the cancelling speaker is nearly the same as the output > of the speaker to be cancelled. > - Now, vary the location of the nonzero coefficient in the filter until the > combined speaker output is minimized. &#4294967295;Mind you that this is only going to > be valid at one point in space because the speakers are a 2-element array > with a beam pattern. &#4294967295;.... unless the wavelengths are long compared to the > speaker spacing, etc. etc. in which case the cancellation can be universal. > > - Once the location of the nonzero coefficient (the delay) is established, > then the signals are out of phase ... cancelling as best they can. > > - Now adjust the amplitude of the coefficient so that the signals are of > equal amplitude and perfectly cancel. > > This is a process of seeking a minimum in each of two dimensions > independently. &#4294967295;If all is perfect then the first step is guaranteed to find > THE minimum you seek. > > Obviously, if the amplitudes are very different then the first step won't > work as well in practice. &#4294967295;So, there's an implied seek for a "good" > amplitude that precedes this step ... where I said make the amplitudes of > the speaker outputs nearly equal. &#4294967295;Then the phase opposition minimum should > be easy to see. > > Fred
Fred yes, I can see that this would work. It's a bit disconcerting that you don't initially know which way to "go"; that is, you don't know which way to adjust the phase to make the error go "downhill" until you try; the best you can do is try one direction and if the error goes up you know that you guessed wrong. Same thing applies to the amplitude loop. But I can't think of a better way Bob
Robert Adams wrote:
> On Nov 20, 11:17 am, "Fred Marshall" <fmarshallx@remove_the_x.acm.org> > wrote: >> Robert Adams wrote: >> >>> I already have a locked frequency, but the phase is the problem. I >>> only have access to the microphone signal to steer the adaptation >>> algorithm and this is the sum of the signal I am trying to cancel >>> and the phase-shifted anti-noise signal I am generating. So what do >>> I use as a reference to lock the phase to? >> >> I think the answer is "you don't". You adapt the phase as you've been >> trying to do by changing sin/cos coefficients. See my other post >> about adaptive filters. >> >> Maybe it would work better if you thought of it this way: >> >> Cancelling signal = A*sin(wt + B) where A and B are what you adapt >> with. Otherwise using A*sin(wt) + B*cos(wt) means you are changing >> both amplitude and phase all the time. >> >> Consider a FIR filter (as in my other post) and you modify its >> coefficients manually. >> Here's what I would do: >> Make but one coefficient nonzero (setting the location of the nonzero >> coefficient is a delay adjustment - which is directly related to >> phase). Just for discussion purposes, set the value of the nonzero >> coefficient such that the output of the cancelling speaker is nearly >> the same as the output of the speaker to be cancelled. >> - Now, vary the location of the nonzero coefficient in the filter >> until the combined speaker output is minimized. Mind you that this >> is only going to be valid at one point in space because the speakers >> are a 2-element array with a beam pattern. .... unless the >> wavelengths are long compared to the speaker spacing, etc. etc. in >> which case the cancellation can be universal. >> >> - Once the location of the nonzero coefficient (the delay) is >> established, then the signals are out of phase ... cancelling as >> best they can. >> >> - Now adjust the amplitude of the coefficient so that the signals >> are of equal amplitude and perfectly cancel. >> >> This is a process of seeking a minimum in each of two dimensions >> independently. If all is perfect then the first step is guaranteed >> to find THE minimum you seek. >> >> Obviously, if the amplitudes are very different then the first step >> won't work as well in practice. So, there's an implied seek for a >> "good" amplitude that precedes this step ... where I said make the >> amplitudes of the speaker outputs nearly equal. Then the phase >> opposition minimum should be easy to see. >> >> Fred > > Fred > > > yes, I can see that this would work. It's a bit disconcerting that you > don't initially know which way to "go"; that is, you don't know which > way to adjust the phase to make the error go "downhill" until you try; > the best you can do is try one direction and if the error goes up you > know that you guessed wrong. Same thing applies to the amplitude loop. > But I can't think of a better way >
Bob, The LMS algorithm should deal with that for you even though it's probably more capable/comprehensive than you need. Using it, the adaptation of the filter should just "turn off" all but one coefficient. The demo in one of those links I posted has a rather dramatic (fast) denoising event - the noise appears to just be there for an instant at the beginning. And, one of those links has a Matlab .m file for adapting it appears. I didn't look at it. Fred
Robert Adams wrote:
> > The problem with this is that the frequency varies slowly over a > period of a few seconds,
Then by all means use something like the LMS adaptive filter with parameters set to track the changes. It seems likely it will work... Fred
On Nov 20, 4:34&#4294967295;pm, "Fred Marshall" <fmarshallx@remove_the_x.acm.org>
wrote:
> Robert Adams wrote: > > On Nov 20, 11:17 am, "Fred Marshall" <fmarshallx@remove_the_x.acm.org> > > wrote: > >> Robert Adams wrote: > > >>> I already have a locked frequency, but the phase is the problem. I > >>> only have access to the microphone signal to steer the adaptation > >>> algorithm and this is the sum of the signal I am trying to cancel > >>> and the phase-shifted anti-noise signal I am generating. So what do > >>> I use as a reference to lock the phase to? > > >> I think the answer is "you don't". You adapt the phase as you've been > >> trying to do by changing sin/cos coefficients. See my other post > >> about adaptive filters. > > >> Maybe it would work better if you thought of it this way: > > >> Cancelling signal = A*sin(wt + B) where A and B are what you adapt > >> with. Otherwise using A*sin(wt) + B*cos(wt) means you are changing > >> both amplitude and phase all the time. > > >> Consider a FIR filter (as in my other post) and you modify its > >> coefficients manually. > >> Here's what I would do: > >> Make but one coefficient nonzero (setting the location of the nonzero > >> coefficient is a delay adjustment - which is directly related to > >> phase). Just for discussion purposes, set the value of the nonzero > >> coefficient such that the output of the cancelling speaker is nearly > >> the same as the output of the speaker to be cancelled. > >> - Now, vary the location of the nonzero coefficient in the filter > >> until the combined speaker output is minimized. Mind you that this > >> is only going to be valid at one point in space because the speakers > >> are a 2-element array with a beam pattern. .... unless the > >> wavelengths are long compared to the speaker spacing, etc. etc. in > >> which case the cancellation can be universal. > > >> - Once the location of the nonzero coefficient (the delay) is > >> established, then the signals are out of phase ... cancelling as > >> best they can. > > >> - Now adjust the amplitude of the coefficient so that the signals > >> are of equal amplitude and perfectly cancel. > > >> This is a process of seeking a minimum in each of two dimensions > >> independently. If all is perfect then the first step is guaranteed > >> to find THE minimum you seek. > > >> Obviously, if the amplitudes are very different then the first step > >> won't work as well in practice. So, there's an implied seek for a > >> "good" amplitude that precedes this step ... where I said make the > >> amplitudes of the speaker outputs nearly equal. Then the phase > >> opposition minimum should be easy to see. > > >> Fred > > > Fred > > > yes, I can see that this would work. It's a bit disconcerting that you > > don't initially know which way to "go"; that is, you don't know which > > way to adjust the phase to make the error go "downhill" until you try; > > the best you can do is try one direction and if the error goes up you > > know that you guessed wrong. Same thing applies to the amplitude loop. > > But I can't think of a better way > > Bob, > > The LMS algorithm should deal with that for you even though it's probably > more capable/comprehensive than you need. &#4294967295;Using it, the adaptation of the > filter should just "turn off" all but one coefficient. &#4294967295;The demo in one of > those links I posted has a rather dramatic (fast) denoising event - the > noise appears to just be there for an instant at the beginning. > > And, one of those links has a Matlab .m file for adapting it appears. &#4294967295;I > didn't look at it. > > Fred- Hide quoted text - > > - Show quoted text -
Fred, Since he is using a sinusoid for the test signal, the LMS will have an infinite number of solutions, not a unique solution. The coefficients of the adaptive filter will be a sinusoid rather than a single non- zero coefficient with others zero. Robert, look up a paper by Peter Clarkson that describes the LMS as a transfer function when sinusoids are used. See if it might help. Any reason, other than complexity, that the filtered-x can't be used? Maurice Givens