Problems Recording and Playing Sound Simultaneously

I'm having trouble working with iOS Audio frameworks to create a simple app. I would like to record audio through a microphone and play it back while recording.

I tried every one of the audio frame layers (AVFoundation, Audio Queue API and RemoteIO) but only found old docs and broken examples. This looks like a simple request that AVFoundation should handle, but I've looked into the following other SO related questions and still spin for hours to figure it out. Here's what I considered:

I've also downloaded and reviewed both SpeakHere and AurioTouch sample projects from Apple. I promise I won't post without search engine hours and fights. You can see "record audio and play iOS at the same time" returns many dated and broken examples. I know that myself and the community can really benefit from some of the updated docs and examples in the audio section. RemoteIO seems too advanced for such a simple task. Thanks again for your help and attention.

+3


source to share


2 answers


The appropriate way to do this is through the AudioUnit API, although this seems like a common scenario that should be handled by higher level APIs.



I wrote a small demo application using AudioUnit. You can try it and change it to suit your purpose. The demo app records audio and plays it back at the same time, but it is recommended to use headphones to watch the effect.

+5


source


The RemoteIO Audio Unit is the only way to reproduce what is being recorded with low latency. RemoteIO is low latency because it performs audio callbacks on a separate dedicated realtime thread, so it's fast, but also why it's a little more difficult to code. All other iOS audio APIs are built on top of RemoteIO and thus add latency.



You also need to configure the app's audio recording API to request low latency with the appropriate audio session type. The foreground app can query and receive input and output delays in most cases by 5.6 milliseconds on most iOS devices.

0


source







All Articles