PDA

View Full Version : Amiga MOD Transcoder available?



JoeMuc2009
2017-12-01, 04:12
Hi all,

something a bit unusual maybe but I thought it could not harm to ask.
I'm still a big fan of 4-channel Amiga SoundTracker / ProTracker modules. It's really oldschool nowadays but I still love it.
However, my Amiga is not directly connected to my hi-fi set, and it's not very comfortable to control module playlists on a computer when everything else is controlled more or less with LMS. This would become super easy if LMS had something like a transcoder for Amiga modules. Winamp for instance had the so-called oldsk00l plugin as an option to read MOD files directly and play them on a PC. I imagine this might be possible in LMS as well.
It would add a whole new level of joy. Unfortunately, I am absolutely beginner level in LMS internals and Perl is not something I can handle well. So I thought maybe somebody else has the same thoughts and/or more capability to get there?
Foobar2000 is officially capable to use MOD files as its input but I have no idea how to use it in LMS.
Linux has a module player called "xmp" which is also capable of creating WAV output.
But what I am looking for is not a solution to create WAV files of all my modules. That would be a giant waste of disk space as a module can be as small as a kilobyte whereas the WAV created from it could easily exceed 100MB or more. So the conversion should happen in-line if possible.

Thank you for your thoughts!
Cheers,
Joe

bpa
2017-12-01, 04:24
ffmpeg (aka avconv) can handle MOD - well at least one sample I tested.

You could set up the approrporiate new type for a .MOD file with custom-type.conf and then add a MOD type to custom-convert.conf which has a MOD filetype and uses ffmpeg to convert to flac and then LMS sends flac stream to player.


Alternatively convert the MOD files once to flac with the command

ffmpeg -i input.mod -f flac output.flc

JoeMuc2009
2017-12-01, 07:37
Hi bpa,

thanks for the pointer. I found the type.conf and convert.conf but could not get any ffmpeg version to accept the MOD files (ProTracker / SoundTracker compatible) as input. Just to be sure we are talking about the same thing here because MOD apparently was also the name for a video format.
When I call ffmpeg -decoders, it returns 439 decoders but the words "MOD", "Protracker", or "Amiga" don't appear anywhere in there. So I assume the format is not supported.
It's an up-to-date version though. The command line output reads:


ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)

No idea what I'm doing wrong. It does not seem as though there are many alternatives. Most Windows programs handling MOD files are to play them, mostly they present a GUI and do not offer command-line level support for conversion, if at all.

Regards
Joe

bpa
2017-12-01, 08:07
I am using the ffmpeg that is installed as part of Ubuntu 16.04 - no special build.
Log of conversion using ffmpeg so that version and decoders are shown


xxx@minitower:/tmp$ ffmpeg -loglevel info -i /home/xxxx/Downloads/lastr.mod -f flac lastr.flc
ffmpeg version 3.3.3-2~ubuntu16.04.1~ppa1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/usr --extra-version='2~ubuntu16.04.1~ppa1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, libopenmpt, from '/home/xxxx/Downloads/lastr.mod':
Metadata:
title : last roundabout
encoder : ProTracker / NoiseTracker / Soundtracker / SoundTracker 2.6 / Ice Tracker / Mod's Grave
comment : (c) 1992 jesper kyd
: finished the 25-10-92
: composed for the...
: sound of silents ii
: skinny3
: skinny4=5(3)
: skinny2
: freak23
: freak17
: freak12
:
: synth
:
:
:
: overbazz
: overbazz2
: cguit
: eu2
:
: strings2
:
: strings1
:
:
:
:
:
:
:
:
:
Duration: 00:08:02.66, bitrate: 3 kb/s
Stream #0:0: Audio: pcm_f32le, 48000 Hz, stereo, flt, 3072 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_f32le (native) -> flac (native))
Press [q] to stop, [?] for help
[flac @ 0x556c80372580] encoding as 24 bits-per-sample
Output #0, flac, to 'lastr.flc':
Metadata:
title : last roundabout
DESCRIPTION : (c) 1992 jesper kyd
: finished the 25-10-92
: composed for the...
: sound of silents ii
: skinny3
: skinny4=5(3)
: skinny2
: freak23
: freak17
: freak12
:
: synth
:
:
:
: overbazz
: overbazz2
: cguit
: eu2
:
: strings2
:
: strings1
:
:
:
:
:
:
:
:
:
encoder : Lavf57.71.100
Stream #0:0: Audio: flac, 48000 Hz, stereo, s32 (24 bit), 128 kb/s
Metadata:
encoder : Lavc57.89.100 flac
size= 87181kB time=00:08:02.77 bitrate=1479.3kbits/s speed= 157x
video:0kB audio:87172kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.009557%


