Jump to content
  • Advertisement
Sign in to follow this  
CodaKiller

How to get size from OggVorbis_File?

This topic is 3123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Don't know if there is a way to do this, but you can use dynamic container like vector<char> and decode ogg stream block-by-block. That is exactly what I do.

Share this post


Link to post
Share on other sites
How about getting audio stream duration in seconds and then do some simple math:

totalSize = durationInSeconds * mixingFrequency * bytesPerSample * numberOfChannels

Share this post


Link to post
Share on other sites
You can use the function ov_pcm_total to find out how many samples total are in the stream.

eg int numSamples = ov_pcm_total(&oggFile, 0);

Not 100% what the second parameter does, I think something to do with chained files but you should be ok just leaving it at 0.

Then, from num samples, work out how many bytes you need for the buffer.

Share this post


Link to post
Share on other sites
Actually, correction :)

"Link to the desired logical bitstream. To retrieve the total pcm samples for the entire physical bitstream, this parameter should be set to -1."

so use -1 for the second parameter.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!