Search code examples
iphonesignal-processingaudio-recordingmicrophoneaudioqueue

How to prevent iphone microphone to record played sound?


I am currently working on an app that needs to record and and play at the same time, but only a given beep at a given frequency. All this works fine by using avaudioplayer to play the sound and audioqueue to emit at a required frequency. The aim would be to pick up the signal from other devices and process them.

Unfortunately each time I play my sound I also trigger the processing since the app "hears itself". I was wondering if there is a way to somehow cancel this out with or without serious signal processing / software tricks etc.

My solution now is to use a flag to make the app deaf while the avaudioplayer plays the sound then it delegates the finishing even to change the flag. Well.. it is not really accurate :(

Any help would be appreciated!


Solution

  • You need something very similar to AEC (acoustic echo cancellation) - this can be quite tricky to implement, but essentially it's an adaptive filter which cancels out the audio from the speaker.