开发者

Mic and Speaker Feedback

开发者 https://www.devze.com 2023-04-06 00:36 出处:网络
I have an iPad application (a tuner) that uses Core Audio Audio Units. It reads the signal from the mic and processes it. It does NOT echo the sound to the speaker.

I have an iPad application (a tuner) that uses Core Audio Audio Units. It reads the signal from the mic and processes it. It does NOT echo the sound to the speaker.

Unfortunately, at different times, the signal actually feedbacks and comes out of the speaker - loud and sort of phasey. I haven't made any connection from the mic to the speaker - but it creates the illusion that the mic is somehow "on". It isn't a direct signal - it is chopped up and requires you to make somewhat loud noises before it will happen.

I'm concerned this is related to overloading the cp开发者_StackOverflow社区u or something. I don't think the callback is getting behind. If I put debug statements into the callback, they seem to stop when I turn off the Audio Unit ... which brings up another oddity. At certain times, even when the Audio Unit has been stopped, the feedback continues to occur from the mic to the speaker so that the app has to be shutdown and removed from the background processing queue before the incessant noise stops.

Oddly, this doesn't happen every time and to every tester but it does occur often enough to create a stir.


If your RemoteIO callbacks are too slow and/or your app crashes and stops handling the audio callbacks, the RemoteIO audio buffers may get recycled, which may cause some of your old play buffers, or perhaps even record buffers, to end up repeated or repeating in the underflowed audio channel. One way to test this is to comment out all your processing code (and debug prints, which can also be too slow) inside your callbacks and see if this fixes your "feedback" problem.

Try to do only simple buffer copies and/or other low-overhead fast processing in both your RemoteIO record and play callbacks. Do not process data inside the Remote callback, instead handshake, schedule or queue the work to be done later outside the callback.

If your app can somehow detect that it can't keep up, it should stop the RemoteIO audio unit (AudioOutputUnitStop).

Also try zero-ing the data each record buffer after you are done with it before exiting each record callback. There have been reports that this may help fix a bug in some very old versions of iPhoneOS.

0

精彩评论

暂无评论...
验证码 换一张
取 消