- Online Community Forums » Programming Questions » AllegroOgg

This thread is locked; no one can reply to it. rss feed Print
Damian Grove
Member #6,758
January 2006

I'll tell you right off that I'm not really an expert C programmer. I can program in C, but understanding new things is a weakness for me with programming.

So anyway, I recently installed AllegroOgg because I want to use OGG sound files with my game engine. I've read the documentation and the example source code, and it goes above my head.

Here's what I want to do... I have specific sections in my source code that I want to have AllegroOgg perform very specific tasks. The best way for me to learn is from a very basic example that is broken up into small bits rather than the example provided with AllegroOgg. Here's four little parts in my code:

// INSERT HERE !! OGG buffer
DUH *duhMod;
const char *cfgFile;

// INSERT HERE !! Open/prepare OGG file "NEWDRUG.OGG" at 44.1kHz
duhMod = dumb_load_mod("BGM00.MOD");

// INSERT HERE !! Poll OGG file

// INSERT HERE !! Free OGG buffer

Okay? Those are just bits of my code, but where you see // INSERT HERE !!, that's where I want to do something with AllegroOgg. I gave you the portions of my code to allow you to see where I need to insert the appropriate code so that it works with the way my program is setup. Would anyone be willing to fill in the missing lines? I hope this isn't asking much... I think it's probably about as simple as using MOD files with DUMB, but I actually understood DUMB instructions... AllegroOgg instructions I didn't think were easy to follow at all.

EDIT: And BTW, I'm looking to read the file entirely from memory, not from a disk.

Get into awesome with Saxman! --

Kitty Cat
Member #2,815
October 2002

It's not AllegroOgg, but APEG can do it:

2BITMAP *Dump;
3APEG_STREAM *ogg_stream; /* HERE */
4DUH *duhMod;
6const char *cfgFile;
11ogg_stream = apeg_open_stream("newdrug.ogg"); /* HERE */
13duhMod = dumb_load_mod("BGM00.MOD");
19apeg_advance_stream(ogg_stream, TRUE/*if looping, else FALSE*/); /* HERE */
26apeg_close_stream(ogg_stream); /* HERE */

Getting Ogg to work in APEG with Windows can be a little tricky, though (since you need to build libogg, libvorbis, and libtheora). I think someone made a binary build, but I don't remember where, unfortunately.

If you want to read the file from memory (which really there isn't much of a reason to; disk access is rather minimal), you can do this to open it:

int size = file_size("newdrug.ogg"); // get size
void *buf = malloc(size); // allocate memory
PACKFILE *pf = pack_fopen("newdrug.ogg", F_READ); // open file
pack_fread(buf, size, pf); // read file
pack_fclose(pf); // close file

ogg_stream = apeg_open_memory_stream(buf, size);

// and to close:

"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

m c
Member #5,337
December 2004

you might like to try fmod (

In the documentation for fmod_ex it only shows the c++ interface, but the c interface is alsmot exactly the same (Fmod::CreateStream becomes Fmod_CreateStream or something, just look at the C files in the examples folder).

Fmod_ex lets you use one single interface to play ogg files, mp3 files, wav files (PCM or ADPCM or AIFF and maybe some others, GSM perhaps im not sure), s3m files, mod, xm, it files, and flac files (or decoded from memory, good for datafiles) and you can even give a url to them and they will be streamed off the net. I like it becuase it's really simple and hassle-free and is still cross-platform compatible.

The only issue i have with it is it, unlike DUMB, doesn't honor the Zxx comands in .it files (so a few cool effects are completely ignored). I've never once used any allegro sound things (i looked at them once, and decided to keep on searching, once i found fmod i never really turned back).

Oh yeah, as far as i know fmod places no external dependencies except for it's runtime dl library/object. You just download it, and copy the sources into your include dir and the mingw libfmod.a into your lib folder (or on linux type make install as root and it's finsihed). It's insanely easy.

Some of the examples failed to build on my linux box, but i didn't care, it still works great, and i later built them by hand and all worked properly.

(\ /)_____#_____####__#
(> <)__####__####__####
Megabytes are where I keep my Data.

Murat AYIK
Member #6,514
October 2005

If you insist on AllegroOGG then you can try my test program. I translated the comments and messages to Eng and erased most display code to make it look even easier. It loads the file into memory as you wanted.

"The world doesn't care about what storms you sailed through, it is interested in whether you brought the ship to the dock or not!"

Go to: