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.
- Select 'MOD (ProTracker) 4 channels' as file format.
- In the left panel, double click the sample of your choice to open it.
- In the right panel, navigate to the 'Samples' tab, then click the folder icon to import a mono, 11025Hz WAV file.
- After importing your samples, you can save the MOD file and proceed to convert it to HIT.
MOD > HIT conversion
Use MODCONV.EXE
, available in hitmen's hit-hitmod15.zip, with dosbox.
MODCONV.EXE FILE.MOD
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);
- voiceID is the PSX spu voice to use for playback; Range 0-23
- sampleID is the MOD's sample ID. That's the sample number in openMPT minus 1 as counting starts from 0.
- note or pitch. That's the note you want to play your sample on. Range 0-35
- volume is the playback volume of your sample. Range min-max 0-63
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