[A5] troubles with Ogg
Onewing

I've determined that the code sees the file, the addons are included, installed and initialized, but the file will not load. I am running this on a Mac. I downloaded the file from indiegamemusic.com. The file would play in browser. I am linking to the AllegroAcodec-5.1.framework and AllegroAudio-5.1.framework as well.

I am not sure what's missing as the only error I get is the one I supply: "Audio clip sample not loaded!" Here's my code:

Edit: note that if I use a ".wav" file, the sample loads and can be played.

#SelectExpand
1#include <stdio.h> 2#include <allegro5/allegro.h> 3#include "allegro5/allegro_image.h" 4#include "allegro5/allegro_font.h" 5#include "allegro5/allegro_ttf.h" 6#include "allegro5/allegro_native_dialog.h" 7#include <allegro5/allegro_audio.h> 8#include <allegro5/allegro_acodec.h> 9#include "game.h" 10 11const float FPS = 60; 12const int BOUNCER_SIZE = 32; 13 14int main(int argc, char **argv){ 15 ALLEGRO_DISPLAY *display = NULL; 16 ALLEGRO_EVENT_QUEUE *event_queue = NULL; 17 ALLEGRO_TIMER *timer = NULL; 18 ALLEGRO_BITMAP *bouncer = NULL; 19 float bouncer_x = SCREEN_W / 2.0 - BOUNCER_SIZE / 2.0; 20 float bouncer_y = SCREEN_H / 2.0 - BOUNCER_SIZE / 2.0; 21 float bouncer_dx = -4.0, bouncer_dy = 4.0; 22 bool redraw = true; 23 24 25 /// Initialize Code 26 if(!al_init()) { 27 fprintf(stderr, "failed to initialize allegro!\n"); 28 return -1; 29 } 30 31 if(!al_init_image_addon()) { 32 al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_init_image_addon!", NULL, ALLEGRO_MESSAGEBOX_ERROR); 33 return 0; 34 } 35 36 if(!al_init_font_addon()) { 37 al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_init_font_addon!", NULL, ALLEGRO_MESSAGEBOX_ERROR); 38 return 0; 39 } 40 41 if(!al_init_ttf_addon()) { 42 al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_init_ttf_addon!", NULL, ALLEGRO_MESSAGEBOX_ERROR); 43 return 0; 44 } 45 46 if(!al_install_keyboard()) { 47 al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_install_keyboard!", NULL, ALLEGRO_MESSAGEBOX_ERROR); 48 49 return -1; 50 } 51 52 53 54 if(!al_install_audio()){ 55 fprintf(stderr, "failed to initialize audio!\n"); 56 return -1; 57 } 58 59 if(!al_init_acodec_addon()){ 60 fprintf(stderr, "failed to initialize audio codecs!\n"); 61 return -1; 62 } 63 64 if (!al_reserve_samples(1)){ 65 fprintf(stderr, "failed to reserve samples!\n"); 66 return -1; 67 } 68 69 70 71 const char *filename = "Underwater.ogg"; 72 ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); 73 al_append_path_component(path, "Resources"); 74 al_set_path_filename(path, filename); 75 const char *energyIconPath = al_path_cstr(path, '/'); 76 if(!al_filename_exists(energyIconPath)) { 77 fprintf(stderr, "Could not locate file: %s\n", energyIconPath); 78 } 79 ALLEGRO_SAMPLE *sample=NULL; 80 sample = al_load_sample(energyIconPath); 81 82 if (!sample){ // Here's where it bombs 83 84 printf( "Audio clip sample not loaded!\n" ); 85 return -1; 86 } 87 88 89 /* Loop the sample until the display closes. */ 90// al_play_sample(sample, 1.0, 0.0,1.0,ALLEGRO_PLAYMODE_LOOP,NULL); 91 92 93 ALLEGRO_SAMPLE_INSTANCE *SongInstance = al_create_sample_instance(sample); 94 al_set_sample_instance_playmode(SongInstance, ALLEGRO_PLAYMODE_LOOP); 95 al_attach_sample_instance_to_mixer(SongInstance, al_get_default_mixer()); 96 al_play_sample_instance(SongInstance); 97 98 al_destroy_sample_instance(SongInstance); 99 al_destroy_sample(sample);

Edgar Reynaldo

My only contribution is to make a debug build or enable logging in release mode and check allegro.log for clues as to why it didn't load. It should say audio_addon somewhere on the left so you can find it easier.

Thread #615492. Printed from Allegro.cc