그래서 유명한 smbPitchShift 알고리즘을 내 프로젝트에 통합하려고합니다. 그러나 입력 버퍼와 출력 버퍼는 동일합니다. smbPitchShift 알고리즘은 버퍼의 샘플을 변경하지 않습니다. 피치는 모든 아이디어를 1로 설정 될 것으로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;
};
소리, 그냥 정상으로 재생 : 여기
콜백을 렌더링 후 나는에 뭘하는지입니까? :)
kAudioUnitRenderAction_PreRender를 사용하고 수정 된 데이터를 ioData 버퍼로 설정합니다. –