SDL_Mixer XM no audio

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 :;
    Temp := Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048);
        music1 : access Mix_Music := Mix_LoadMUS(To_C("./sounds/RedOrange.xm"));
        Temp := Mix_PlayMusic(music1, 1);
        --this is a function I wrote that just logs to the console
        Temp := Mix_HaltMusic;
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()
    Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048);
    Mix_Music* music1 = Mix_LoadMUS("./sounds/RedOrange.xm");
    Mix_PlayMusic(music1, 1);
    --this is a function that just logs to the console

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?

If you post the xm file in question, it would be more possible to find the problem.

I’ve just discovered that this may not an SDL/SDL_Mixer probelm.

Note that libmikmod 3.2 has fixed a bug which would prevent it from loading XM files made with OpenMPT.

Since I made my RedOrange.xm with OpenMPT, this may be the problem. I haven’t been able to confirm what player and version SDL_Mixer uses, but I did discover that upon converting the same .xm to a .mp3 via an online player resulted in a .mp3 that was the correct duration but completely silent. This may be why there is no audio and also no error. Using a .xm made from a different source resulted in proper playback such as would normally be expected. I tried it again with another OpenMPT-made .xm and had the same silence problem.

Whether this is a mikmod problem, an OpenMPT problem or both is uncertain but it looks like one simple workaround is to generate any .xms with another tracker.