Tracker Module (.mod,.xm,.s3m, etc.) Playback

Organizing tasks to work on, New Features Ideas, Building LCS & LCB Libraries & Widgets, Redecorating and Modifying the IDE, Hacking / Editing Tools, Compiling the Engine from Source, etc.
Post Reply
User avatar
OpenXTalkPaul
Posts: 2141
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by OpenXTalkPaul »

I've had several people now ask me about tracker .mod(ule) playback, so I thought I might start a thread about it, thinking maybe we can get an extension made to handle them.

If you aren't familiar with tracker/mod format, it's a music format that dates back to Commodore64/Amiga computers in the 1980s. They're a combination of musical notes (frequencies) AND sound samples to use as 'instruments' (some samples may be generated by Commodore's famous "SID" chip, or an emulation of it), the notes and their parameters are layout out in sample channels (how many depends on polyphony, the amount of samples played simultaneously) in spread-sheet style vertical columns.

There was a XCMD for HyperCard/SuperCard/RunRev-macOS(classic) to xTalk-script the playing back of these files, which can be found in the dated but open-source 'PlayerPro" archive on SourceForge. https://sourceforge.net/projects/player ... ry%20XCMD/

So now I'm looking for the best choice for a library (+command line tool preferably) to use with OXT.
It seems to be common choice to use libmodplug which it looks like is what that XCMD used (2 decades ago). It's still around, last updated 2 years ago.
https://github.com/Konstanty/libmodplug

However, I think this library is a better choice, and it seems it was written by the same person who originally wrote mod plug. Supports most OS/platforms. There's even a web assembly port so could support our HTML5 engine too.
libopenmpt https://lib.openmpt.org/libopenmpt/download/

Also around for a long time there is libMikMod https://mikmod.sourceforge.net

And lastly there are these other libraries:
libBass https://slackbuilds.org/repository/15.0 ... s/libbass/
libxmp https://github.com/libxmp/libxmp
uFMOD https://en.wikipedia.org/wiki/UFMOD
Those last three are newer libraries, that I've not heard of before like I have.

I don't think any of these have functionality of a tracker-editor though, they seem to all essentially do the same thing, which is to flatten (mix-down) a mod file to a a file of PCM Sound Samples that then needs to be sent to a playback engine.
EDIT: libMikMod actually has bunch of additional features and supports many playback 'drivers' (sound output APIs for various platforms, even BeOS, hah!)

I don't think it would take very much work to wrap the basic functionality of one these libraries. Why bother? Because music is food for the soul, and .mod tracker files tend to sound like are classic game background music (8bit 16bit era), kids love it!
User avatar
tperry2x
Posts: 2306
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by tperry2x »

At the moment, this is a (rather convoluted) way of doing that on Linux (could be adapted for Windows too).
It's just what I initially came up with so far.
User avatar
OpenXTalkPaul
Posts: 2141
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by OpenXTalkPaul »

tperry2x wrote: Wed Sep 04, 2024 3:56 pm At the moment, this is a (rather convoluted) way of doing that on Linux (could be adapted for Windows too).
It's just what I initially came up with so far.
OK thanks, I'll check it out.

This morning I compiled libMikMod (plus the other three libraries for playing tracker mods) on macOS / BigSur and then I set up an Extension Module to load it based on the basic example provided (translated from C). The library loads but then it crashes when I go to play a mod file. I think that may be because I skipped over the part where you have to set a bitmask in a variable that MikMod library creates which tells it to use software (rather than hardware like a GUS sound card), plus I may need to include dependency libraries (like Pulse Audio and ASLA) like I had to do for FluidSynth to be fully functional in an Extension module form.

The problem with encapsulating these library binaries AND their dependencies into an extension is that for it to be cross-platform package I need to include a platform specific version of each platform that's supported, which means the package gets larger (heavy), when you make a standalone that includes the module though it should include only the version that goes with the standalone's architecture so it won't be as large as the Extension package folder it. I suppose there could be separate versions of the package released for each platform.
User avatar
OpenXTalkPaul
Posts: 2141
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by OpenXTalkPaul »

I think I might to try a different tracker mod library, I don't like the way that libMikMod works. For one thing that library creates its own variables to store various settings and pre-populates them with default values, which I can't easily access from Extension Builder context. There's three other tracker libraries that fit the bill to consider.

Also, I don't want to put a much time into this at the moment. I'm personally not very interested in scripted tracker/mod, but I thought this might be something easily packaged and several people have asked about it, so I figured I'd look into it.
User avatar
OpenXTalkPaul
Posts: 2141
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by OpenXTalkPaul »

tperry2x wrote: Wed Sep 04, 2024 3:56 pm At the moment, this is a (rather convoluted) way of doing that on Linux (could be adapted for Windows too).
It's just what I initially came up with so far.
Is there a reason why you want to use Windows version of PlayerPro Player on Linux via WINE? Why not just install the Linux build of openmpt123 and use that? It would be a much smaller package. When I ran the Mac version of openmpt123 CLI it provided playback quality and terminal text 'UI' that's very similar to what you have in the video there, no WINE needed. I see the stack has a conditional to pick between PPLay exe and openmpt123.exe, is openmpt123 not compatible with all tracker formats?
User avatar
OpenXTalkPaul
Posts: 2141
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by OpenXTalkPaul »

If you build / install the library libopenmpt123 on your Linux, it comes with that command line tool "openmpt123"
If it is user-installed and you have user/local/bin in your IDE's #PATH environmental variable (OXT DPE RC4 adds that to $PATH automatically), then this should return the path to it (on POSIX systems, so Mac & Linux):

Code: Select all

put shell("command -v openmpt123")
Screen Shot 2024-09-05 at 10.53.58 AM.png
Screen Shot 2024-09-05 at 10.53.58 AM.png (104.59 KiB) Viewed 2267 times
('Homebrew' package manager sym-links installs into the default location)
If you get a file path back then you know that exists on the system you can use it like:

Code: Select all

put shell("openmpt123 --batch "&quote&"/PATH-To-MODS/hoffman_-_wizball.mod"&quote)
Which plays the file. For some reason I had to use the --batch switch to get the file to play from the IDE's message box, Shell kept telling me 'wrong parameters', even though the same params worked fine in a terminal and I properly replaced special characters (&quote&).

WARNING: That particular file starts out with a very LOUD 'keytar' note bend! To stop the shell() playing if you hit Command (control) + Period, it should stop playing. Otherwise to stop it playing you'll either have to force terminate the openmpt123 process, or just what until it finishes playing the song if you're enjoying it.

If you need more control of the player and/or wanted to monitor the playback progress while playing your tracker files, you could use 'open process' pattern to play the files async/non-blocking)

Code: Select all

open process "openmpt123 --batch /Users/paul/PATH-To-MODS/hoffman_-_wizball.mod"
-- and then you can stop the playback by closing the process:
close process "openmpt123 --batch /Users/paul/PATH-To-MODS/hoffman_-_wizball.mod"
User avatar
tperry2x
Posts: 2306
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by tperry2x »

For exactly all those reasons/steps you mention above, this is why I had included everything in a portable form. Just for ease of use (no messing about for the user). It's only me testing the idea out, so it's by no means what I see as a working solution.
I wonder if it'd be possible to create a minimal appimage of the linux required libs, again - making it automatic for the the end user.
OpenXTalkPaul wrote: Thu Sep 05, 2024 2:04 pm I see the stack has a conditional to pick between PPLay exe and openmpt123.exe, is openmpt123 not compatible with all tracker formats?
I forget which way around it is now, as I've not looked at this for several days - but I think openmpt couldn't play back the MADK file in my example. Only PPlay could. (or vice-versa). :lol:
User avatar
OpenXTalkPaul
Posts: 2141
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by OpenXTalkPaul »

