Version 2.2 of the iPhone SDK introduced a new framework for playing and mixing audio: AVFoundation. The AVFoundation framework provides an easy-to-use interface for playing simple sound files. It may appear to be a simple class, but it does pack some punch. The framework not only plays individual sound files, but it can also play multiple sounds simultaneously. The AVAudioPlayer class provides per-sample volume control, allowing you to perform basic sound mixing, and can play a number of different file formats including .mp3, m4a, .wav, .caf, .aif, and others.
Applications or simple games
In addition to this, it provides properties for reading power levels, allowing you to do something most geeks have loved to do since the Apple ][ days: build your own VU meters. The AVFoundation framework is useful for adding sound support in applications such as instant messenger applications or simple games, which don’t require sophisticated digital sound. To create digital sound streams, you’ll still need to use the Audio Toolbox framework, covered later in this chapter.
In order to use the AVFoundation framework, you’ll need to add it as a framework to your existing project. Right-click on the Frameworks folder in your Xcode project, and choose Add Existing Frameworks. Navigate to your SDK’s Frameworks directory and choose the AVFoundation. Framework folder.