MIDI music for games
Many hobby game developers write their soundtrack as MIDI, or find MIDI music under a free licence. Modern engines such as Godot and Unity do not play MIDI files out of the box, but they handle OGG Vorbis very well. When you convert MIDI to OGG, the music is rendered with a General MIDI soundfont, so it sounds the same on every player's computer, and stored in a compact, open format the engine can stream.
OGG also suits Android, where it is the format of the system sounds, and free software such as Audacity and LMMS.
Making music loop
Game music usually loops. A few tips for a clean loop:
- The render continues briefly after the last note so the sound can fade naturally. For a seamless loop, trim this tail in the audio editor so the file ends exactly on the bar line.
- Make the MIDI end at a bar line and start without an empty bar, so the loop length matches the musical form.
- If the last notes ring into the first bar, consider exporting a separate intro and loop section.
Bitrate guide
| Use | Vorbis setting | Size per minute |
|---|---|---|
| Background music on mobile | 96–128 kbps | 0.7–1 MB |
| Standard game music | 160 kbps | about 1.2 MB |
| Detailed orchestral score | 192 kbps or more | 1.4 MB and up |
Vorbis is variable bitrate by nature, so quiet or sparse passages take less space than the table suggests.
About the sound
The notes, instruments and tempo come from the MIDI file. The tone of each instrument comes from the soundfont, so a piece written with a specific synthesizer in mind may sound different. Listen to the preview, and adjust instrument choices in your MIDI editor if one does not fit.
For sound effects or voice lines in the same game, WAV to OGG converts recorded audio. If the music plays only in browsers, MIDI to Opus gives smaller files. Check the licence of any MIDI file you did not write before putting it in a game.