【问题标题】:iOS smbPitchShift doesn't workiOS smbPitchShift 不起作用
【发布时间】:2013-12-19 20:11:38
【问题描述】:

所以我正在尝试将著名的 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。有什么想法吗? :)

【问题讨论】:

  • 尝试使用 kAudioUnitRenderAction_PreRender 并将修改后的数据设置到 ioData 缓冲区。

标签: ios audio core-audio audiounit


【解决方案1】:

我也尝试了 kAudioUnitRenderAction_PreRender 标志,但没有成功。它认为我错误地使用了 Accelerate 框架中的 vDSP 功能。我使用了 AEFloatConverter 并且成功了 ;)

【讨论】:

  • 我也在尝试使用 smbPitchShift,并且遇到了类似的问题。你能分享(Github gist?)你更新的、工作的、渲染回调吗?
猜你喜欢
  • 1970-01-01
  • 2012-08-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-25
相关资源
最近更新 更多