Вопрос

so I'm trying to integrate the famous smbPitchShift algorithm into my project, but the input buffer and output buffer are the same. The smbPitchShift algorithm doesn't alter the samples in the buffer.

Here's what I'm doing in post-render callback:

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;
};

The sound plays just as normal, as the pitch would be set to 1. Any ideas? :)

Это было полезно?

Решение

I tried kAudioUnitRenderAction_PreRender flag as well, but it didn't work. It think I used vDSP functions from Accelerate framework wrong. I used AEFloatConverter and that did the trick ;)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top