How can I create slow motion effect for all currently playig sounds and music in my game? I'm using cocos2d v2.1 and ObjectAL.
I can set timescale for scheduler, but how I can do this for sound together?
How can I create slow motion effect for all currently playig sounds and music in my game? I'm using cocos2d v2.1 and ObjectAL.
I can set timescale for scheduler, but how I can do this for sound together?
Keep references to the CDSoundSource
of each sound and bg output:
CDSoundSource *bgMusic = [[SimpleAudioEngine sharedEngine]soundSourceForFile:@"mysong1.mp3"];
[mySoundArray addObject:bgMusic];
Then create a method to ramp down the pitch of all references at a scheduled interval:
-(void)testUpdate:(ccTime)dt
{
float myRampVal = 0.05f;
float finalPitch = 0.5f;
for(CDSoundSource *sound in mySoundArray)
{
sound.pitch -= myRampVal;
if(sound.pitch < finalPitch)
{
sound.pitch = finalPitch;
}
}
}
Schedule by calling the following when you want to lower the pitch:
[self schedule:@selector(audioDownRamp:) interval:0.1f];