2013-12-19 44 views
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。任何想法? :)

+0

尝试使用kAudioUnitRenderAction_PreRender并将修改的数据设置为ioData缓冲区。 –

回答

1

我也尝试kAudioUnitRenderAction_PreRender标志,但它没有奏效。它认为我使用Accelerate框架的vDSP函数错误。我使用了AEFloatConverter并且做了这个诀窍;)

+0

我正在尝试使用smbPitchShift,并且遇到类似的问题。你可以分享(Github的要点?)你的更新,工作,回报? –