INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Input Plugin - 24 and 32 bit Playback  (Read 1427 times)

Oblong

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 63
  • nothing more to say...
Input Plugin - 24 and 32 bit Playback
« on: February 20, 2004, 06:28:58 pm »

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 / 8) * 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...
Logged

Oblong

  • Regular Member
  • Junior Woodchuck
  • **
  • Posts: 63
  • nothing more to say...
Re:Input Plugin - 24 and 32 bit Playback
« Reply #1 on: February 21, 2004, 01:19:16 am »

Never mind.  I figured it out.

      // calculate the amount of room available in the buffer
      long nBufferBytesAvailable = GetBufferBytesAvailable();

      long sample = 0;
      byte * loc8 = GetBufferFillLocation();
      long nBlockSamples = frame->header.blocksize;
      int nBytesPerSample = (m_nBitsPerSample / 8);
      long nBlockAlign = nBytesPerSample * 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++)
         {
            memcpy((loc8 + fudge),&buffer[channel][sample],nBytesPerSample);
            fudge += nBytesPerSample;
         }
      }

      // update the buffer location to reflect the data we just added
      UpdateBufferSize(nRAWBytes);

Walter...
Logged
Pages: [1]   Go Up