XMI File Format
(Incomplete - Under Construction)

Document version 1
Authored by Chris Ison chrisisonwildcode@gmail.com

Last Edited 24 May 2014

Copyright (C) 2014 WildMidi Developers
This document is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-sa/4.0/


Introduction

This document describes the XMI format as used by the WildMIDI project.
It is not a complete description of the XMI file format and only those
parts that have been decyphered and are relevant to the WildMidi project
are described here. Unfortunately we cannot answer questions about the
format that are not described within this document.  If you feel there
is an error in this document please feel free to report it as a bug at
https://github.com/Mindwerks/wildmidi/issues/


Description

// FORM DATA
{
    uint8_t text[4] = "FORM";
    uint32_t size_of_data_before_chunks;
    uint8_t text[8] = "XDIRINFO";
    uint8_t unknown[4] = { 0x00, 0x00, 0x00, 0x02 };
    uint8_t form_count;
    uint8_t unknown_data[size_of_data_before_chunks - 13]

    uint8_t text[4] = "CAT ";
    uint32_t size_of_CAT;

    uint8_t text[4] = "XMID";

    {
        // XMID Chunks
        uint8_t text[4] = "FORM";
        uint32_t size_of_form;
        uint8_t text[4] = "XMID";

        {
            {
                uint8_t text[4] = "TIMB";
                uint32_t TIMB_size;
                uint8_t TIMB_data[TIMB_size] = { 8bit patch, 8bit bank, ... }
            }
            // OR
            {
                uint8_t text[4] = "RBRN"
                uint32_t RBRN_size;
                uint8_t unknown[RBRN_size];
            }
            // OR
            {
                uint8_t text[4] = "EVNT"
                uint32_t EVNT_size;
                uint8_t MIDI_data[EVNT_size] {
                // All events and delta values stored as with standard MIDI,
                // EXCEPT for there is no "Note Off" and "Note On" extra data
                //      after the velocity that states the length of the note
                //      in delta ticks stored in MIDI variable length format.

                // ALSO NOTE that only the first TEMPO event is used,
                //      all others are ignored.

                // Example Note on may be stored like
                // uint8_t event_data[] = { 0x90, 0x24, 0x64, 0xA3 }
                // uint8_t delta_ticks[] = { 0xA3 }
                // uint8_t event_data[] = { 0x90, 0x48, 0x64, 0x23, 0xA3 }

                // See the MIDI file format for more information

                ...
                }
            }
            ...
        }
    }
}
