libsdl-org / SDL_mixer

An audio mixer that supports various file formats for Simple Directmedia Layer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SDL3: libxmp unable to load modules, where libmodplug had no problem before.

AntTheAlchemist opened this issue · comments

I have a bunch of music modules that don't work with libxmp. They worked fine with libmodplug.

What's the solution? Can I somehow go back to libmodplug?

The error is "XMP: Unrecognized file format". And it looks like the music files no longer supported are MTM files.

IMHO, libmodplug worked a LOT better. libxmp is broken. I already reported another bug that's not fixed - I have to load the whole module into RAM to get it to load.

I am guessing that you are building SDL_mixer using Visual Studio project
files and using the libxmp-lite.dll files along with it: The lite version
is what its name implies: it is a very light version with limited amount
of loaders, namely protracker, scream tracker 3, and impulse tracker with
limited amount of their variants. If you are using the libxmp-lite dlls,
it is no wonder the mtm files won't load.

I think the reason behind @slouken's choice of lite version is not really
the size of the dlls but that the full library used to be licensed under
LGPL, as opposed to the lite version which is under MIT. @slouken: If that
really is the reason, libxmp recently switched its license to MIT for the
whole library, and we can simply provide the prebuilt dlls or dylibs of the
full library -- just say the word.

libmodplug worked a LOT better. libxmp is broken.

That's a lot of .... (choose whatever word for that ...) libmodplug is more
than full of bugs even in its severely patched state we used to provide.

I think the reason behind @slouken's choice of lite version is not really the size of the dlls but that the full library used to be licensed under LGPL, as opposed to the lite version which is under MIT. @slouken: If that really is the reason, libxmp recently switched its license to MIT for the whole library, and we can simply provide the prebuilt dlls or dylibs of the full library -- just say the word.

Word.

I think it was code size too, but feel free to make the switch and see how it looks.

Hold-up! Non-lite would add a lot of code.

I'm loading the offending mod files into OpenMPT and saving them as .s3m, which seems to do the trick. I'm happy to do that as a work around if there's no loss of features from MTM to s3m?

I bumped the libxmp external dep (the gitmodule) to latest.

I can change the MSVC and Xcode project files to use the full library instead of lite:
Need confirmation.

@AntTheAlchemist has a workaround he prefers over the full xmp library. Let's wait and see if we have other people who need the full library before we make that change?

I'll go ahead and close this for now.

@AntTheAlchemist has a workaround he prefers over the full xmp library. Let's wait and see if we have other people who need the full library before we make that change?

OK then

FWIW, the libxmp.dll built with --disable-depackers --disable-prowizard
(which is the default now in cmake vendored builds) is about 377k for x86
and about 391k for x64, when compiled with gcc7.5, i.e. about twice size
against existing lite dlls. Not much IMHO, but you guys decide.

That's not bad, actually. Can you toss a build somewhere for @AntTheAlchemist to check out and see if they load his original MTM files?

Here you go -- zip with x86 and x64 windows dlls : libxmp-dlls.zip

NOTE: Assuming @AntTheAlchemist is building from the Visual Studio
project files, he must change the libxmp-lite.dll entries in there to
simply libxmp.dll and rebuild SDL_mixer.

Thanks @sezero . Agreed, the extra file-size isn't too bad. Would there be something like SDL_LEAN_AND_MEAN for libxmp for people who still want the lite version so they shave some mb off their build?

I've not been able to get this working. I've renamed everything -lite, but it's not picking up libxmp.dll. I get "MOD support not available" now. I'm using the Visual Studio project, with a github copy of libxmp in external\libxmp (for the Android build). The only place I can find that references libxmp-lite.dll is in the solution explorer.

Scratch that. I found the "XMP_DYNAMIC="libxmp-lite.dll" preprocessor. The libcmp.dll loads now...

Interestingly, it's still saying XMP: Unrecognised file format. So the problem wasn't the "lite" part.

Give us a file that fails to load

It's gone back to "MOD support not available", so I don't think the new dll is working, I think it picked up an old -lite.dll from somewhere when it did work the one time. Can you update the SDL_mixer visual studio project to de-lite everything, and I'll try a fresh copy from source. I've tried everything and can't get these new dlls to load.

0.zip

I think I see what's happening: did you only try the x86 (32 bit) version?
If yes, here is an updated build which I only changed the x86 dll (the x64
version is fine):

(The issue was the x86 version of the dll linked to libgcc dynamically, so
the absence of libgcc dll resulted in failure in loading libxmp.dll... The
new dll is statically linked to libgcc, so there should be no issues now.)

libxmp-dlls.zip

It's still not working. Yes I'm trying the x86. I don't have a x64 build.

"change the libxmp-lite.dll entries in there to simply libxmp.dll"

Where exactly are the entries that need to be changed? I've found preprocessor entries and the files in the solution explorer.

I renamed libxmp.dll to libxmp-lite.dll and it worked 😆. I confirm the -lite version has limited compatibility with some mods, and I still prefer the OpenMPT resave workaround to keep KB down.

It would be good to have a SDL_LEAN_AND_MEAN type option for libxmp, especially for Android where size matters a lot - I get a lot of positive feedback about lightweight apps which people are less likely to uninstall, which is something I love about SDL.

I renamed libxmp.dll to libxmp-lite.dll and it worked

Evil workaround, but enough to confirm everything works.

I'll soon update all project files and prebuilt dlls.

I'll soon update all project files and prebuilt dlls.

I updated both SDL2 and SDL3 branches. Closing.

I just noticed Android.mk mentions XMP-lite, and it got me wondering if we can have SUPPORT_MOD_XMP as well as SUPPORT_MOD_XMP-LITE ?

I want to make my case again for keeping a lite version as an option, and quote the readme from the lite version:

Libxmp-lite is a lean and lightweight subset of Libxmp that plays MOD, S3M,
XM, and IT modules and retains full compatibility with the original API.
It's intended for games and small or embedded applications where module
format diversity and file depacking are not required.

No one is stopping you from using xmp-lite: The cmake and autotools build systems already give you the option. However, if you want a magical solution for Visual Studio where one can switch xmp and ximp-lite dlls and the SDL_mixer dll would still work, well I won't do that - too much hassle (maybe someone else will): Just edit the Visual Studio project file for your needs.

I don't really understand how the lite non-lite versions work, so not sure what I need to edit to select each. I am going along with the out-of-the-box config from android-project. I don't have xcmake or autotools or linux.

In the MSVC project file, change the name of the dll to look for,
i.e. change XMP_DYNAMIC="libxmp.dll" to XMP_DYNAMIC="libxmp-lite.dll"
(and provide the corresponding dll, of course), so that the SDL_mixer
dll would know what to load.

The two dlls are identical in terms of API and ABI, so no other changes
would be needed.