Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Cannot load sample.

This thread is locked; no one can reply to it. rss feed Print
Cannot load sample.
arch674
Member #16,525
August 2016

Hey, i have a problem when i try to load sample, I'm doing exactly like I should, after al_load_sample function uses, my sample pointer is null...
Maybe someone had this issue too and know how to solve it? :-/

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

There are several possible causes for al_load_sample to fail.

1. You didn't initialize allegro, the audio or the acodec addons.
See al_init() , al_install_audio() , al_init_acodec_addon() for details.

2. You didn't build support for your particular sound file type into allegro.
Where did you get allegro from? Did you build it yourself?

3. Your path or your current working directory is wrong.
Try testing loading the file with an absolute path. If a relative path fails, your working directory is not what you expect it to be. See al_change_directory() , al_get_standard_path() , al_path_cstr() for details.

4. Your sound file is a type not recognized by Allegro. Try saving it in a different format, or re-saving it with an audio editor.

arch674
Member #16,525
August 2016

Hey, thanks for quick response.
I've done init, audio and acodec_addon.
There is a site u meant http://download.gna.org/allegro/allegro-unstable-bin/5.1.12/
I tried to set a full path too, same issue.
I have ".wav" file.
Strange situation. ::)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Okay.

Your options are :

1. Update Allegro. Latest version is 5.2.1. Your problem may have been fixed. There are NUGET packages for MSVC now.

2. Try a different .wav file or an .ogg file and see if others work.

3. Try re-saving your .wav file.

Post your code, and post your .wav file as an attachment if it is not too large (>10 MB).

arch674
Member #16,525
August 2016

If u want to run it, i've added my stickman too.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Okay. I have binaries of 5.2.0 and ex_audio_simple won't play it. Says it failed to load.

VLC Media Player can play it though, and here's what it says about the media :
{"name":"610508","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/1\/7150ca5c056c9c7c018c8caad995c6f2.png","w":602,"h":588,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/1\/7150ca5c056c9c7c018c8caad995c6f2"}610508

Try re-saving it in your favorite audio editor. The codec must not be one recognized by Allegro, or maybe there is a bug. Don't know.

arch674
Member #16,525
August 2016

OK, thank you for help.
The problem was with sound file, I used another wav and there is how it should be.

Go to: