tags:

views:

1015

answers:

2

Is there an easy way to control the playback speed/tempo of a sound file loop played using Audio Queue Services? For example, if a game is playing background music, I want to make the BGM speed up as time runs out, but without changing the pitch of the music. Thx!

+1  A: 

There's no trivial way to do this that I know of. On the Mac, you'd presumably use Audio Units to do this, but I think the support for those is limited on the iPhone SDK.

You can do some processing during your AudioQueue playback callback, between AudioFileReadPackets() and AudioQueueEnqueueBuffer() but I think speed-shifting without changing the tone will require rather a lot of CPU time.

It'd probably be easier to have more than one recording of the music, and switch files during a silent passage of the music.

Mark Bessey
A: 

Please give a short code-example on how to do some speed-shifting with some processing during the AudioQueue playback callback between AudioFileReadPackets() and AudioQueueEnqueueBuffer(). Thanks.