Skip to content

Latest commit

 

History

History
59 lines (36 loc) · 2.85 KB

README.md

File metadata and controls

59 lines (36 loc) · 2.85 KB

Planet X3 MIDI converter

A simple utility for converting a Standard MIDI File (.MID) into the custom Planet X3 format (it is just a long MIDI event dump).

IMPORTANT: The files that this program outputs are uncompressed! They will not load in a standard Planet X3 installation, and will likely result in the game crashing upon attempting to load!

ALSO IMPORTANT: If the output file is over 63798 bytes in size, it will overflow into other parts of memory, causing undefined behavior! If the output file size exceeds this amount, try shaving the original MIDI down (by removing certain "expensive" effects - i.e. vibrato using rapid pitch bend changes, etc.).

Dependencies

  • a *NIX system (only GNU/Linux has been tested so far), Windows Subsystem for Linux also theoretically possible
  • Python 3
  • midicsv (usually available directly from your system's repo)
  • libfluidsynth (optional, only required for the player)

Usage

To convert a MIDI file, run the following:

./convert.sh <input file> <output file> <header byte>

Each music file for Planet X3 has to contain a specific header byte, which tells the engine what device to play the file on and which decoder to use. For MIDI, only the following values are allowed:

  • 5 → for Roland SC-55 (and other GM-compatible synths)
  • 6 → for Roland MT-32 (and compatibles)

Other values will result in undefined behavior.

So, for example, if we want to convert the main menu song for the MT-32, we run the following:

./convert.sh ~/Documents/Planet\ X3\ Digital\ Download/Soundtrack/Roland\ MT-32/MIDIFILES/PX3\ 15\ Into\ Battle\ \(MT-32\).mid menu.bin 6

Replace the path to wherever your Planet X3 Digital Download is actually located on your system.

By running this command, the original MIDI file will be converted to midi.bin, which should appear in the same directory as this program.

Player

This repository also contains a small player program based on FluidSynth.

NOTE: This player is only intended to test the functionality of the output. While files intended for the SC-55 will sound flawless, the quality will severely decrease when attempting to play files intended for the MT-32, as that variant of the soundtrack requires custom instruments to be loaded, which is not possible here.

To compile it, run:

cc playbin.c -lfluidsynth playbin

This program also requires a soundfont file (gm.sf2) to be placed in the same directory. There are several free soundfonts available, we recommend the Fluid R3 GM SoundFont, as it is one of the best free soundfonts available. Just download it, move it to the same directory as this program and rename it to gm.sf2.

To play a converted file (after you have supplied your own soundfont file), run:

./playbin menu.bin