SDL_mixer mod music loop

Hello, I’m porting a old game to modern systems using SDL2 and SDL2_mixer, but the game’s music are xm files. Since I started the port I (and some other players) noticed that the music looping was not working well, it has a big gap between loops. Today I decided to investigate what could be happening, and looks like the problem is that libmodplug isn’t looping the music (ModPlug_Read returns 0 when the music ends), and when the music ends Mixer plays it again (seek to 0?).

This stack overflow question is exactly about this, but it’s only working with mikmod (don’t know why), and Mixer uses libmodplug by default.

Is there any way to overpass this without having to recompile Mixer, and if not is there any plan to include that? (I mean, choosing to loop the music internally on the library)

I know this is a month old but this is a topic I’m concerned about too. I just accepted that beggars can’t be choosers and SDL will never respect the loop point in MOD files and I should just be lucky there’s a sound library that plays them that’s still in active development :frowning:

Oh and that’s me commenting on the answer in that Stack Overflow thread too :slight_smile: Did you ever come up with a work around? Also what old game are you porting? Keen to know!

Yes, I found out that the problem was in both libmodplug and SDL_mixer, the mod library won’t loop the music even if you tell it to. I’ve solved it by editing the library, getting the loop back and forcing to loop every music. Just look at my last commits. I couldn’t use CMake to compile the windows library on linux so I made a Makefile for it, but I don’t know if it works on every platform.

Awesome. I had a nose around, is Pekka Kana 2 the game you’re porting?

Yes, I’ve published it with the modified version of libmodplug dll file, so I didn’t have to recompile SDL_mixer (I haven’t found a way to cross compile it to windows yet). I don’t know if I have to deal with the sdl license, because the only thing I changed was libmodplug, witch is in the public domain.

1 Like