mixxxdj / mixxx

Mixxx is Free DJ software that gives you everything you need to perform live mixes.
http://mixxx.org
Other
4.43k stars 1.27k forks source link

Improve chiptune file detection. #12136

Open daschuer opened 11 months ago

daschuer commented 11 months ago

Bug Description

Mixxx has currently support for

mod: Protracker med: OctaMed okt: Oktalyzer s3m: Scream Tracker 3 stm: Scream Tracker xm: FastTracker2 it: Impulse Tracker

But the used libmod supports more (24). It has its own dispatcher to detect the file type, which can be found here: https://github.com/Konstanty/libmodplug/blob/d1b97ed0020bc620a059d3675d1854b40bd2608d/src/sndfile.cpp#L134

Currently we use libmagic to determine the file type from its content and than fall back to the file extension. However libmagic has no chiptunes support.

Unfortunately libmodplug and also libopenmpt have no 1:1 extension for libmagic,

libmodplug has the rules hidden internally, as simple checks like

if (((pmmh->id & 0x00FFFFFF) != 0x444D4D) || (!pmmh->song)) return FALSE;

https://github.com/Konstanty/libmodplug/blob/d1b97ed0020bc620a059d3675d1854b40bd2608d/src/load_med.cpp#L490C7-L490C7

libopenmpt has a example program for a binary check. https://github.com/OpenMPT/openmpt/blob/master/examples/libopenmpt_example_c_probe.c

Maybe we can extract something from it for our file detection.

Version

No response

OS

No response

ghost commented 11 months ago

I think it would be best for the future to drop libmodplug and switch to libopenmpt because libmodplug is not updated anymore I think. libopenmpt is always updated.