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

Started by
4 comments, last by BennettSteele 12 years, 5 months ago
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
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

I gets all your texture budgets!

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.
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.

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

I gets all your texture budgets!

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.

This topic is closed to new replies.

Advertisement