Chapter 27. Recording Audio
In This Chapter
Setting the appropriate audio category for recording audio |
Recording audio with AVAudioRecorder |
Understanding the settings associated with audio recording |
You've seen how to play audio in your application using the AV Foundation Framework as well as using OpenAL. You've also seen how to access your iPod library from within your application so that you can play the media from the user's music collection.
In this chapter, you're going to see how you record audio in your application. Recording audio is about as simple as playing audio. It uses the same AV Foundation Framework as you used to play audio. In this case, however, you're going to use the AVAudioRecorder
class to do your work.
Setting up Your AVAudioSession
Just like when playing audio, you have to initialize an AVAudioSession
appropriately before you can begin recording audio. There are two session categories associated with recording audio. The first category is AVAudioSessionCategoryRecord
, which allows you to just record audio. This category mutes all playback while recording. The second category, AVAudioSessionCategoryPlayAndRecord
, allows playback to continue while you're recording. This is more typically suited to voice-over IP applications and the like. Typically, for simply recording audio, you may prefer to use the AVAudioSessionCategoryRecord
category.
Note
Remember, to use the AV Foundation Framework, you must add it as a linked framework to your project.
To configure the audio ...
Get Cocoa Touch™ for iPhone® OS 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.