dmid – MIDI to OPL3 converter using GENMIDI-type instrument banks


dmid [ -2s ] [ -i bank ] [ file ]


Dmid decodes MIDI instructions either from file or from standard input, and produces OPL3 instructions suitable for playback by opl3(1). To program instruments, an OPL2 instrument bank formatted as GENMIDI lumps from doom must be provided. Since it is assumed that the bank is contained in a doom WAD file, its default location is /mnt/wad/genmidi. This may be overridden with the -i command line option.

The -s flag enables streaming mode, in which the input file is a stream of MIDI events. The file needn’t provide any timing information such as MIDI tics. This is suitable for MIDI instruments.

In GENMIDI lumps, two voices are defined per instrument. For compatibility, the -2 flag disables the second voice, reducing the number of OPL channels needed. It also disables OPL3 specific features and produces an IMF-format stream, which can be used in other game engines.


Play a MUS file from a doom WAD file:


% games/wadfs /sys/games/lib/doom/doom2.wad
createfile SW18_7: file already exists
% games/mus /mnt/wad/d_doom | games/dmid | games/opl3 >/dev/audio

Play a MIDI stream from a USB device (see usb(3)):


% games/wadfs /sys/games/lib/doom/doom2.wad >[2]/dev/null
% games/dmid -s /dev/usb/ep10.1/data | games/opl3 >/dev/audio




games(1), mus(1), opl3(1), audio(3), usb(3), wadfs(4)


Dmid first appeared in 9front (July, 2018).