iPhone Sound: Adjust speed of playback of audio file while playing

后端 未结 3 1883
谎友^
谎友^ 2020-12-29 17:37

is there a way to adjust the speed of the playback of an audio while playing in Objective C for the iPhone/iPod touch?

Also would be interesting if playing a file ba

3条回答
  •  温柔的废话
    2020-12-29 18:04

    A cheesy way to do it is to tweak the sample rate when you send it to the playback engine (Audio Queue, Remote I/O Unit, OpenAL). For PCM -- and I'm not sure this would work for anything other than PCM (so you'd have to decompress an MP3 or AAC with Audio Converter Services first) -- you could speed up your audio by adjusting the AudioStreamBasicDescription like this:

    audioStreamDesc.mSampleRate = audioStreamDesc.mSampleRate * 1.2;
    

    Note that this also changes the pitch of your audio: not only is it faster, it's also higher pitched. The Mac has a system-supplied audio unit that allows you to change playback speed without changing pitch, but it seems to be absent on iPhone.

提交回复
热议问题