The project I'm working on allows a user to speak through a PA system with their iphone as the microphone. Unfortunately, the existing audio units in iOS don't eliminate the feedback between the PA speakers and the iphone microphone and there is instant and debilitating feedback. Is there a way to overcome this issue using existing algorithms? If software feedback elimination is not an option, would it be possible to tune the sensitivity of the iphone microphone to be more directional?
I've never implemented this myself, but here are my (possibly incorrect) thoughts:
The general method of feedback elimination is to
- Detect the frequencies that are feeding back
- Tune a filter to eliminate those frequencies
Step 2. is relatively easy, especially if you are using iOS and have an audio unit that can do it for you. There are some things to watch out for -- because you need a fairly steep filter you need to make sure it is stable even at extreme settings -- but hopefully the folks at Apple have taken care of that stuff for you.
Step 1. is trickier -- how do you know something is feedback and not a genuine part of the audio? There are some advanced techniques related to echo cancellation and adaptive filtering for doing this, but I'm not aware of anything widely available as code or libraries. There might be some shortcuts for your specific use-case, e.g. If you are dealing with speech only, you might be able to simply track pitch, and if a single pitch is strong enough assume that it's a result of feedback, but even doing that quickly enough may not be trivial.
Note that this entire process usually needs to be done continuously/adaptively, at least to some extent to make sure movements of the mike and speaker don't cause new feedback.
There are several patents associated with this, mostly because it's an important aspect of designing hearing-aids. Perhaps some of them are expired and you use them:
(Note, wikipedia mentions another method based on pitch shifting. I'm not familiar with this, and it sounds pretty silly, but it might be worth investigating.)