Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How to read OGG's from datafiles with AllegroOgg

This thread is locked; no one can reply to it. rss feed Print
How to read OGG's from datafiles with AllegroOgg
Luis Garcia Ventura
Member #5,392
January 2005
avatar

Hi!

I'm a begginer who's trying to read OGG's from my datafile using AllegroOgg, but I can't do it :(

I'm using AllegroOgg because I can't compile AllOgg, and I only want to use OGG sound .

When reading from disk, I have no problem and it works 100% ok playing the sound:

1 install_sound (DIGI_AUTODETECT,MIDI_NONE,NULL);
2 char *data; // OGG file in memory
3 int len; // Length of file
4 FILE *f = NULL; // file.ogg
5 
6 len = (int)file_size("conv.ogg");
7 data = new char[len];
8 f = fopen("conv.ogg", "r");
9 fread(data, 1, len, f);
10 ActFx = alogg_create_ogg_from_buffer(data, len);
11 
12 alogg_play_ex_ogg(ActFx, 65536, 255, 127, 1000, 0);
13 alogg_start_autopoll_ogg(ActFx, 25);
14 
15 
16 while( !keypressed() && alogg_is_playing_ogg(ActFx) )
17 { rest(10); }
18 
19 alogg_destroy_ogg(ActFx)

But, when I try to read it from a datafile, I obtain no result:

  install_sound (DIGI_AUTODETECT,MIDI_NONE,NULL);
  DATAFILE *MyDataFile = load_datafile ("mydat.dat");
  ActFx = alogg_create_ogg_from_buffer (MyDataFile[conv].dat), 20786);
  alogg_play_ex_ogg(ActFx, 65536, 255, 127, 1000, 0);
  while( !keypressed() &&    alogg_is_playing_ogg(ActFx) )
  { rest(100); }
     
     alogg_destroy_ogg (ActFx);

20786 is the file lenght. If I check ActFx pointer after alogg_create_ogg_from_buffer is not NULL, and allog_play_ex_ogg returns ALLOG_OK, but nothing is played.

Can you help me? Thank you very much :):):)

EDITED:

I've still trying, and, finally, I've obtained the result wanted :)

I've forgot the alogg_start_autopoll_ogg(ActFx, 25); call.

I think I don't need to improve my PC's memory, but mine
::)

Go to: