所以我试图将着名的smbPitchShift算法集成到我的项目中,但输入缓冲区和输出缓冲区是相同的。 smbPitchShift算法不会改变缓冲区中的样本。
以下是我在渲染后回调中所做的事情:
OSStatus MyAURenderCallback (void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData
)
{
if (*ioActionFlags == kAudioUnitRenderAction_PostRender) {
NSLog(@"render");
SBPitchShifter *self = (__bridge SBPitchShifter *)inRefCon;
float *fBuffer = (float *)(malloc(sizeof(float)*inNumberFrames));
int stride = 2;
vDSP_vflt16((SInt16 *)ioData->mBuffers[0].mData, stride, (float *)fBuffer, stride, inNumberFrames);
smbPitchShift(2.0, inNumberFrames, inNumberFrames, 4, self.linearPCMASBD.mSampleRate, fBuffer, fBuffer);
vDSP_vfixr16((float *)fBuffer, stride, (SInt16 *)ioData->mBuffers[0].mData, stride, inNumberFrames);
free(fBuffer);
}
return noErr;
};
声音播放正常,音高设置为1.任何想法? :)
答案 0 :(得分:1)
我也尝试了kAudioUnitRenderAction_PreRender标志,但它没有用。它认为我使用了Accelerate框架中的vDSP函数错误。我使用了AEFloatConverter并且这样做了;)