Search code examples
iphoneaudioios6

Use microphone as input with MTAudioProcessingTap


I want to use the MTAudioProcessingTap's functionality, but instead of using the AVPlayer like CHris in his tutorial i want to use the iPhones microphone.

Can this be done and / or is it documented anywhere?


Solution

  • The way I would proceed with this is to set the session to AVAudioSessionCategoryPlayAndRecord.

    The tutorial says that you can apply the MTAudioProcessingTap to modify any file on your phone. If you follow this tutorial, it shows you how to create a file you recorded using AVFoundation and then play it back.

    Right now AV Foundation is not set up to do real-time audio processing as you record audio. It can only modify the audio in real time while it is being played back or it can do offline audio processing as detailed in the Audio Session Programming Guide.

    I also do not recommend doing a destructive process to a sound as it is being processed. Best practice for audio creation is to leave the master untouched and to change the sound after you capture it.

    As of the beginning of 2014 there is a great deal of information about AV Foundation that is not yet documented. There is a new audio session category that has not been included in the Audio Session Programming Guide. In a few month a whole book on AV Foundation will be published and hopefully that book will provide more solutions to some of these questions.