For completeness the conf file that could work would be like the following. There will be issues like LMS will not able to scan the file so duration etc will not be known so conversion to flac would be an overall better solution.
custom-types.conf


mod mp3 * *
# F:{PATH=%f}R:{PATH=%F}B:{BITRATE=-B %B}T:{START=-ss %s}
[ffmpeg] -loglevel quiet -i $PATH$ -f wav - | [lame] --silent -q $QUALITY$ $BITRATE$ - -

mod pcm * *
# F:{PATH=%f}R:{PATH=%F}B:{BITRATE=-B %B}T:{START=-ss %s}
[ffmpeg] -loglevel quiet -i $PATH$ -f u16le -

mod flc * *
# F:{PATH=%f}R:{PATH=%F}B:{BITRATE=-B %B}T:{START=-ss %s}
[ffmpeg] -loglevel quiet -i $PATH$ -f flac -


custom-convert.conf


mod mod - audio

custom-strings.txt


MOD
EN Amiga MOD audio

bpa
2017-12-01, 08:18
thanks for the pointer. I found the type.conf and convert.conf but could not get any ffmpeg version to accept the MOD files (ProTracker / SoundTracker compatible) as input. Just to be sure we are talking about the same thing here because MOD apparently was also the name for a video format.
When I call ffmpeg -decoders, it returns 439 decoders but the words "MOD", "Protracker", or "Amiga" don't appear anywhere in there. So I assume the format is not supported.


Just did some checking on MOD - it is not an encoding (ie. the audio is in PCM) - MOD is a muxer format so use "ffmpeg -demuxers" to list the demuxers and check if you have "libopenmpt" which is for "Tracker formats"

JoeMuc2009
2017-12-01, 11:33
Well, almost there. I added this to my custom-convert.conf:


mod flc * *
# F:{PATH=%f}R:{PATH=%F}T:{START=--skip=%t}U:{END=--until=%v}D:{RESAMPLE=-r %d}
[xmp] $PATH$ --nofilter -c -t 300 -o %TEMP%\1.wav | [flac] -cs --totally-silent --compression-level-0 $START$ $END$ -- %TEMP%\1.WAV | [sox] -q -t flac - -t flac -C 0 $RESAMPLE$ -


And this to custom-type.conf:


################################################## #######################
#ID Suffix Mime Content-Type Server File Type#
################################################## #######################
mod mod audio/x-amiga-mod audio

This actually results in LMS being able MOD files when picked from the directory view in LMS's control interface in the browser. It doesn't even take long until the music starts. About 3 seconds average. Not too bad.

HOWEVER:



neither the file name nor the module's internal name is shown. The latter is no surprise as there is nothing to extract the name from the MOD file and hand it over to LMS to pass it through to the player's display
the resulting stream is like a web radio stream. I cannot skip to a given point in the playback
in the browser it looks like nothing is playing at all during playback, see screenshot below
I'm not happy working with a temporary file that always has the same name. This would not work if two users wanted to consume MOD files at the same time. As LMS is Windows-based here, I cannot take xmp's output and pipe it directly to flac as one would do in Linux. It seems that it cannot work without files in Windows at all
the scanner apparently overlooks the .MOD files completely so they never make it into my library. I have to use the file system / directory based file picker to see modules


24112

So this illustrates that the total play duration is shown on the left instead of right (which is always 0:00 with modules). And no information whatsoever on what is currently playing. Funny.

Looked at ffmpeg again and it seems that it is not capable of using libopenmpt. Even though I put its binaries in the same directory as the ffmpeg executable, this is what I get:


>ffmpeg
ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100

