Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:XMIDI

From ReverseEngineering.wiki
Format
Magic FORM at 0, then XDIR (or XMID)
Extensions .xmi, .xmid
Endianness IFF chunk sizes big-endian, INFO/RBRN values little-endian
On this wiki Facts · Code · Notes · Topics

The Miles Design / Audio Interface Library music format (.xmi, also lumps in game archives): an IFF container with an optional FORM XDIR (INFO = track count) followed by CAT XMID holding one FORM XMID per sequence, each with optional TIMB (custom patches), RBRN (branch points) and an EVNT chunk of MIDI-like events where notes carry a duration instead of a note-off.

Overview

XMIDI is the sequence format of the Miles Sound System (Library:Miles Sound System, AIL on DOS) used by many DOS games with Roland MT-32, AdLib and General MIDI drivers. It is a compressed relative of the Format:Standard MIDI File: the events are almost the same, but timing and note length are encoded differently, and extra controllers give loops, callbacks and branches.

Container

See Fact:XMIDI/struct/Container chunks. All IFF chunk lengths are big-endian and chunks are padded to an even size; the track count in INFO is a little-endian u16.

Events

See Fact:XMIDI/behavior/Event encoding. Delta times are the sum of consecutive bytes below 0x80 (not 7-bit groups), Note On is followed by a variable-length duration and there are no Note Off events.

Controllers

ScummVM implements the loop controller 0x74 (FOR loop), 0x75 (NEXT/BREAK), 0x77 (callback trigger) and 0x78 (sequence branch index); 0x6E-0x72 (channel lock, voice and timbre protection, bank change) are ignored, and 0x73-0x76 are reported as unsupported (midiparser_xmidi.cpp lines 197-275). Unverified: the exact semantic of each from the Miles documentation.

Timbres

A TIMB chunk lists custom patches used by a sequence: u16 count, then pairs of patch and bank bytes (from line 446); Miles MT-32 and OPL drivers fetch the actual instrument data from a bank file. Unverified: where that bank file is stored in a given game.

Pitfalls

  • Some files lack the FORM XDIR wrapper and start with FORM....XMID directly; ScummVM warns but accepts them (lines 351-354).
  • ScummVM uses 60 ticks per quarter note and 500000 microseconds per quarter as the initial tempo (lines 510-512).

Code & repositories

ScummVM (GPL-3.0-or-later) audio/midiparser_xmidi.cpp, adapted from the Exult project.

  • https://github.com/scummvm/scummvm @ 3f4203f8833f12615b0df5fa27f19d3c30d3e5d8 · license: GPL-3.0-or-later (declared by the contributor; GitHub's detector did not recognize COPYING)
    ScummVM: audio/midiparser_smf.cpp, audio/midiparser_xmidi.cpp and audio/decoders/voc.cpp parse SMF, XMIDI and Creative VOC data of many DOS and Amiga adventure games.
    Tested on: source read, not run: read only, source files at the pinned commit · checked 2026-10-19