MIDI to TEXT | TEXT to MIDI | |
![]() |
![]() |
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.
Current version 1.05, 22 August 2010. MidiToText.zip
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.
For more information on the MIDI (SMF) file format see http://www.somascape.org/midi/tech/mfile.html
| File Structure | MIDI Text | MIDI Coding |
| File header | MFile format ntrks division (or ...) MFile format ntrks -timecode resolution | "MThd" 00 00 00 06 xxxx xxxx xxxx |
| Start of track | MTrk | "MTrk" nn nn nn nn xx ... |
| End of track | TrkEnd | |
| MIDI Events | MIDI Text | MIDI Coding |
| Note Off | clock Off ch=chan n=note v=vel | xx ... 8x xx xx |
| Note On | clock On ch=chan n=note v=vel | xx ... 9x xx xx |
| Polyphonic Pressure | clock PoPr ch=chan n=note v=val | xx ... Ax xx xx |
| Controller | clock Par ch=chan c=con v=val | xx ... Bx xx xx |
| Program Change | clock PrCh ch=chan p=prog | xx ... Cx xx |
| Channel Pressure | clock ChPr ch=chan v=val | xx ... Dx xx |
| Pitch Bend | clock Pb ch=chan v=pitch | xx ... Ex xx xx |
| SysEx message | clock SysEx1 F0 hex | xx ... F0 nn xx ... |
| SysEx continuation | clock SysEx1 hex | xx ... F7 nn xx ... |
| Escape sequence | clock Arb2 hex | xx ... F7 nn xx ... |
| Sequence Number | clock SeqNr num | xx ... FF 00 02 xx xx |
| Text | clock Meta3 Text string | xx ... FF 01 nn "abcd..." |
| Copyright | clock Meta3 Copyright string | xx ... FF 02 nn "abcd..." |
| Sequence Name | clock Meta3 SeqName4 string | xx ... FF 03 nn "abcd..." |
| Track Name | clock Meta3 TrkName4 string | xx ... FF 03 nn "abcd..." |
| Instrument Name | clock Meta3 InstrName string | xx ... FF 04 nn "abcd..." |
| Lyric | clock Meta3 Lyric string | xx ... FF 05 nn "abcd..." |
| Marker | clock Meta3 Marker string | xx ... FF 06 nn "abcd..." |
Cue Point| clock Meta3 Cue string | xx ... FF 07 nn "abcd..." | |
| Other text events | clock Meta type string | xx ... FF xx nn "abcd..." |
| End of track | clock Meta3 TrkEnd | xx ... FF 2F 00 |
Tempo| clock Tempo tempo | xx ... FF 51 03 xx xx xx | |
| SMPTE Offset | clock SMPTE num num num num num | xx ... FF 54 05 xx xx xx xx xx |
| Time Signature | clock TimeSig num/num num num | xx ... FF 58 04 xx xx xx xx |
| Key Signature | clock KeySig keysig manor | xx ... FF 59 02 xx xx |
| Sequencer Specific | clock SeqSpec hex | xx ... FF 7F nn xx ... |
| Other Meta events | clock Meta type hex | xx ... FF xx nn xx ... |
| format | MIDI File Type: 0=single track; 1=multiple composite tracks; 2=multiple independent tracks (rarely found). |
| ntrks | Number of tracks (MTrk/TrkEnd pairs) in the file |
| division | MIDI division; MIDI clock ticks per quarter note |
| timecode | SMPTE timecode, frames per second (expressed as a negative number) |
| resolution | SMPTE timecode, sub-frame resolution |
| clock | Accumulated 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. |
| chan | Channel (1-16) |
| note | Note Value (0-127). Alternatively Scientific pitch notation (for example C#4 or Db4) may be used |
| vel | Note Velocity (0-127) |
| val | Value (0-127) |
| num | Number (miscellaneous) |
| con | Controller (0-127) |
| prog | Instrument (0-127) |
| keysig | Number between -7 and +7, representing the number of flats (-ve) or sharps (+ve) in the key signature |
| manor | minor or major |
| pitch | Pitch bend. A 14-bit integer centred about its midpoint, 8192 (2000 hex) |
| tempo | Tempo. 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). |
| type | A hex number of the form 0xab |
| hex | A sequence of 2-digit hex numbers (without 0x) separated by spaces |
| string | A 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. |