# Acoustic feedback detection algorithm

I am woking on an sound processing application where I have limited processing resources. I need to be able to detect acoustic feedback and then signal that such an event occurred. I am not concerned with the more complex task of feedback cancellation, in which the detection circuit would (presumably) need to output accurate information about the frequency and intensity of the detected feedback.

I just need to reliably detect feedback, while rejecting false positives that might come about from 'genuine' harmonic input to the system.

A time domain solution would be preferable. Can anyone suggest such a solution?

• What kind of prior information do you have on the input? How close your input signal can be to a feedback sound (synth generating a sine wave through an overdriven filter, re-amped feedback guitar)? Aug 10, 2012 at 13:10
• The input will be anything experienced by a listener in their daily life. This could well include the music related signals that you mentioned. However, the feedback detection need not be particularly rapid. Aug 10, 2012 at 14:28
• @learnvst: Do you mean that it can have a large latency? You could exploit that luxury by allowing it to have a large latency, a longer period of time than what you would typically hear from a musical instrument playing a note. Aug 10, 2012 at 15:23
• Sure . . a latency of 2 seconds or so would be acceptable. Aug 10, 2012 at 16:02

I assume here that your device is not in the feedback chain.

If you can't afford a FFT or filter-bank decomposition (and then detect over successive frames the FFT bins in which the amplitude gets almost exactly multiplied by the same complex number over successive frames), I would suggest looking at these few parameters:

• Fit a line to the log of the RMS envelope (computed on 50 or 100ms windows) over the past 2 seconds. Compute the slope, compute the coefficient of correlation. First should be positive, the second should be close to 1 for a feedback build-up, which is exponential.
• Compute the standard deviation of the zero-crossing intervals. This is a cheap harmonicity measure, and it should go close to zero as a pure tone settles in and overwhelms the signal.
• % of clipped samples. Seeing clipping is a bad omen - but maybe it's too late for you?

You should get by with a few decision rules based on these criteria.

Now, if your device is in the feedback loop (eg: audio DSP box, hearing aid), things are easier because you can "challenge" what you think is a feedback frequency by inducing a delay in the processing chain, or more subtly an all-pass filter (to delay only the suspicious frequency), and if you notice a change in the frequency of the suspect peak, you get a confirmation that it was induced by feedback rather than coming from the input signal.

• If you're looking for the presence of a pure tone, a phase-locked loop might be another approach worth considering. You would need some means of detecting when the loop has reached lock, of which there are numerous schemes. Digital PLLs can also be implemented with relatively modest processing load. Aug 10, 2012 at 16:49