public unsafe static void ConvertorFloatToShort2Channels(IntPtr inputInterleavedBuffer, IntPtr[] asioOutputBuffers, int nbChannels, int nbSamples) { float *ptr = (float *)((void *)inputInterleavedBuffer); short *ptr2 = (short *)((void *)asioOutputBuffers[0]); short *ptr3 = (short *)((void *)asioOutputBuffers[1]); for (int i = 0; i < nbSamples; i++) { *(ptr2++) = ASIOSampleConvertor.clampToShort((double)(*ptr)); *(ptr3++) = ASIOSampleConvertor.clampToShort((double)ptr[1]); ptr += 2; } }
public unsafe static void ConvertorFloatToShortGeneric(IntPtr inputInterleavedBuffer, IntPtr[] asioOutputBuffers, int nbChannels, int nbSamples) { float *ptr = (float *)((void *)inputInterleavedBuffer); short *[] array = new short *[nbChannels]; for (int i = 0; i < nbChannels; i++) { array[i] = (short *)((void *)asioOutputBuffers[i]); } for (int j = 0; j < nbSamples; j++) { for (int k = 0; k < nbChannels; k++) { short *[] array2; IntPtr intPtr; short * ptr2; (array2 = array)[(int)(intPtr = (IntPtr)k)] = (ptr2 = array2[(int)intPtr]) + 1; *ptr2 = ASIOSampleConvertor.clampToShort((double)(*(ptr++))); } } }