O'Reilly logo

Cocos2d for iPhone 1 Game Development Cookbook by Nathan Burba

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modifying audio properties

CocosDenshion provides functionality to change the pitch, gain, and pan properties of an audio source. Pitch is the frequency, gain is volume, and pan is a way to shift volume between left and right speakers. In this example, we will create a music-bending instrument to display these properties being dynamically modified.

Modifying audio properties

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_AudioProperties -(CCLayer*) runRecipe { //Enable accelerometer support self.isAccelerometerEnabled = YES; [[UIAccelerometer ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required