Convert MIDI files to CSV text files and vice versa
Source : John Walker (site fourmilab)
The MIDI file format is perfect for what it was designed for, but it is not very open.
It is recorded in binary format and its complex format requires specialized libraries for reading and writing, not common in commercial tools.
The advantage of exporting functions to the CSV text format is to open the MIDI format to tools that manipulate text.
Then simply re-import the result of these processing in MIDI format with the inverse import function.
Export
Karaboss has an export function that allows you to convert a MIDI file into a CSV text file, keeping all the information contained in the original MIDI file.
How?
From the Explorer, select a Midi file and open it in the player (Edit or Play/Stop)
Click on the menu “File” > “Export Midi file to TEXT”
The MIDI file will be then exported to a text file named “FileName (Dump) .txt” located in the same directory as your original MIDI file, and will be displayed in your default text editor (notepad, notepad ++ etc …)
Import
In the same way, Karaboss has an import function allowing you to convert a CSV text file into MIDI format.
How?
From the MIDI Player, click on the menu “File”> “Import Midi file from TEXT”.
Select a file in compatible format.
The file will then be converted to in the MIDI format and displayed in your editor.
Note:
In principle, exporting and re-importing a file should produce a result equivalent to the original MIDI file.
The import and export functions of Karaboss are not yet fully finalized and do not take into account all MIDI events.
The standard used
Simple export example:
0, 0, Header, 1, 2, 480 1, 0, Start_track 1, 0, Title_t, "Close Encounters" 1, 0, Text_t, "Sample for MIDIcsv Distribution" 1, 0, Copyright_t, "This file is in the public domain" 1, 0, Time_signature, 4, 2, 24, 8 1, 0, Tempo, 500000 1, 0, End_track 2, 0, Start_track 2, 0, Instrument_name_t, "Church Organ" 2, 0, Program_c, 1, 19 2, 0, Note_on_c, 1, 79, 81 2, 960, Note_off_c, 1, 79, 0 2, 960, Note_on_c, 1, 81, 81 2, 1920, Note_off_c, 1, 81, 0 2, 1920, Note_on_c, 1, 77, 81 2, 2880, Note_off_c, 1, 77, 0 2, 2880, Note_on_c, 1, 65, 81 2, 3840, Note_off_c, 1, 65, 0 2, 3840, Note_on_c, 1, 72, 81 2, 4800, Note_off_c, 1, 72, 0 2, 4800, End_track 0, 0, End_of_file