2
votes

I'm messing around with audio playback using AudioQueue. Does anyone know how you can control the rate of playback so that you can fast forward and fast rewind with audio coming out? AVPlayer has a "rate" property, however I need to be using AudioQueue.

I haven't found anything similar in the Multimedia Programming Guide or in Audio Queue Services Programming Guide. It looks like Mac OS X supports kAudioQueueParam_PlayRate as mentioned by Rocky but that doesn't work on iOS

1
Thanks, but it looks like that is only for OS X and not for iOS. I probably should have specified iOS in the question and not just as a tag. I'll edit that now. - Kevin

1 Answers

0
votes

kAudioQueueParam_PlayRate works on iOS from version 7 onwards. It must be enabled specifically before playback starts in order for it to work:

        var enabled : UInt32 = 1;
        AudioQueueSetProperty(queue!, kAudioQueueProperty_EnableTimePitch, &enabled, 4);
        var algorithm = kAudioQueueTimePitchAlgorithm_Spectral;
        AudioQueueSetProperty(queue!, kAudioQueueProperty_TimePitchAlgorithm, &algorithm, 4);

then you can vary rate and pitch as required:

            AudioQueueSetParameter(q, kAudioQueueParam_PlayRate, Float32(rate));
            AudioQueueSetParameter(q, kAudioQueueParam_Pitch, Float32(pitch));

(sorry for Swift answer on a question tagged objective-c, but that's what I have to use as an example...)