How to convert AudioUnitSampleType to use with Dirac LE

83 Views Asked by At

I am getting crazy with this issue. I am using Dirac LE to perform pitch shifting but the library always adds lot of clicks to the resulting conversion. I need to do the conversion in real time inside the Callback function of an AudioUnit.

All the set up is working fine except for the conversion.

I figure that the the problem is the conversion from 8.24 (AudioUnitSampleType) to short type (used by Dirac) and back to 8.24.

for(int i=0; i<inNumberFrames; i++) {
    faudioIn[0][i] = (SInt16)(outSamplesChannelLeft[i] >> 9);
    faudioIn2[0][i] = (SInt16)(outSamplesChannelRight[i] >> 9);
}
long framesOut  = DiracFxProcess(1.0, 1.0, faudioIn, faudioOut, inNumberFrames, THIS.mDirac1);
long framesOut2 = DiracFxProcess(1.0, 1.0, faudioIn2, faudioOut2, inNumberFrames, THIS.mDirac2);

for(int i=0; i<inNumberFrames; i++) {
    UInt32 val = (faudioOut[0][i]<0)?0xFF000000:0x00000000;
    outSamplesChannelLeft[i] = (faudioOut[0][i] << 9 ) | val;
    val = (faudioOut2[0][i]<0)?0xFF000000:0x00000000;
    outSamplesChannelRight[i] = (faudioOut2[0][i] << 9) | val;
}

Please, can anyone post a working example? Thanks a lot!

0

There are 0 best solutions below