1
所以我试图将着名的smbPitchShift算法集成到我的项目中,但输入缓冲区和输出缓冲区是相同的。 smbPitchShift算法不会更改缓冲区中的采样。iOS 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。任何想法? :)
尝试使用kAudioUnitRenderAction_PreRender并将修改的数据设置为ioData缓冲区。 –