I'm trying to get my FLAC input plugin working for 24bit playback, but just get static.
I was hoping someone from J River could offer some advice:
Here is my sample code for copying data into the MC buffer:
byte * loc8 = GetBufferFillLocation();
unsigned short * loc16 = (unsigned short *)loc8;
unsigned long * loc32 = (unsigned long *)loc8;
long nBlockSamples = frame->header.blocksize;
long nBlockAlign = (m_nBitsPerSample /
* m_nCurrentChannels;
long nRAWBytes = nBlockSamples * nBlockAlign;
int channel;
int offset = 0;
int fudge = 0;
for(sample=0;sample < nBlockSamples;sample++)
{
for(channel = 0; channel < m_nCurrentChannels; channel++)
{
switch (m_nBitsPerSample)
{
case 8:
*(loc8 + offset + channel) = buffer[channel][sample];
break;
case 16:
*(loc16 + offset + channel) = buffer[channel][sample];
break;
case 24:
if (buffer[channel][sample] & 0x80000000)
*(loc32 + offset + channel) = buffer[channel][sample] | 0xFF000000;
else
*(loc32 + offset + channel) = buffer[channel][sample];
break;
case 32:
*(loc32 + offset + channel) = buffer[channel][sample];
break;
}
}
offset += m_nCurrentChannels;
}
// update the buffer location to reflect the data we just added
UpdateBufferSize(nRAWBytes);
If I lie to MC and tell it that 24 bit files are 32 bit, It will playback, but with massive distortion.
Any suggestions?
Thanks.
Walter...