Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Problem loading audio stream from tracker music file

Credits go to SiegeLord for helping out!
This thread is locked; no one can reply to it. rss feed Print
Problem loading audio stream from tracker music file
mm2dog
Member #16,633
February 2017

Hello, I'm a newcomer to Allegro and I'm trying to play an .xm music file with the following code:

#SelectExpand
1ALLEGRO_AUDIO_STREAM *stream = al_load_audio_stream("path/to/file.xm", 4, 2048); 2if (stream) { 3 al_set_audio_stream_playmode(stream, ALLEGRO_PLAYMODE_LOOP); 4 al_set_audio_stream_playing(stream, true); 5} 6else { 7 // panic! 8}

The problem is, al_load_audio_stream is returning NULL. I know the file path is correct and I know the audio and acodec Allegro addons are both working because I am able to load and play .wav samples. I understand Allegro 5 uses DUMB to play module files like .xm, and I have the DUMB library installed. Do I need to #include anything or link anything beyond the audio and acodec libraries in order to load and play .xm files? I haven't been able to find any full code examples with this specific format so I'm a little bit lost.

Additionally, I'm not really sure what the second and third parameters of al_load_audio_stream are supposed to be (number of buffers and number of samples, respectively), so I just used values I saw other people using in posts online. Could this be the source of the issue, and if so, how do I determine which values to use with the music file I want?

SiegeLord
Member #7,827
October 2006
avatar

What OS is this?

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

mm2dog
Member #16,633
February 2017

Sorry, I forgot to mention. I am on Arch linux

SiegeLord
Member #7,827
October 2006
avatar

The Arch package doesn't build Allegro with the DUMB dependency (see https://github.com/liballeg/allegro5/issues/670#issuecomment-251003473 for the explanation). You'll have to build Allegro yourself. Just install these dependencies manually (https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/allegro#n14), in addition to dumb, and then follow the usual build instructions (see further below in that PKGBUILD file).

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

mm2dog
Member #16,633
February 2017

I'm a little ashamed I didn't find that issue on github with my googling. Thanks for your help!

Go to: