Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Issue: ASIOSampleConvertor bug [16361]

$
0
0
Working with multichannel output in NAudio I noticed a bug in the ASIOSampleConvertor: the ConvertorFloatToIntGeneric is using a float pointer instead of a int pointer as it should.

Corrected code:

public static void ConvertorFloatToIntGeneric(IntPtr inputInterleavedBuffer, IntPtr[] asioOutputBuffers, int nbChannels, int nbSamples)
{
unsafe
{
float* inputSamples = (float*)inputInterleavedBuffer;
int*[] samples = new int*[nbChannels]; // <- here stood float*
for (int i = 0; i < nbChannels; i++)
{
samples[i] = (int*)asioOutputBuffers[i]; // <- here stood float*
}

for (int i = 0; i < nbSamples; i++)
{
for (int j = 0; j < nbChannels; j++)
{
*samples[j]++ = clampToInt(*inputSamples++);
}
}
}
}
Comments: Yeah, multichannel is a lot of pain, took me quite a while to find this. I used a M-Audio ProFire 610 Firewire device on a Windows 7 x86 machine. I used the NAudio source code version 60216c3b9380. When I found this, it got really obvious, the sound was clearly clipped (on all channels and ok in the wave file created at the same time) and the function schoult convert from float to int but still was writing float.

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>