tperry2x wrote: Fri Sep 06, 2024 8:21 am
OpenXTalkPaul wrote: Thu Sep 05, 2024 2:04 pm I see the stack has a conditional to pick between PPLay exe and openmpt123.exe, is openmpt123 not compatible with all tracker formats?
I forget which way around it is now, as I've not looked at this for several days - but I think openmpt couldn't play back the MADK file in my example. Only PPlay could. (or vice-versa). :lol:
OK, that's what I thought. I'm not real familiar with all the many different variations on the mod format that I know there are (which kind of makes it a rabbit-hole that I don't really want to go down).
I wonder if it'd be possible to create a minimal appimage of the linux required libs, again - making it automatic for the the end user.
I've been thinking it could be possible write a small script library extension that uses CLI apps for playback AND INCLUDES the CLIs (one for each platform) AND any dynamic libraries they may depend on in an Extension Package sub-folder. Packaging extra things up nicely is kind of the point to the Extension package format (.lce).
Most (all?) of these mod libraries can output to PCM samples to a file (which can be piped to a sound player), some can do that without the need for any library dependency, even on extremely limited hardware (by today's standards). It's no wonder why the 'demo scene' liked them.
User avatar
OpenXTalkPaul
Posts: 2141
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by OpenXTalkPaul »

Ah I see, madk / madh is a extended mod format variant that was proprietary to PlayerPRO, which if I recall correctly, was a Mac-only player and tracker editor for much of it's active development years. So I'm not surprise that it doesn't have wide support from the tracker-music community or any of the widely available open-source tools. Player Pro can export to standard formats (again IIRC) I remember using one of those tracker apps back in the day to export sound-samples/MIDI data from various mod formats.
https://forum.openmpt.org/index.php?topic=6748.0
I might take a crack at wrapping another player library libXMP (Extended Mod Player), not sure if it supports madk format, but it looks like it might be easier to wrap, and like libmikmod it's a fairly small library, and doesn't appear to have any extra library dependencies (on my copy, built on macOS).
https://xmp.sourceforge.net/libxmp.html#concepts
User avatar
OpenXTalkPaul
Posts: 2141
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by OpenXTalkPaul »

Wow, there's still a bunch of tracker-editors around, from the retro community:
https://16-bits.org/pt2.php
and even a few commercial ones still around.
https://en.wikipedia.org/wiki/Renoise
User avatar
tperry2x
Posts: 2306
Joined: Tue Dec 21, 2021 9:10 pm
Location: Somewhere in deepest darkest Norfolk, England
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by tperry2x »

OpenXTalkPaul wrote: Fri Sep 06, 2024 4:13 pm Wow, there's still a bunch of tracker-editors around, from the retro community:
https://16-bits.org/pt2.php
Thank you Paul for this. That site led me to Ft2. I downloaded the source, compiled it, and made an appimage of it. You can see it in action and download the appimage from here.
(I'll modify my stack to use this instead at some point).
User avatar
OpenXTalkPaul
Posts: 2141
Joined: Sat Sep 11, 2021 4:19 pm
Contact:

Re: Tracker Module (.mod,.xm,.s3m, etc.) Playback

Post by OpenXTalkPaul »

tperry2x wrote: Fri Sep 06, 2024 7:01 pm
OpenXTalkPaul wrote: Fri Sep 06, 2024 4:13 pm Wow, there's still a bunch of tracker-editors around, from the retro community:
https://16-bits.org/pt2.php
Thank you Paul for this. That site led me to Ft2. I downloaded the source, compiled it, and made an appimage of it. You can see it in action and download the appimage from here.
(I'll modify my stack to use this instead at some point).
Happy to share my findings, thanks for sending me down a musical rabbit hole again :lol: I actually just picked up a tiny little portable USB-MIDI Keyboard that has some programmable sliders, knobs, and pads/buttons, jammin' a bit this morning!
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests