MOD playback

Code example

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, with dosbox.




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


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 :
MOD format specification :
Hitmen's original modplayer :
Hitmen's MODCONV utility :