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.
Execute the following code:
#import "SimpleAudioEngine.h" @implementation Ch6_AudioProperties -(CCLayer*) runRecipe { //Enable accelerometer support self.isAccelerometerEnabled = YES; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 60)]; //Add background CCSprite *bg = [CCSprite spriteWithFile:@"synth_tone_sheet.png"]; bg.position = ccp(240,160); [self addChild:bg]; //Initialize the audio engine sae = [SimpleAudioEngine sharedEngine]; //Background music is stopped on resign and resumed on becoming...