Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Wav to OGG - Samples missing (Read 2445 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Wav to OGG - Samples missing

Hi Everyone,
I M facing one problem in OGG Compression. I m trying to convert wav files to ogg files. But I found out that the OGG file i created has less samples than the original wav file.
The code i used for compressing ogg is as follows. Can anyone please tell me where i m going wrong.

bool write (const int** samplesToWrite, int numSamples)
  {
      if (numSamples > 0)
      {
            float** const vorbisBuffer = vorbis_analysis_buffer (&vd, numSamples);
              for (int i = numChannels; --i >= 0;)

          {

              float* const dst = vorbisBuffer;

              const int* const src = samplesToWrite ;

              if (src != 0 && dst != 0)

              {

                  for (int j = 0; j < numSamples; ++j)

                      dst[j] = (float) src[j];

              }

          }

      }


      vorbis_analysis_wrote (&vd, numSamples);



      while (vorbis_analysis_blockout (&vd, &vb) == 1)

      {

          vorbis_analysis (&vb, 0);

          vorbis_bitrate_addblock (&vb);



          while (vorbis_bitrate_flushpacket (&vd, &op))

          {

              ogg_stream_packetin (&os, &op);



              for (;;)

              {

                  if (ogg_stream_pageout (&os, &og) == 0)

                      break;



                  mywrite (og.header, og.header_len);

                  mywrite (og.body, og.body_len);

                  if (ogg_page_eos (&og))

                      break;

              }

          }

      }

      return true;

  }

Thanks and regards
Godwin