How to create an IMF file
This is a short guide that hopes to explain a couple of different ways of creating IMF files from scratch.
Creating a new IMF file will allow you to provide new background music for these games:
- Bio Menace
- Blake Stone
- Catacomb 3-D
- Commander Keen 4-6
- Corridor 7
- Cosmo's Cosmic Adventures
- Duke Nukem II
- Hocus Pocus
- Major Stryker
- Monster Bash
- Operation Body Count
- Realms of Chaos (beta version only)
- Wolfenstein 3-D
This procedure allows you to create an IMF file from a source MIDI.
Create a MIDI file
This is the hard part (because you need musical talent!) Create a MIDI file in your favourite sequencer. Rosegarden is free, as is the DOS-based Voyetra Sequencer Plus Gold which was used by Bobby Prince to create the MIDIs behind many of the original IMF files. Because this method goes via CMF format which handles percussion very differently to MIDI, the source MIDI file will need to follow certain rules for its percussion. Each instrument should be on a different channel, and the pitch of the note will, like normal MIDI instruments, affect the pitch of the percussion instrument. (If you just use normal MIDI percussion where everything is on channel 10 and different notes play different instruments, it will be converted as a single instrument - say a drum - playing different notes.) The easiest way to do this is to ignore channel 10 entirely when composing your MIDI file.
The instruments you choose are unimportant as they will be overridden later.
When you have your MIDI file you must export it as a type-0 format MIDI, as MID2CMF in the next step only supports type-0 files (they only have a single track.) You will no doubt want to keep your original multi-track file in case you need to do some more work on the song later.
The OPL is only able to play nine notes simultaneously, so the easiest way to work within this limitation is to use channels 1 through 9 in the source MIDI, and only ever play one note at a time on each channel. Because CMF files use the raw MIDI data unchanged, some special MIDI controllers can be used to adjust how the CMF file sounds. There is a full list in the CMF format article however the main one is MIDI controller 0x67 (decimal 103) which is used to enable and disable the OPL's rhythm mode. When this controller is set to 1, rhythm mode is activated. This sacrifices three instruments to gain five percussion-only instruments, for a total of 11 simultaneous notes. In this mode only channels 1 through 6 are used, and channels 12 through 16 are used for the new percussion instruments (see the CMF article for the exact instrument-to-channel assignment.) It is still possible to use program change events to change the instrument on these percussion channels, and indeed this is how different types of drum and snare sounds are produced.
Download MID2CMF and convert the MIDI file into CMF format. At this point the instruments will sound bad, but as long as the song otherwise sounds good enough proceed to the next step.
Download SBTimbre and run it through DOSBox. From the File menu, import the CMF file that was created in the previous step. Once the instruments have been tweaked to perfection, export them back to the same CMF.
The CMF file should now sound perfect (e.g. if you play it in Adplug.) Download CMF2IMF and convert the CMF file into IMF format. Remember to use the correct speed and type options for the game you will be using, as shown below.
|Commander Keen 4-6||560||0|
|Cosmo's Cosmic Adventures||560||0|
|Duke Nukem II||280||0|
|Operation Body Count||700||1|
|Realms of Chaos||?||?|
For example to create an IMF file that Commander Keen will accept (speed 560, type 0) run:
cmf2imf --speed 560 --type 0 in.cmf out.imf
This will create out.imf which can then be merged back into the game files.
You should now have an IMF file suitable to be re-imported back into the game data files! See the game's page on this wiki (in the main game list) for other utilities that can assist with this.