AEAudioFilePlayer slower/faster

It's probably a stupid question, but I'd like to be able to play an audio file faster or slower, but without pitch adjustment or time stretching, just plain averaging of samples (the tape recorder rewinding effect).

What is the best way of achieving this? I understand I can't request extra buffers from the producer, or at least somehow it didn't work for me. Having my own AudioFileReader with a speed property is an option of course, but isn't there a more "canonical" and shorter way?


  • I'd say kAudioUnitSubType_Varispeed is probably what you're after, @crontab:

        @constant       kAudioUnitSubType_Varispeed
                        An audio unit that can be used to control playback rate (as the rate is faster, 
                        the pitch is higher). It provides a generic view, so can be used in both a UI 
                        and programmatic context. It also comes in an Offline version so can be used 
                        to process audio files.
    // Parameters for the AUVarispeed unit
    CF_ENUM(AudioUnitParameterID) {
            // Global, Rate, 0.25 -> 4.0, 1.0
        kVarispeedParam_PlaybackRate                = 0,
            // Global, Cents, -2400 -> 2400, 0.0
        kVarispeedParam_PlaybackCents               = 1

    Create an AEAudioUnitFilter with the kAudioUnitSubType_Varispeed type, configure it with the kVarispeedParam_PlaybackRate or kVarispeedParam_PlaybackCents parameters, and add it as a filter in front of the AEAudioFilePlayer.

  • Thanks @Michael, but that doesn't quite do what I need. I'm implementing an imitation of a tape recorder with Fast Forward/Rewind functions, so at least playing backwards already poses a challenge none of the AU's seem to be able to solve. I've already implemented a file player class with incremental file reading and ff/rewind functions at up to x8 speeds. I might share it once tested and all, though it solves a very specific problem nobody needs these days :)

  • Ahh, I see! Right then, nicely done =)

Sign In or Register to comment.