Search code examples
iphoneaudiocore-audioavaudioplayer

iPhone SDK: Change playback speed using core audio AVAudioPlayer


I'd like to be able to play back audio I've recorded using AVAudioRecorder @ 1.5x or 2.0x speed. I don't see anything in AVAudioPlayer that will support that. I'd appreciate some suggestions, with code if possible, on how to accomplish this with the iPhone 3.x SDK. I'm not overly concerned with lowering the pitch to compensate for increased playback speed, but being able to do so would be optimal.


Solution

  • See this question. In other words, you'll have to use a different API like Audio Queue Services. If you want to try a simple hack, you can try doubling the sample rate property of the audio file. It probably won't work though. Also, be warned that it is fairly CPU demanding to adjust the playback speed while keeping the same pitch. You'll need to use a one of the available techniques called "time stretching". Also, in case you haven't realized it by now, doing complicated things with audio on the iPhone is a major pain because Apple's documentation is generally either very bad or nonexistent.