• Status Closed
  • Percent Complete
  • Task Type Patches
  • Category Codecs
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by myth - 2006-04-26
Last edited by linuxstb - 2008-03-03

FS#5241 - MOD player codec (not based on dumb)

This is an experimental MOD player codec. It is based on an old open source module player for gravis ultrasound (unfortunately I forgot the name, if anyone finds out please inform me). I added a fast mixing routine and did a quick rockbox port. Yet the source is quite unpolished, but it plays fine on my h320.

Current features:
* Plays startracker/protracker modules (4-8 Channels)
* Unfortunately only modules up to 486kbytes (due to codec memory limitation)

Song length calculation is not implemented (should be no real problem though)

Closed by  linuxstb
2008-03-03 21:37
Reason for closing:  Rejected
Additional comments about closing:   Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407

The original version of this patch can't be included in Rockbox due to the unclear license.

A written-from-scratch MOD codec released under the GPL is at acker/task/8680

myth commented on 2006-04-26 22:38

Corrected a bug within the 0d00 effect and readded the 0e00 effect. Most songs should sound normal now.

Apply the mod_v0.1.diff from above and replace the apps/codecs/mod.c with the new one

   mod.c (35.9 KiB)

I’m pissing my pants right now…can’t wait to test it!!!

it really works!!!!

download experimental 2.4.17 with this patch

dma commented on 2006-06-17 16:52

Nice work, but a codec not limited to MOD files would be so much more interesting. :)

myth commented on 2006-06-27 14:28

Implementing other tracker-formats is theoretically possible, but we have to solve memory limitations first. Currently we can not realiably store more than 512kbyte sample data. And this is a killer for many XM/S3M files.

myth commented on 2006-07-18 21:34

Here is an update for the latest CVS. It now merges fine together with SID codec.

how exactly does this audio format work? is it like MIDI, which just store “notes” into a file and requires special software to decode and “mix” the notations into “music”


JFYI: Does no apply to the new codec system. I guess it needs some rework.


Adapted to current CVS. It works fine - hope I haven’t missed anything.

Can someone please update this to go with current CVS? THere are two problems: The one is that the definition of the metadata extraction routine must be moved a bit. But the bigger problem I couldn’t solve is what with DSP_DITHER which is undefined.

Thanks a lot and all the best


DSP_DITHER is not needed anymore and the line that uses it can be removed.

I have attached the patch I am using - I have moved all the mod stuff away from the end of the queue, so it doesn’t constantly get out sync when new codecs are added.

Without any guarantees. ;)

Thanks, this did work.

updated to work with current CVS

Skyly commented on 2006-11-13 18:07

Works with the Nov 13 build too. God bless you for this patch hehe.

Skyly commented on 2006-11-14 06:38

Doh, except any mod you play gets stuck on repeat, so they’ll hold up a playlist you put them in.

myth commented on 2006-12-11 13:03

Here is an updated mod.c for the latest CVS. Just apply the mod_v0.5.patch and replace the mod.c with this one.

   mod.c (35.7 KiB)

I just tried it on h120, current cvs – I get hard lockups of my player :(

fixed :)

I modified the patch, so that the titles only get played one time and don’t loop automatically. Intentional loops (mod effect 0x0b) are only done once. This makes it finally possible to play multiple mods in a playlist.

I also implemented a crude form of seeking. It is done in the “pattern order” table, so the wps will display the the position in this table as current time and the size of the table as song length. As a result we get some sort of progress bar as well. Expect some funny effects, as some mods don’t use the full table or use it out-of sequence with the effect 0x0b. Also set-tempo effects and such like may be skipped leading to a wrong speed of the mod. But better than no seeking at all, IMO.

myth commented on 2006-12-12 18:17

You guys rock!

Copy sample text (greetings etc) to title meta tag which is then displayed in WPS (provided %s is on %it line). Also file size (in kb) is displayed instead of bitrate. Slightly improved progress bar accuracy.

Needs updating for today’s SVN. Is it possible to also implement a FastTracker player (i.e. xmz)?

Updated patch.


synched again

MikeS commented on 2007-02-10 17:24

That was quick :)

incorporated MikeS’ replaygain fix

needs an update. amazing patch by the way.

what do you mean by update? It works with current svn?

nevermind me. it does. somehow it didnt want to compile with the patch removed and applied again later on. i actually had to delete mod.c and start anew.

The ipod mini 2g doesn’t have enough IRAM. So this version of the patch doesn’t put any code in IRAM. It may mean that it is not fast enough now. Maybe someone with that target can report.

Just tried it on my mini 2g with a couple of mods, works fine. If you have any stress test files let me know – I got boost levels up to ~30%, so it’s quite fast on the mini. The file might have been too easy for the decoder though ;-)

Proper fix according to NLS’ advice in

While I was at it I changed it so it displays the mod type (number of channels) as the genre string.

out of sync as of 04092007.

What seems to be the problem? Works fine for me:

$ patch -p0 < mod_v0.14.patch
patching file apps/codecs/Makefile
patching file apps/codecs/mod.c
patching file apps/codecs/SOURCES
patching file apps/metadata.c
patching file apps/tree.c
patching file firmware/export/id3.h
patching file firmware/id3.c

gives multiply “previous definition of “…” was here” errors in mod.c while compiling.

My guess is you didn’t properly undo the patch (revert is not enough) and now have the source code twice within mod.c. Have a look.

thats what i thought at the beginning but i did the svn revert and applied it to the clean code. i’ll look into it more.

Like I said in my previous comment “svn revert” is not good enough. It will only deal with already existent files and not touch added files like mod.c.

Flake commented on 2007-04-13 03:43

What about .xm (Mad Tracker) and .it (Impulse Tracker) support?

Aye me wants that too


anyone able to patch the latest rockbox build?
I fetched it from from csv today and get the following result:
debian:/home/root/rockbox# patch -p0 < mod_v0.15.patch
patching file apps/codecs/Makefile
Hunk #1 FAILED at 48.
1 out of 1 hunk FAILED – saving rejects to file apps/codecs/Makefile.rej
patching file apps/codecs/mod.c
patching file apps/codecs/SOURCES
patching file apps/metadata.c
Hunk #1 succeeded at 1764 (offset 50 lines).
Hunk #2 succeeded at 2342 (offset 50 lines).
patching file apps/filetypes.c
Hunk #1 succeeded at 67 (offset -37 lines).
patching file firmware/export/id3.h
patching file firmware/id3.c

Any ideas?

It’s just the makefile, open the .rej file and change it yourself, it should only be one or two lines.

I’ve updated the patch and created a little workaround for problem with strncasecmp.

Should compile against the latest svn.

The previous patch broke after ape.c was added. Fixed patch.

synced after metadata.c split

synced after changes to get_metadata

Hi. I’m new to this - I keep getting errors when trying to apply the mod_v0.19.patch. Can somebody please tell me what I’m doing wrong? I believe I have the latest Rockbox source.

Thank you

“patching file apps/codecs/Makefile
Hunk #1 FAILED at 48.
1 out of 1 hunk FAILED – saving rejects to file apps/codecs/Makefile.rej
patching file apps/codecs/mod.c
patching file apps/codecs/SOURCES
Hunk #1 FAILED at 12.
1 out of 1 hunk FAILED – saving rejects to file apps/codecs/SOURCES.rej
patching file apps/filetypes.c
Hunk #1 FAILED at 67.
1 out of 1 hunk FAILED – saving rejects to file apps/filetypes.c.rej
patching file apps/metadata.c
Hunk #1 FAILED at 293.
1 out of 1 hunk FAILED – saving rejects to file apps/metadata.c.rej”

It still applies fine, but here is a new patch anway

:-( I just checked out the latest source from SVN and I’m afraid the 0.20 patch doesn’t work either.

Am I doing something wrong? I put the patch into the rockbox folder - the same folder where I can see apps, docs, bootloader folders etc. and tried “patch –binary -p0 5241_20.txt”

Any help would be appreciated. I’d love to get this to work.


–binary is unnecessary/wrong

and I take it the missing < is just an oversight

patch -p0 < 5241_20.txt

Thanks for that. Hehe. Silly me - I just started manually making the changes but thanks - it will help me with future patching attempts. Fingers crossed!! :^)

Yay!! It all compiled fine.. Now which files (other than the .codec files) do I need to put onto the iPod please? Is there a document online somewhere on this site that describes the process of which files are required under the .rockbox folder on the iPod?

I appreciate your help and I’m sure anybody else reading this who is trying to do the same thing will also.


use atomic buffer type (don’t blame me!)

This has been discussed in IRC a few times, but I thought it was worth adding here. There seems to be some concern over the license of this codec - the main codec file contains the text:

“* Sequencer taken from Gravis Ultrasound open source mod player (forgot the name, if anyone finds out, please insert *g* )”

The general view is that we can’t commit this to SVN and include in the official builds when the license to the source code is unknown - claiming that it was “open source’ isn’t enough. Can anyone identify the original mod player that the code in this codec comes from? Or failing that, maybe the sequencer could be replaced with one from a known (GPL-compatible) source?

(and a minor comment - my name shouldn’t be the (C) holder in apps/metadata/mod.c)

Spent some time looking at the source a couple weeks ago, and it looks like it’s roughly based on an old, pre-commercial version of FMOD.

myth commented on 2007-12-18 16:19

That seems to be correct, it is an old fmod version. Now what does that mean? The source states “public domain” - if we properly credit the author can we put it in SVN?

The license text in seems to contradict itself:

“Legal Notice: This source is public domain. This code cannot be redistributed commercially, in any form whether source code or binary without the prior consent of the author.”

IIUC, by placing a work in the public domain the author is relinquishing all legal rights to it, and hence can’t dictate conditions on its use.

So I’m not sure if this helps us - we’ve moved from having no license, to having a nonsensical license…

I think the safest way is for someone to contact the author of fmod and ask for permission to use the code under a GPL-compatible license - i.e. one which doesn’t prevent commercial use.

myth commented on 2008-02-13 10:27

Can someone please confirm that this codec will be included in the official branch once the license issues have been solved? I think the best way is to rewrite the sequencer code.

I can see no reason for it not to be commited if it works well and there are no further licensing issues.

myth commented on 2008-02-18 21:24

Alright, I have started rewriting the whole player from scratch. A first impression should be ready next week.

myth commented on 2008-02-24 23:04

Just wanted everyone to know that the new license-free routine made some progress. It can now load and play basic .mod files. More to come in a few days.

adapt change from r16410

myth commented on 2008-02-25 14:58

I have a license question: Can we make use of the original amiga period values out of the amiga protracker source code? Or do we have to calculate them on start? Or in general: Can precalced tables be copyrighted (especially if the calculation is not a secret)? What if I precalc them “offline” and include them so they look the same way as the original?

Just to make sure we don’t have any future license issue.

myth commented on 2008-02-27 22:47

Here we go with the first release of the license free mod codec.

First of all the good news:
- Fresh from my fingers and totally license free. Doesn’t even make use of “magic tables”.
- Support for more file formats (e.g. 15 instrument files)
- Improved mixing routine (sounds by far better!). There was a major bug in the old routine *g*
- Improved playing and effects handling (especially for chip-tunes)

Now the bad news (for now):
- It plays fine in the simulator, but does not on the real machine. I have yet no idea why this is so.
- Seems to have problems with some mod files (requires some more bugfixing)
- There are some enhanced effects (0xe) missing. I will add that later.

For installing simply apply the above patch and replace mod.c with the new one. I tried hard to include lots of comments, so help is welcome.

   mod.c (33 KiB)
Project Manager

Good work!

But I think it’s a pity that you spent all this time rewriting from scratch and didn’t follow the coding guidelines in docs/CONTRIBUTING…

myth commented on 2008-02-28 18:51

The license-free routine now plays fine under both simulator and machine. I also removed the typedefs in order to start following the coding guidelines (thanks Linus).

Still to do:
- Effect bugfixing
- Adding the ID3 features / instrument name display from the old source

   mod.c (33.6 KiB)
Project Manager

Good work once more!

I still have issues with the coding style. Here is an excerpt from docs/CONTRIBUTING:


We do not want mixed case identifiers.
Variables and function names should be all lower case.
Struct and enum names should be all lower case.
Preprocessor symbols and enum constants should be all upper case.


We only use plain old /* C standard comments */.
If you want to comment out large blocks containing other comments, use #if 0.


When changing code, follow the code style of the file you are editing.

When writing new files, you may use the brace placement style of your choice.

Braces for function declarations are put in a new line under the name, as in:

int foo(char *name)
   return FOO_NAME:

Always indent your code with four spaces. Don’t use TAB characters, as that
will mess up code display in CVS, printing, and a zillion other places.

Keep lines below 80 columns length. Use whitespace and newlines to make the
code easy to browse/read.

I hope you decide to try to follow them, it would be a shame to miss out this new shiny codec because of that.



myth commented on 2008-02-28 21:17

I promise I will completely follow the guidelines, soon ;) Anyway here is the latest version including effect bugfixes. A lot of modules should play now.

myth commented on 2008-02-28 21:19


   mod.c (34.3 KiB)
myth commented on 2008-03-03 20:53

I moved the whole license free mod codec to I’d suggest we don’t use the old codec anymore and concentrate on bugfixing the new one.


Available keyboard shortcuts


Task Details

Task Editing