Opened 14 years ago

Closed 12 years ago

Last modified 7 months ago

#8491 closed patch (outdated)

Experimental MikMod support

Reported by: eriktorbjorn Owned by: sev-
Priority: normal Component: Audio
Keywords: Cc:


This patch adds experimental MikMod support which could
possibly be used to play the MOD music from the Amiga
versions of some games. Originally, I had planned to
support both MikMod and ModPlug, but I decided MikMod
was probably much more common.

This code is not particularly well tested, and it does
not support seeking. But it's a start.

Ticket imported from: #1372271. Ticket imported from: patches/596.

Attachments (3)

mikmod.diff (11.7 KB) - added by eriktorbjorn 14 years ago.
Patch against a December 2 CVS snapshot (6.6 KB) - added by cyxx 14 years ago.
RJP1 player for FOTAQ amiga music files
modules.diff (11.7 KB) - added by Kirben 13 years ago.
Updated mikmod patch, with looping.

Download all attachments as: .zip

Change History (29)

Changed 14 years ago by eriktorbjorn

Attachment: mikmod.diff added

Patch against a December 2 CVS snapshot

comment:1 Changed 14 years ago by eriktorbjorn

I should perhaps add that the only thing I've tried so far
is replacing a track from the CD version of Monkey Island 1
with a MOD file. That, at least, seems to work.

comment:2 Changed 14 years ago by Kirben

No offence, but this method of MOD support doesn't seem of
any use for Simon the Sorcerer 1. A few points:

1. We need to load MODs from specific files, the current
method leaves it hard coded with 'track%d.mod'

2. For the disk versions of Simon the Sorcerer 1 the music
needs to be depacked first and can't be loaded directly
from a file.

3. Should we require another library for ScummVM? does
MikMod support the MOD formats required by other games? or
just Simon the Sorcerer 1?

I think it would be best to work out the requirements for
MOD support of all games in ScummVM, before adding any code
to CVS.

At the moment MOD support is required for the Amiga
versions of these games:
Inherit the Earth
Monkey Island 1
Simon the Sorcerer

Maybe Flight of the Amazon Queen too, if someone was
interested in completely code, as recently mentioned on

Simon the Sorcerer 1 needs to play and loop a single MOD,
from a single file, stopping the current MOD playing first.
Each '%dtune' file contains a single MOD, in Protracker
format. But the '%dtune' file can't be loaded directly,
since the file is packed in the disk versions.

Monkey Island 1 uses the TFMX format, with music tracks
stored in 'music.dat' and sound effects are in 'sample.dat.
So needs to read MODs from file offsets, stop specific
MODs, loop MODs and play multiple MODs at once (ie sound
effects over music).

I'm not sure what the requirements of MOD support in
Inherit the Earth are. _sev, could you list details?

comment:3 Changed 14 years ago by Kirben

Owner: set to sev-

comment:4 Changed 14 years ago by eriktorbjorn

Well, the file name is only hard-coded as 'track%d.mod' if
you play it through the Audio CD manager. It should be
possible to create a MOD input stream from any File handle,
though I haven't tested this myself yet. I was deliberately
modelling the patch on how we support MP3, Ogg Vorbis and
FLAC. At the moment, it's more a proof-of-concept than a
finished patch.

To support depacking, it should be trivial to extend it to
read the MOD data from a stream instead. Then the Simon
engine could either have a depacking stream class, or depack
it into a buffer and use a memory stream. Maybe.

To support MOD at all, the only ways I see - short of
re-inventing the wheel ourselves - is to either depend on
another library, or copy the relevant parts of that library
into ScummVM. The licenses for MikMod and ModPlug would
allow either way, I believe.

I don't know which MOD formats are used by other games.
MikMod does support several formats - see - but it does not
support TFMX.

comment:5 Changed 14 years ago by sev-

It may happen that libmikmod is an overkill.

I know these games which use different flavours of tracker

MI1: TFMX. There exists only one awfully writtent player
Kyrandia: Max Trax. UADE/deliplayer play it, but do it by
means of interpreteting Amiga code, no C equivalents
FOTAQ: RichardJosephPlayer. Cyx wrote incomplete
implementation for that
Simon: Protracker, i.e. plain MOD.
ITE: Protracker

I.e. right now out of libmikmod we will use only MOD, which
is simplest, stable and very known tracker format.

From the other hand the library has quite nice unified
tracker format where all different formats are converted to.
So we probably may write/adapt parsers for other formats and
maybe even contribute them back to libmikmod or some other
open MOD player. But of course this may not work and in this
case it would be probably good to strip down libmikmod or
find some another smaller MOD->Wav convertor and use that.

comment:6 Changed 14 years ago by SF/kaminari

I don't know the details of its distribution model, but
isn't BassMOD a possible alternative? It's been used in SF
and SDL-based projects.

comment:7 Changed 14 years ago by sev-

You say something weird. BassMOD is closed sourced, it's
precompiled only for four platforms. Moreover, speaking of
BASS, you should buy a license for using it.

comment:8 Changed 14 years ago by SF/kaminari

"The BASS library is free for non-money making use -- if you
are not charging for the software (and it has no other
commercial purpose, eg. advertising), then you can use BASS
in it for free."

You're right about the rest though. Anyway, it was just a

comment:9 Changed 14 years ago by fingolfin

No way we would use this BASS library, they aren't
compatible with the GPL spirit at all.

As for TFMX: I thought that this wasn't a MOD format at
all...Yeah, some mod players support it, but mostly because
it also comes from the Amiga, not because it's MOD.

Homepage of the TFMX creator:
XMMS-TFMX plugin (source):
CocoModX (OS X player which supports TFMX:
The tfmx code CocoModX uses (based on tfmx-play):
TFMX format description:

comment:10 Changed 14 years ago by fingolfin

(oh and not to forget:

Changed 14 years ago by cyxx

Attachment: added

RJP1 player for FOTAQ amiga music files

comment:11 Changed 14 years ago by cyxx

Just wanted to mention that I completed my RJP1 player. I'm
attaching it here just for reference. I don't know yet
when/how this will get integrated to the queen engine...
I'll see.

Speaking of TFMX, I second sev, the code for the existing
player is hard to follow and apparently all the macros are
not implemented.

comment:12 Changed 14 years ago by sev-

I chat with UADE folks about all of this and got several
source codes of different amiga players (in m86k asm of course).

Updated list of Amiga formats used by ScummVM:

MI1: TFMX. Not a MOD format
FOTAQ: RichardJosephPlayer. incomplete player attached
Simon: Protracker, i.e. plain MOD.
ITE: Protracker. Several C implementations exist
Gob2, Gob3: Infogrames player (potential target)
Kyrandia1: MaxTrax. Well commented source by Joe Pearce :)

For these to be implemented we will need to reimplement our
mixer and add on-the-fly resampling ratio change. It will
make it slower, so proper solution would be to make it
turneable, i.e. for constant rate games (default) it will
use current codepath, and for Amiga games it should use
different, more complicated one. Probably it could be even
done just by subclassing our mixer with Amiga features and
use it in appropriate games.

It would be nice to create some set of common routines or
something, so it will ease development. It will not be very
nice to have 6 completely separated players, but have at
least something comming between them (IMHO).

I haven't move more than talking about it due to
superbusy-ness with my daily job.

comment:13 Changed 13 years ago by sev-

A little update (it's better later than never). I've got a
MOD tracker from madmoose in excellent shape written on top
of OSystem work and consistent with our coding style. Now
it's the matter of testing it and commiting.

comment:14 Changed 13 years ago by (none)

As far as I remember, UADE also supports TFMX.

comment:15 Changed 13 years ago by sev-

As I explained in another bugreport, UADE is not suitable
for us. Yes, it can play TFMX, but UADE is plain
EaglePlayer. I mean plain, i,e. it is Amiga emulator plus
m68k binary code which gets interpreteted. We need pure C++

comment:16 Changed 13 years ago by SF/mld

hej, just a small note about the simon mods /mikmod as

Do play them as noisetracker instead of protracker otherwise
you get a too strong vibrato/tremolo effect which sounds not

Secondly... Just to raise awareness. mikmod (and modplug)
has big issues with amiga mods and lacks certain features
some of the more sophisticated mods use. - However as far I
can hear Simon mods seem to be quite plain to be used.

About the tfmx mi1... There's actually a quite good
protracker cover of the tfmx-pro music by c.huelsbek on ham
Not sure if it's complete... Maybe it's easier to hack
something up with this. (using hardcoded plist position for
the different subsongs).

happy easter,

mld/uade team

comment:17 Changed 13 years ago by SF/mld

hmmh, otoh forget the mi1 mod... it's incomplete and since
it uses the original instrument samples it's probl. legally
off-limits for scummvm to use... sorry

anyway happy easter =:*B

mld/uade team

comment:18 Changed 13 years ago by Kirben

Due to improved support for Amiga and AtariST versions of
AGOS engine based games, support for Protracker music could
be very useful now.

I attached an updated version of eriktorbjorn's patch,
which allows module music to be played in Amiga/AtariST
versions of all AGOS engine based games.

Changed 13 years ago by Kirben

Attachment: modules.diff added

Updated mikmod patch, with looping.

comment:19 Changed 12 years ago by fingolfin

Could somebody explain how this patch compares to the "new" code in sound/mods/ ?

comment:20 Changed 12 years ago by eriktorbjorn

I submitted the patch because I figured it would be easier to use an existing MOD player. I guess it's obsolete now.

comment:21 Changed 12 years ago by Kirben

This item could be closed now, as Protracker support is covered by ScummVM, which was the main reason for using the MikMod library. Protracker support is working in agos engine, and available for parallaction and saga engines in future, if required.

The Amiga ports currently aren't supported by kyta, queen or saga engines. So would be best to move remaining information to wiki or another tracker item for future reference.

The main format currently required by ScummVM, would be SoundFX format used by cine engine. Which was not part of the previous discussion at all.

comment:22 Changed 12 years ago by fingolfin

Eugene, can we close this?

comment:23 Changed 12 years ago by sev-

Yes, as soon as Wiki is up now and I move this info there :)

comment:24 Changed 12 years ago by sev-

Ok, closing this, as info was moved to Wiki,

comment:25 Changed 12 years ago by sev-

Resolution: outdated
Status: newclosed

comment:26 Changed 7 months ago by digitall

Component: Audio
Note: See TracTickets for help on using tickets.