Jump to content
  • Advertisement
Sign in to follow this  
BennettSteele

Using C++, OpenAL + Ogg Vorbis, Load a .Ogg file

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

I recently finnished restoring alot of my game, but now i have to bring back the in-game music, which is saved in .ogg files. Im using openAL, so they would have to be converted to .wav files, which are too big. So i decided to look into Ogg Vorbis, which looked like it would fix it. Well, i have the files, but now i dont know how i could load a whole .Ogg file int a ALuint so i can just have 1 song at a time playing. This is what im thinking the function would look like:

ALuint OggLoadFromFile(const char* file);

where it returns the right ALuint to use. How would i do this?w

Share this post


Link to post
Share on other sites
Advertisement

I recently finnished restoring alot of my game, but now i have to bring back the in-game music, which is saved in .ogg files. Im using openAL, so they would have to be converted to .wav files, which are too big. So i decided to look into Ogg Vorbis, which looked like it would fix it. Well, i have the files, but now i dont know how i could load a whole .Ogg file int a ALuint so i can just have 1 song at a time playing. This is what im thinking the function would look like:

ALuint OggLoadFromFile(const char* file);

where it returns the right ALuint to use. How would i do this?w


You'll probably want to build a mechanism for streaming these ogg files, since when loaded into memory in decoded form they'd still take up a huge amount of space
Doing this is not all too straightforward, but there's a tutorial on devmaster.net explaining the process quite nicely; it can be found here: http://www.devmaster...als/lesson8.php

If you just need simple playback then this tutorial is probably all you need

Share this post


Link to post
Share on other sites
Yeah, i saw that... i guess i will have to surgicly add it to my code... later though, i just got the menu system working, and im on a coding spree. ;P
Thanks though.

Share this post


Link to post
Share on other sites
Ok, i put in the code, and now it comes up with a runtime error when i run it. im using Code::Blocks, and read it does not go right with MinGW, so i tried editing some of the os_types.h type definitions, but still came up with a run time error. what should i do? Im calling the ogg_stream.update() every frame too, but when i dont use the update, it runs.

Share this post


Link to post
Share on other sites

Ok, i put in the code, and now it comes up with a runtime error when i run it. im using Code::Blocks, and read it does not go right with MinGW, so i tried editing some of the os_types.h type definitions, but still came up with a run time error. what should i do?


Are you just copy-pasting the code in there, because I'm not someone who helps out copy-pasters ;)
if not, I can't help you out with such a vague description, you'll have to give more information about what the error says and when and where it popped up

Share this post


Link to post
Share on other sites
this is called every frame:


{
Player.update();

if(APP.Playing)//IN GAME LOGIC AND DRAWING
{
if(APP.State){GameLogic(DT);}
else{GameDraw();}
}
else if(!APP.Playing)//SCREEN LOGIC AND DRAWING
{
if(APP.State){ScreenLogic(DT);}
else{ScreenDraw();}
}
}


Player is the ogg_stream class i used...

when i use it like it is, it comes up with the error:
Microsoft Visual C++ Runtime Library:
This application has requested the Runtime to terminate it in an unusual way.

but when i comment it out, it runs just fine, just without sound.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!