Jump to content
  • Advertisement
Sign in to follow this  
Dookie

ov_pcm_total() question...

This topic is 4378 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

Hello! I'm writing a streaming audio function for my game's music. I'm trying to find the pcm length of my game's music track with ov_pcm_total() so I can get my file loader to create default loop points, but it doesn't return the correct number. Here's my usage... LoopEnd = ov_pcm_total(&vf, -1); Not much to it, but LoopEnd doesn't end up with the pcm length of the audio file... I haven't tested the value, but I think it ends up being zero (because the audio playback is a continuous tone, which I presume would be a looping tiny piece of the song playing back). Would anybody tell me how to get the total pcm length of my game's music into LoopEnd? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Dookie
Would anybody tell me how to get the total pcm length of my game's music into LoopEnd? Thanks!
I use double dDuration = ov_time_total(&theFile,-1); to get the file duration in seconds, then you could multiply that the rate member of vorbis_info from ov_info(). It's less exact, but should be good enough.

What exactly do you mean by "loop points"?

Share this post


Link to post
Share on other sites
Thanks for the info, Evil Steve. That works pretty good!

The loop points are for playing parts of a big '.ogg' file... I have one big ogg file with all of my game's music in it (about 5 songs), so to play one song within the file I set loopStart and loopEnd. In my streaming audio engine, I scan to see how far along into the song I've played, then when I've hit loopEnd I simply seek back to loopStart.

In the past, I had a problem with a slight hesitation between stopping a song, loading a new one from disk, and starting the new song. For a fast-paced 2D space shoot-em-up, that's an eternity! I played around with multithreading my streaming audio engine, but there were a handful of betatest machines that would crunch when a song change happened. So for my third attempt at seamless music transition, I tried merging all of my songs into one big file and am attempting to play pieces of it... Hopefully it'll work! [smile]

Thanks again for the help, I really appreciate it!

Share this post


Link to post
Share on other sites
You could try fading the two tracks together (By adjusting the volume of the two buffers), even over half a second or something. That would stop the brief pause, and may make the transition seem smother. Alternatively, you could start loading the second track as the first one nears the end (Unless that's what you meant by the multithreading)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!