kajott / TrackMeister

TrackMeister: a MOD/XM/IT/etc. player in fullscreen mode for tracked music compos at demoparties
MIT License
32 stars 1 forks source link

mod mode is linked to file extension rather than file type #2

Open djh0ffman opened 4 months ago

djh0ffman commented 4 months ago

The mod playback mode seems to only be activated by the filename ending with ".mod" when it should be based on the contents of the file. For example, dragging a file named "mod.generator" onto the window plays the mod with OpenMPT interpolation. Renaming the file to "generator.mod" plays it with the Bleep interpolation.

kajott commented 4 months ago

Yes, the various sections in the INI file can indeed only react to filename patterns at this moment. I'll see if I can find a way to detect the actual file type at runtime before loading the module proper (because some settings, like the Amiga filter, need to be set before loading the module in libopenmpt, but I only get to know the detected format after loading).

In the meantime, you can use a simple workaround for your specific scenario: In tm.ini, clone the [*.mod] section into a new one called [mod.*].

djh0ffman commented 4 months ago

Quick method would be look at file offset 0x438

If it contains "M.K." or "M!K!" you know it's ProTracker

kajott commented 4 months ago

That would be too format-specific, I think. There are 15-instrument MODs, there are a couple other magic strings than just M.K. and M!K! ... it would replicate quite a bit of format-specific logic that I would rather keep contained in libopenmpt :) But sure, this kind of approach is also on the table if everything else fails.

sagamusix commented 4 months ago

Note that the Amiga BLEP filter will only be used for formats where it is suitable; so just unconditionally enabling it in the default settings could be another solution to this problem. It won't affect S3M/IT/XM/etc. files.

sagamusix commented 4 months ago

If you want to go the route with extracting the module type before fully loading the module, one option would be to load the file once with various "skip" flags enabled (e.g. skip pattern and sample loading), then get the type, and then load the file again without those flags. Note that there is currently a bug with the skip flags though that if all of them are specified, the module will not load properly, but that will be fixed with the next libopenmpt release.

kajott commented 4 months ago

@sagamusix, that's good to know! So I only need to disable interpolation for Amiga formats then? Or is that also taken care of and RENDER_INTERPOLATIONFILTER_LENGTH=0 (default) maps to 1 (no interpolation) for Amiga modules and 4 or 8 (high quality interpolation) for other types? In that case, we could just run on full auto all the time and let libopenmpt handle all the gritty details.

sagamusix commented 4 months ago

As long as Amiga BLEP interpolation is enabled, it will always be preferred over any of the other interpolation options. So technically you only need to force BLEP interpolation and can keep the interpolation filter length at its default value.

Note that if a ProTracker MOD is detected to contain values that are not compatible with Amiga (e.g. notes outside of the ProTracker note range), it is not considered to be an Amiga module anymore and the BLEP filter will not apply. So if it is preferred to play even this kind of PC MODs with no interpolation, you would have to do as you suggested, but when only considering Amiga modules, it's not required.

kajott commented 4 months ago

OK, so I'll extend TrackMeister's auto filter mode so it includes render.resampler.emulate_amiga=1, and we don't even need the Amiga/non-Amiga distinction on the TrackMeister side any longer. Perfect!

sagamusix commented 4 months ago

BTW, I just re-read your initial reply and wanted to point out that the Amiga resampler ctl can be changed at runtime after loading the module and detecting its type; at least from the libopenmpt side that is not an issue. Our XMPlay plugin allows this to change while the song is playing, for example.

kajott commented 4 months ago

The aforementioned change has been implemented in 334ce85; now, the default auto filter automatically switches to Amiga emulation if an Amiga MOD is detected by libopenmpt.

I'm still keeping this issue open because there's still some things to sort out regarding Amiga/PC switching, specifically around volume ramping, which currently does not default to zero on Amiga MODs and needs to be set explicitly.