private static int sample_lab_signed_to_unsigned(byte[] buffer, int samplecount)
{
for (int i = 0; i < samplecount; i++)
{
if ((buffer[i * 3 + 1] & 0x80) != 0)
buffer[i * 3 + 1] = (byte)(0x80 + (sbyte)buffer[i * 3 + 1]); // cast to signed int is important
else
buffer[i * 3 + 1] |= 0x80;
if ((buffer[i * 3 + 2] & 0x80) != 0)
buffer[i * 3 + 2] = (byte)(0x80 + (sbyte)buffer[i * 3 + 2]);
else
buffer[i * 3 + 2] |= 0x80;
}
return (samplecount * 3);
}