views:

937

answers:

2

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.

+1  A: 

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 complicated to adjust the playback speed while keeping the same pitch. You'll need to use a phase vocoder. Also, in case you haven't realized it by now, doing complicated things with audio on the iPhone is a major pain because the documentation is generally either very bad or nonexistent.

Justin Peel
Thank you for the answer.
Harkonian
So, if I am recording at a sample rate of 8000, then theoretically changing the sample rate to 12000 for playback should result in 1.5x speed?
Harkonian
Yes, if it will take arbitrary sample rates rather than just the common ones (44100, 22050, etc.). I think that it will, but I haven't tried it.
Justin Peel
I'll give it a try and post the results today.
Harkonian
+1  A: 

Changing the sample rate should work just like a tape recorder would if you played it faster. Everything becomes higher in pitch. To keep the pitch the same, you would need to set up an Audio Unit graph that includes the AUPitch effect, and lower the pitch by the same ratio that you increase the sample rate by.

lucius
Thank you for that.
Harkonian