MOD playback

Code example

https://github.com/ABelliqueux/nolibgs_hello_worlds/tree/main/hello_mod

Preparing sound samples

Samples should be 11025Hz mono wavs :

ffmpeg -i input.wav -ar 11025 -ac 1 output.wav

Adding sound effects (samples) to a mod file

Use OpenMpt to edit an existing mod file or create a new one.

  1. Select 'MOD (ProTracker) 4 channels' as file format.
  2. In the left panel, double click the sample of your choice to open it.
  3. In the right panel, navigate to the 'Samples' tab, then click the folder icon to import a mono, 11025Hz WAV file.
  4. After importing your samples, you can save the MOD file and proceed to convert it to HIT.

OpenMPT Add sample

MOD > HIT conversion

Use MODCONV.EXE, available in hitmen's hit-hitmod15.zip, with dosbox.

MODCONV.EXE FILE.MOD

Dosbox MODCONV

One-liner

You can run a DOS command through dosbox from the CLI with :

dosbox -c "C:\PATH\TO\MODCONV.EXE INPUT.MOD" -c "EXIT"

The generated HIT file will be in the same directory as the MOD file.

Playing a sample

Using @nicolasnoble's modplayer, you can use the MOD_PlayNote() function.

MOD_PlayNote( voiceID, sampleID, note, volume);

PSX spu voices

MODs use 4 channels, which are mapped to the four first voices of the SPU by default. When calling MOD_PlayNote(), you should use voices > 4.

See here for a complete example.

Sources & Docs

Nicolas Noble's modplayer : https://github.com/grumpycoders/pcsx-redux/tree/main/src/mips/modplayer
MOD format specification : http://www.aes.id.au/modformat.html
Hitmen's original modplayer : http://hitmen.c02.at/files/releases/psx/hit-asm-mod.zip
Hitmen's MODCONV utility : http://hitmen.c02.at/files/releases/psx/hit-hitmod15.zip