這隻在OSX上可用,直到iOS 7.如果你看看AudioQueue.h,你會發現它僅在iOS 7上有條件可用。[注:在重新閱讀我看到你指的是OS X,不是的iOS,但希望下面是跨平臺]
此外,還需要啓用time_pitch 隊列之前設置time_pitch算法,只有譜算法支持間距(所有的支持率)
result = AudioQueueNewOutput(&(pAqData->mDataFormat), aqHandleOutputBuffer, pAqData,
0, kCFRunLoopCommonModes , 0, &(pAqData->mQueue));
// enable time_pitch
UInt32 trueValue = 1;
AudioQueueSetProperty(pAqData->mQueue, kAudioQueueProperty_EnableTimePitch, &trueValue, sizeof(trueValue));
UInt32 timePitchAlgorithm = kAudioQueueTimePitchAlgorithm_Spectral; // supports rate and pitch
AudioQueueSetProperty(pAqData->mQueue, kAudioQueueProperty_TimePitchAlgorithm, &timePitchAlgorithm, sizeof(timePitchAlgorithm));