Up

MIDI to TEXT

TEXT to MIDI

Overview

MidiToText decompiles MIDI files into an editable ASCII text format. TextToMidi recompiles the text files back into MIDI files. The syntax follows the standard set by DOS utilities MF2T and T2MF.

Applications

Download

Current version 1.05, 22 August 2010. MidiToText.zip

Operation

Drop the MIDI file into the MidiToText window to produce a text file of the same name (apart from the .txt extension). Alternatively, use the Modify filename option to create a text file of the form * (M2T).txt, to ensure that the recompiled MIDI file does not overwrite the original. To recompile, drop the MIDI Text file into the TextToMidi window.

MIDI Text Format

For more information on the MIDI (SMF) file format  see http://www.somascape.org/midi/tech/mfile.html

File StructureMIDI TextMIDI Coding
File headerMFile format ntrks division    (or ...)
MFile format ntrks -timecode resolution
"MThd" 00 00 00 06 xxxx xxxx xxxx
Start of trackMTrk"MTrk" nn nn nn nn xx ...
End of trackTrkEnd
MIDI EventsMIDI TextMIDI Coding
Note Offclock Off ch=chan n=note v=velxx ... 8x xx xx
Note Onclock On ch=chan n=note v=velxx ... 9x xx xx
Polyphonic Pressureclock PoPr ch=chan n=note v=valxx ... Ax xx xx
Controllerclock Par ch=chan c=con v=valxx ... Bx xx xx
Program Changeclock PrCh ch=chan p=progxx ... Cx xx
Channel Pressureclock ChPr ch=chan v=valxx ... Dx xx
Pitch Bendclock Pb ch=chan v=pitchxx ... Ex xx xx
SysEx messageclock SysEx1 F0 hexxx ... F0 nn xx ...
SysEx continuationclock SysEx1 hexxx ... F7 nn xx ...
Escape sequenceclock Arb2 hexxx ... F7 nn xx ...
Sequence Numberclock SeqNr numxx ... FF 00 02 xx xx
Textclock Meta3 Text stringxx ... FF 01 nn "abcd..."
Copyrightclock Meta3 Copyright stringxx ... FF 02 nn "abcd..."
Sequence Nameclock Meta3 SeqName4 stringxx ... FF 03 nn "abcd..."
Track Nameclock Meta3 TrkName4 stringxx ... FF 03 nn "abcd..."
Instrument Nameclock Meta3 InstrName stringxx ... FF 04 nn "abcd..."
Lyricclock Meta3 Lyric stringxx ... FF 05 nn "abcd..."
Markerclock Meta3 Marker stringxx ... FF 06 nn "abcd..."
Cue Pointclock Meta3 Cue stringxx ... FF 07 nn "abcd..."
Other text eventsclock Meta type stringxx ... FF xx nn "abcd..."
End of trackclock Meta3 TrkEndxx ... FF 2F 00
Tempoclock Tempo tempoxx ... FF 51 03 xx xx xx
SMPTE Offsetclock SMPTE num num num num numxx ... FF 54 05 xx xx xx xx xx
Time Signatureclock TimeSig num/num num numxx ... FF 58 04 xx xx xx xx
Key Signatureclock KeySig keysig manorxx ... FF 59 02 xx xx
Sequencer Specificclock SeqSpec hexxx ... FF 7F nn xx ...
Other Meta eventsclock Meta type hexxx ... FF xx nn xx ...

Parameters

formatMIDI File Type: 0=single track; 1=multiple composite tracks; 2=multiple independent tracks (rarely found).
ntrksNumber of tracks (MTrk/TrkEnd pairs) in the file
divisionMIDI division; MIDI clock ticks per quarter note
timecodeSMPTE timecode, frames per second (expressed as a negative number)
resolutionSMPTE timecode, sub-frame resolution
clockAccumulated MIDI clock ticks from the start of the track (MIDI encodes the incremental value). Optionally, the clock may be displayed in Bar:Beat:Tick format.
chanChannel (1-16)
noteNote Value (0-127). Alternatively Scientific pitch notation (for example C#4 or Db4) may be used
velNote Velocity (0-127)
valValue (0-127)
numNumber (miscellaneous)
conController (0-127)
progInstrument (0-127)
keysigNumber between -7 and +7, representing the number of flats (-ve) or sharps (+ve) in the key signature
manorminor or major
pitchPitch bend. A 14-bit integer centred about its midpoint, 8192 (2000 hex)
tempoTempo. A 24-bit integer indicating the number of microseconds per quarter note. Handling the tempo in its native form ensures that it may be recompiled with no loss of precision. The conventional Quarter Notes Per Minute value (equivalent to Beats Per Minute with x/4 time signatures) is obtained by dividing 60,000,000 by the tempo. TextToMidi also accepts conventional Quarter Notes Per Minute values (any integer less than 900).
typeA hex number of the form 0xab
hexA sequence of 2-digit hex numbers (without 0x) separated by spaces
stringA string between double quotes (like "text"). Quotes within the text are escaped as \"; the \ itself is escaped as \\, CR as \r, LF as \l, TAB as \t, null as \0. Other non-printable characters are represented as \xXX, where XX is two hex digits.

Footnotes

1SysExSystem Exclusive messages start with an F0 and terminate with an F7 data byte. They are stored as F0 events with the status byte also representing the first data byte. SysEx messages may occasionally be spread across multiple events. The initial SysEx (F0) message is then left unterminated and the remainder of the message is sent as a series of SysEx Continuation (F7) events with the last one terminated with an F7 data byte. In this case the F7 status byte does not form part of the message, whereas the terminating F7 data byte does.

2ArbAn F7 event can also be used in an entirely different context for sending Arbitrary escape sequences. To distinguish between the two cases: if a previous SysEx event remains unterminated, the F7 status indicates a continuation of it, otherwise it indicates an escape sequence.

3MetaMidi2Text follows the standard set by MF2T, although its use of the "Meta" prefix with some Meta events and not others is inconsistent.
Text2Midi makes the "Meta" prefix optional wherever the meaning remains clear without it.

4SeqNam TrkNamThe Sequence Name (Song Title) and Track Name are both Meta Text type 3 events with the context determining its meaning. In the first track, a Meta Text type 3 event is interpreted as being the Sequence Name while in any subsequent tracks it becomes the Track Name.