A small XM (FastTracker II Extended Module) player library. Designed for easy integration in demos and such, and provides timing functions for easy sync against specific instruments, samples or channels.
Written in C11 and released under the WTFPL license, version 2.
The playback routine (assuming the non-portable .libxm
format is
loaded, see xmconvert
below) fits in under 7KiB of compressed
machine code.
pack libxmtoau{,.packed}
./xmconvert cerror-expatarimental.{xm,libxm}
xz -9ekf cerror-expatarimental.{xm,libxm}
wc -c cerror-expatarimental.* libxmtoau.packed
118582 cerror-expatarimental.libxm
4320 cerror-expatarimental.libxm.xz
49240 cerror-expatarimental.xm
4820 cerror-expatarimental.xm.xz
6985 libxmtoau.packed
Pack script used: https://github.com/Artefact2/boilerplate-demo/blob/master/src/pack
Some example programs are provided.
-
xmgl
is a music visualiser that uses OpenGL and JACK for very precise audio synchronisation. See a demo here: https://www.youtube.com/watch?v=zZkhl6XBUVM or something similar that runs in the browser: libxm.js. -
xmtoalsa
is a simple player that uses the ALSA library. It producesxmp
-like output while playing. Usexmtoalsa --help
(or check the source) to see the full usage../xmtoalsa --random **/*.xm
-
xmtowav
will play a module and output a.wav
file../xmtowav my_module.xm my_module.wav
-
xmtoau
will play a module and output a.au
file to standard output.mpv <(./xmtoau my_module.xm)
-
xmbench
is a benchmark program. -
xmconvert
will convert a module to the non-portable format. The file produced is much larger than the original module, but it compresses down to about the same size (XXX: not true at the moment). The non-portable format can be loaded by libxm in much less code, resulting in smaller executable sizes. -
libxmtoau
is similar toxmtoau
, except that it loads non-portable files generated byxmconvert
.
Here are some interesting modules, most showcase unusual or advanced tracking techniques (and thus are a good indicator of a player's accuracy):
- Cerror - Expatarimental
- Lamb - Among the stars
- Raina - Cyberculosis
- Raina - Slumberjack
- Strobe - One for all
- Strobe - Paralysicical death
Status |##| Eff | Info | Description
--------+--+-----+------+------------------------------
DONE |00| 0 | | Arpeggio
DONE |01| 1 | (*) | Porta up
DONE |02| 2 | (*) | Porta down
DONE |03| 3 | (*) | Tone porta
DONE |04| 4 | (*) | Vibrato
DONE |05| 5 | (*) | Tone porta+Volume slide
DONE |06| 6 | (*) | Vibrato+Volume slide
DONE |07| 7 | (*) | Tremolo
DONE |08| 8 | | Set panning
DONE |09| 9 | | Sample offset
DONE |10| A | (*) | Volume slide
DONE |11| B | | Position jump
DONE |12| C | | Set volume
DONE |13| D | | Pattern break
DONE |14| E1 | (*) | Fine porta up
DONE |--| E2 | (*) | Fine porta down
|--| E3 | | Set gliss control
UNTESTED|--| E4 | | Set vibrato control
DONE |--| E5 | | Set finetune
DONE |--| E6 | | Set loop begin/loop
UNTESTED|--| E7 | | Set tremolo control
DONE |--| E9 | | Retrig note
DONE |--| EA | (*) | Fine volume slide up
DONE |--| EB | (*) | Fine volume slide down
DONE |--| EC | | Note cut
DONE |--| ED | | Note delay
DONE |--| EE | | Pattern delay
DONE |15| F | | Set tempo/BPM
DONE |16| G | | Set global volume
DONE |17| H | (*) | Global volume slide
DONE |20| K | | Key off (Also note number 97)
DONE |21| L | | Set envelope position
DONE |25| P | (*) | Panning slide
DONE |27| R | (*) | Multi retrig note
DONE |29| T | (*) | Tremor
DONE |33| X1 | (*) | Extra fine porta up
DONE |--| X2 | (*) | Extra fine porta down
Status | Value | Meaning
--------+---------+-----------------------------
DONE | $10-$50 | Set volume (Value-$10)
DONE | $60-$6f | Volume slide down
DONE | $70-$7f | Volume slide up
DONE | $80-$8f | Fine volume slide down
DONE | $90-$9f | Fine volume slide up
DONE | $a0-$af | Set vibrato speed
DONE | $b0-$bf | Vibrato
DONE | $c0-$cf | Set panning
DONE | $d0-$df | Panning slide left
DONE | $e0-$ef | Panning slide right
DONE | $f0-$ff | Tone porta
-
Only loads FastTracker II-compatible XM files.
-
Loading a bogus file (that yet has a valid 60-byte header) will probably result in a segmentation fault.
-
Big endian architectures are not yet supported.
Some test XM files are in the tests
directory. Their goal is to test
a certain feature against regressions. A summary of tests (and what
they are supposed to test) is in the table below.
Test | Status | Tested against | Extras
-------------------------------+----------------+------------------------+------------------------------------------------
amiga.xm | FAIL | MilkyTracker, xmp | Should sound identical.
finetune.xm | PASS | MilkyTracker | Left and right channels should sound identical.
note-delay-ghost.xm | PASS | MilkyTracker, FT2 | Should sound identical.
note-delay-retrig.xm | PASS | MilkyTracker | Should sound identical.
pattern-loop-quirk.xm | PASS | MilkyTracker | Should play the same notes at the same time.
ramping.xm | PASS | MilkyTracker | If XM_RAMPING is ON, no loud clicks should be heard.
ramping2.xm | PASS | MilkyTracker | If XM_RAMPING is ON, no loud clicks should be heard.
tone-portamento.xm | PASS | MilkyTracker | Should sound identical.
tremolo.xm | PASS | MilkyTracker | Should sound identical.
tremor.xm | PASS | MilkyTracker | Should sound identical.
vibrato.xm | PASS | MilkyTracker | Should sound identical.
Thanks to:
-
Thunder kurttt@sfu.ca, for writing the
modfil10.txt
file; -
Matti "ccr" Hamalainen ccr@tnsp.org, for writing the
xm-form.txt
file; -
Mr.H of Triton and Guru and Alfred of Sahara Surfers, for writing the specification of XM 1.04 files;
-
All the MilkyTracker contributors, for the thorough documentation of effects.
-
All the people that helped on
#milkytracker
IRC.