Sunday, February 18, 2024

Getting various MIDI applications to work

From time to time I stumble about older applications (usually games) which use MIDI for music playback. These are some notes on how to get things working with various libraries and will be extended from now on every time I stumble upon something.

General

MIDI was originally meant to be supported by hardware, but when we are talking about today’s soundcards you won’t find any consumer sound card with hardware MIDI support any more. Because of that you need software to do the job.

This is where software such as TiMidity++ or FluidSynth come into play, but this article will only cover the requirements for specific libraries. The focus of this article are the requirements of specific applications / libraries however; for a general overview see e.g. the ArchWiki entry on MIDI.

The most important thing first

If everything you try just doesn’t want to work, make sure that the applications and libraries you are using are compiled with MIDI support built-in! Nothing is more frustrating than debugging for hours just to find out that the packager didn’t care about MIDI support when creating the package. Yes, that happened to me several times, so if in doubt, do yourself a favor and compile the relevant parts yourself just to make sure.

Allegro 4

Allegro is a cross-platform library for creating multimedia applications, including games. Up to version 4 it also included MIDI support.

On Linux the following MIDI drivers are supported:

MIDI_OSS - Open Sound System
MIDI_DIGMID - sample-based software wavetable player
MIDI_ALSA - ALSA RawMIDI driver

I never tested OSS MIDI setup.
Allegro’s ALSA driver unfortunately only supports raw MIDI devices (which could be emulated by TiMidity++ if one wanted).
If you don’t have one set up, the autodetection will use the DIGMID software emulation, and that’s the easiest to set up. It just requires one file with the MIDI instruments in a specific location - otherwise you simply won’t hear anything.

I’ll quote the readme.txt file:

The DIGMID wavetable driver uses standard GUS format .pat files, and you
will need a collection of such instruments before you can use it. This
can either be in the standard GUS format (a set of .pat files and a
default.cfg index), or a patches.dat file as produced by the pat2dat
utility. You can also use pat2dat to convert AWE32 SoundFont banks into
the patches.dat format […].

HOWTO

  • Get a sound bank in “SoundFont 2” or “GUS” format (see link to ArchWiki above for links).
  • If it’s in “SoundFont 2” format: Convert it using pat2dat -o patches.dat /usr/share/soundfonts/CT8MGM.SF2 (I’ve used the SoundFonts included with my ancient SoundBlaster 16 for this).
  • Copy the file(s) to /usr/share/allegro/ (which I’d recommend, then all Allegro based applications will use it) or directly into the application’s directory.

Add comment

Fill out the form below to add your own comments