Metering background music

The CDAudioManager class wraps the AVAudioPlayer class. Using this class gives us access to lower level audio functions. In this recipe, we will dynamically read the average level and peak level of background music currently playing. We can use this information to sync or cue animations.

Metering background music

Getting ready

Please refer to the project RecipeCollection02 for full working code of this recipe.

How to do it...

Execute the following code:

#import "SimpleAudioEngine.h" @implementation Ch6_MeteringMusic -(CCLayer*) runRecipe { //Initialize the audio engine sae = [SimpleAudioEngine sharedEngine]; //Background music is stopped on resign and ...

Get Cocos2d for iPhone 1 Game Development Cookbook 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.