I can’t seem to get XM audio to play with SDL_Mixer. Everything works fine as long as I pass in a .wav, but as soon as I try a .xm, the audio is silent as if I never told it to play.
I simplified everything for the following example. My code is in Ada, but don’t let that spook you; the function calls are all more or less the same.
procedure Blah is
Temp : Interfaces.C.int;
begin
Temp := SDL_Init(SDL_INIT_EVERYTHING);
Temp := Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048);
declare
music1 : access Mix_Music := Mix_LoadMUS(To_C("./sounds/RedOrange.xm"));
begin
Temp := Mix_PlayMusic(music1, 1);
SDL_Delay(5000);
--this is a function I wrote that just logs to the console
Log(Interfaces.C.Strings.Value(SDL_GetError));
Temp := Mix_HaltMusic;
Mix_FreeMusic(music1);
end;
SDL_Quit;
end Blah;
In C, this would be more or less (haven’t compiled it to make sure there aren’t any dumb syntax mistakes):
void main()
{
SDL_Init(SDL_INIT_EVERYTHING);
Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048);
Mix_Music* music1 = Mix_LoadMUS("./sounds/RedOrange.xm");
Mix_PlayMusic(music1, 1);
SDL_Delay(5000);
--this is a function that just logs to the console
Log(SDL_GetError());
Mix_HaltMusic();
Mix_FreeMusic(music1);
SDL_Quit();
}
The SDL_GetError being logged appears to be an empty string.
I just updated to the latest version of SDL, SDL_Mixer and SDL_TTF last night to make sure it wasn’t a version problem or something that has been fixed.
I have these in the working directory:
- libmodplug-1.dll
- SDL2_Mixer.dll
- other SDL libraries not related to music, yadda yadda
I know I don’t need all of these, but I threw all these in the working directory just to rule out the possibility that I’m missing one:
- libFLAC-8.dll
- libmpg123-0.dll
- libogg-0.dll
- libopus-0.dll
- libopusfile-0.dll
- libvorbis-0.dll
- libvorbisfile-0.dll
I’ve also played around with calling Mix_Init on a couple of different flags that look important, like MIX_INIT_MOD and/or MIX_INIT_MODPLUG but I’m not entirely sure what I need to do with that call or when I need to call it, or even if I need to call it at all. It usually fails if I try to call it with MIX_INIT_MODPLUG, again with no SDL_GetError message. I know it fails because I can do a comparison between the MIX_INIT_MODPLUG flag and its bitwise and with the result of the Mix_Init call and it doesn’t match.
It’s really hard to find documentation or examples on XM format with SDL_Mixer. Would anybody happen to know where I might be going wrong?