No libopenmpt in the list :( and no --enable-libopenmpt switch is available

JoeMuc2009
2017-12-01, 11:39
Oh by the way, credit where credit is due, the idea to use XMP comes from this blog:

http://blog.netflowdevelopments.com/2012/03/11/how-to-batch-convert-xm-mod-files-to-wav-files-in-linux/

At first it seemed that XMP is a Linux-only tool but it's actually open source and can be compiled on Windows as well.
The sources can be found here:

https://sourceforge.net/projects/xmp/files/xmp/4.0.7/

I think it's legal to offer the compiled Windows EXE to anybody who desires to have it and can't compile themselves. Just PN me if you want it.

JoeMuc2009
2017-12-01, 13:05
Okay, my solution sucks. It is not possible to add the modules to the playlist. So it's either play them all from A to Z, or pick one, and playback stops after this one so I have to pick the next. The rest of what LMS or the playback devices offer appears to be mostly brain-dead. It should all behave just like the modules were "proper" source audio file streams but I'm still far from that.
Maybe a plugin that worships the information extracted from the MOD file such as title, length, etc. would do a better job here. Also I would like to influence some parameters like "how many times are jump commands at the end of the song followed"? Because a lot of MODs are designed to run indefinitely by picking up playback at a given location once the end was reached, but there should be an end if they are part of a playlist. And this is something that needs to be determined before converting the MOD to anything else.
Moreover, Amiga computers had a built-in low-pass filter that, if engaged, would cripple a good bit of the spectrum but is closer to what we (Amiga users) feel is original. It should be possible to engage or disengage, at least in the configuration so it can be changed on demand. Good playback tools like Modplug have configurable filters and algorithms for post-processing of the 8-bit output to give it better quality. The stereo experience should adjustable between full channel separation and mono. It's all missing if the toolchain is fixed the way I set it up.

bpa
2017-12-01, 13:17
No libopenmpt in the list and no --enable-libopenmpt switch is available

"--enable-libopenmpt" is a ffmpeg configure/build parameter not a runtime parameter but you probably need to have the library built and installed for the option to be available.

For LMS to "know"about a file - it needs to be scanned and that means updating the LMS scanner about MOD. I think you'd be better off converting the MOD files to a know format such as Flac.

Roland0
2017-12-01, 13:34
It should all behave just like the modules were "proper" source audio file streams but I'm still far from that.
Maybe a plugin that worships the information extracted from the MOD file such as title, length, etc. would do a better job here.

Adding full support for new file types to LMS is rather involved, check out this thread (http://forums.slimdevices.com/showthread.php?107011-Howto-play-Ogg-Opus-files) for a basic overview.



Good playback tools like Modplug have configurable filters and algorithms for post-processing of the 8-bit output to give it better quality.
ffmpeg also supports libmodplug, but it needs to be configured/build with this option, similar to libopenmpt

JoeMuc2009
2017-12-01, 15:52
For LMS to "know"about a file - it needs to be scanned and that means updating the LMS scanner about MOD. I think you'd be better off converting the MOD files to a know format such as Flac.

Okay, so this means the scanner is not extensible, right? I think I underestimated the task a bit. Proper support imho means:



a directory full of .MOD files can be added just as easily as any other directory containing MP3, OGG, FLAC, whatever
MOD files are identified in player devices by their title or file name in the library
MOD files are converted in-line as they are selected to be played. Permanent conversion into a different format is not required / not desirable to keep hard disk consumption low and to enable dynamic adding of files to the directory without the need to convert them for making them available
tagging functionality is reduced of course but it should be possible to assign a common tag like composer = Amiga or something to make all modules easily selectable
it is possible to add MOD files to a playlist just like any other media file
while a MOD file is being played, it is possible to jump back and forth in the "timeline"
some settings like spatial audio, filters etc. can be adjusted through a dedicated LMS plugin page


If that's not possible, I can live with it - eventually did so for years now. Listening to the good old modules on my main Hi-Fi set today was kind of gorgeous despite the bad support in the UI.

Another very stony way out of this mess might be a "virtual" MP3 directory shell extension, similar to many backup solutions which allow to mount their backup archives as a file system in which the user can browse down to any single file. It would present a lot of tagged MP3 files which never actually exist, each of which mirrors a respective .MOD file. The mounted structure could be scanned like a normal directory and LMS's scanner would never know the difference... Okay, this is getting crazy.

Anyway, thanks anyone for your input.

Cheers,
Joe

bpa
2017-12-02, 02:59
Roland0's link provides more detail.

To do most of what you asked - scanner needs to support MOD format. I have never looked at scanner in detail but I believe it cannot be extended by the presence of files of custom code like plugins - it needs the Scan::Audio Perl module to be updated part of which is written in C.

Conversion of MOD file to a known format would provide the same features with no development effort.

The "some settings like spatial audio, filters etc. can be adjusted through a dedicated LMS plugin page". I don't know what is special about MOD files - if these are just settings for the MOD transcoder command line - if so then a special plugin/handler is needed. IIRC There have been plugin s which modified the audio stream for all sources (e.g. RC) such as BruteFir or Inguz, these could be alternative starting points.

JoeMuc2009
2017-12-02, 03:46
Thanks again, it's cool that there are people around willing to share their expertise. Really appreciated! :)
I should emphasize that this is purely sentimental. MOD is the format used for trackers, or sequencers, back in the days of 16-bit home computers which had very limited RAM and disk space. A MOD is basically a collection of so-called patterns which contain the sequence of samples (~instruments) to be played in up to four channels, the note values for each entry, plus special commands like volume changes, vibrato, volume / tone slide, arpeggio, play speed etc.
Patterns are arranged in a list so it is possible to play the same pattern or sequence of patterns multiple times with just one additional byte needed per pattern in the pattern list. So far it is similar to MIDI.
Eventually the samples, which typically occupy most of the payload, follow one after another in the same file, basically a list of 8-bit (!) waveforms with size info and optional loop info to enable a sample to repeat itself at a given point and restart at another given point to play indefinitely. This is where MOD is fundamentally different from MIDI which relies on samples being stored in the playback machinery, and configured externally such that the right instruments are patched. A MOD would bring its own instruments at all times, ensuring the experience is the same no matter what.
All this is very economic. A MOD is not a linear audio stream but relies on repetition and saves lots of space by enabling playback of samples at arbitrary frequencies so the same sample can be played in three octaves. Just a few kilobytes of input could give you hours of playback. Plus, it supported creativity a big deal because one could "steal" samples from existing modules to use in one's own, and learn pattern arrangements, effect commands and their overall use from others easily. Associated programs like SoundTracker, ProTracker, StarTrekker etc. made it easy to work with modules. Their results were used in the entire demo scene and most of the games back in the day.
Amiga computers introduced this technique as far as I remember, and added some "artifacts" like the low-pass filter that was usually engaged on power-up to suppress digital noise interference in the analog outputs, but would also cause the sound to appear pretty muffled. It could be switched off by a command in the MOD file, which is what virtually any composer did in the first step, or even be toggled for effects if needed. Another problem with basically any home computer was that the stereo separation was nearly 100%, i.e. the tracker channels 1 and 4 would play strictly on the left channel, 2 and 3 exclusively on the right. This is almost painful when using headphones. While some of that separation was desirable, the arrangement kind of falls apart. To bring it all closer together, I used to help myself with a resistor placed between the positive terminals of both audio outputs. The sound field got narrower this way of course but with the right resistor value the results were pretty good.
The same would have to be done in software now because I don't want this permanent resistor in my signal path. Transcoders like XMP handle filter and stereo separation through command line parameters as you stated.

But I see that I underestimated the effort needed to make it work in LMS as desired. Not a big deal, this is kind of a low-level enthusiast matter, and as hard disk space is no longer a big concern these days, I may convert at least the top 100 modules of my collection to whatever replicates them best at a good compression rate.

bpa
2017-12-02, 04:04
But I see that I underestimated the effort needed to make it work in LMS as desired. Not a big deal, this is kind of a low-level enthusiast matter, and as hard disk space is no longer a big concern these days, I may convert at least the top 100 modules of my collection to whatever replicates them best at a good compression rate.

Thanks for the more detailed explanation of the audio stream and how it is not "usual".

If you wanted to modify the scanner, you should send a PM to andyg (Andy Grundman) - when he worked for Slimdevices he wrote the Scan Audio module which then got put into CPAN. He has good knowledge in audio formats area. Since there seems to be a decent library "libopenmpt" obtaining the metadata should not be difficult (i.e. no parsing ).

Not sure how time index to jump to specific time points in the file will work ( IIRC MP3 & Flac it is estimated, MP4 has an index table) but this is normally a command line parameter passed to transcoder.

JoeMuc2009
2017-12-02, 05:05
...
Not sure how time index to jump to specific time points in the file will work ( IIRC MP3 & Flac it is estimated, MP4 has an index table) but this is normally a command line parameter passed to transcoder.

It's a demanding task to get this right, especially as a track can loop indefinitely. So if the user desires to go to, say, 75%, where is the code supposed to jump then? I really don't know but Winamp (with Oldsk00l plugin) and Modplug can do this rather smoothly and with expected results. Probably they do not respect any loops and just use the slider to navigate to the respective point in the pattern list to start playing right there.
The special challenge here is that an instrument may keep playing from a previous pattern (the self-looped samples I mentioned earlier), but if you jump to the pattern at the selected position, the instrument is not triggered to play again because that was done in the pattern before. So the code has to look back a little, too, to make this perfect. Also the playback speed (bpm) may be varied in the course of a pattern sequence and if you skip to a pattern that relies on a set speed instead of setting its own, you may find the part of the module playing too fast or too slow.

Anyway, I'll see when I have more time for this matter.