Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recording audio and playing iPod at the same time?

I am trying to be able to record audio through the iPhone's microphone while simultaneously playing music from the iPod.

The recording and playback work separately, but if I try to playback from the iPod and record at the same time the recording stops.

By the way, I am not actually recording the audio to save the sound file, but merely analyzing it. It's for my app that flashes to the beat of the music you play.

Does Apple just not allow record and playback at the same time?

like image 907
Jake Holland Avatar asked Nov 14 '22 12:11

Jake Holland


1 Answers

You should be able to do this by setting the Audio Session to AVAudioSessionCategoryPlayAndRecord. Information on this is in the Apple docs, although admittedly the Core Audio documentation is (and has always been) lacking in clarity.

AVSession Class Reference

Also, it's worth noting that AVAudioRecorder and AVAudioPlayer automatically set the session for you. You can wrestle control and set the session manually using the key I highlighted above.

like image 102
lewiguez Avatar answered Nov 16 '22 04:11

lewiguez