I want to read the MIDI messages inside one MIDI file. When I tried to open the file with notepad it looks like the following
How to open this in notepad or any other text editor?
Sound Design Stack Exchange is a question and answer site for sound engineers, producers, editors, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI want to read the MIDI messages inside one MIDI file. When I tried to open the file with notepad it looks like the following
How to open this in notepad or any other text editor?
Standard MIDI files are in binary (see the specification), so you cannot open them directly in a text editor.
There are tools to convert between the .mid format and some text format (e.g., mid2asc, midicomp), but it might be a better idea to open the file in a MIDI sequencer.
mid2asc
, which works well indeed. But I notice that with input.mid -> mid2asc -> asc2mid -> output.mid
, the output.mid
is not exactly the same as input.mid
. Do you know a non-destructive tool, that allows us to modify just a few MIDI events, but not touch the rest of the file's bytes @CL.?
I know I'm a bit late to the game, but a text editor I regularly use is sublime text.
What's useful about sublime in this situation is that when it opens a midi file (.mid) it will automatically convert it to hex.
You can also use software like Sekaiju by the Open MIDI Project which views what the data actually means (View -> Show new Event list window). This software looks old, but they've been releasing new versions every year for nearly a decade now, and from my experience it is pretty straight forward.
There is of course other software out there, but I've found that these two have worked really well for me so far.
I know the original question was what text editor could be used, and my answer was sublime, but I find it's also convenient to have software like Sekaiju which decrypts all the information in as simple a way possible so you don't need to flip between raw midi and midi code sheets.
Here's what you're looking for. Here are two good ways to do this. Even though these were written years ago, they're good & work well with all versions of Windows including 10. They convert both ways- from midi to txt and from txt to midi. So you can edit the txt as you wish, convert, & then play it. Actually, the one converts to/from a csv file that you can open and edit it in Excel. Cool. The downloads are compressed as tar and gz files so you'll need a program like 7-Zip. The source files are included, but all you need are the exe program files. These must be run from the command prompt, but the basic command is very easy. Example: "mf2t.exe -v midifilename.mid txtfilename.txt" converts the mid file to the txt file. The mf2t program and/or a slightly later version mf2tXP can be downloaded from www.midiox.com. The mf2csv can be downloaded from http://www.fourmilab.ch/webtools/midicsv/. Have fun.
abcmidi
This option has the advantage of using ABC notation which is a well known existing text format with a standard at: http://abcnotation.com/wiki/abc:standard:v2.1
Example using: https://en.wikipedia.org/wiki/File:Bass_sample.mid
sudo apt install abcmidi
wget https://upload.wikimedia.org/wikipedia/commons/a/a0/Bass_sample.mid
midi2abc Bass_sample.mid > Bass_sample.abc
Now Bass_sample.abc
contains:
X: 1
T: from Bass_sample.mid
M: 4/4
L: 1/8
Q:1/4=120
% Last note suggests minor mode tune
K:C % 0 sharps
V:1
%%MIDI program 33
A,,z2C, D,E,/2z3/2A,,-| \
A,,2 G,,2 A,,z3| \
A,,/2z2z/2C,/2z/2 D,E, zA,,-| \
A,,2 C,2 A,,
so let's edit the very first note by changing:
A,,z2C, D,E,/2z3/2A,,-| \
to:
B,,z2C, D,E,/2z3/2A,,-| \
And now we regenerate a MIDI file with:
abc2midi Bass_sample.abc -o Bass_sample_hacked.mid
and when I hear Bass_sample_hacked.mid
, it has been modified as desired.
Using this multitrack MIDI sample: https://en.wikipedia.org/wiki/File:MIDI_sample.mid we see that multitracking is supported, and uses the "Multiple voices" feature: http://abcnotation.com/wiki/abc:standard:v2.1#multiple_voices
However, the midi2abc output format dumps tracks fully one by one instead of say 4 measures of each channel, making it extremely hard to know what corresponds to what on another track.
Tested on Ubuntu 20.04, abcmidi 20200122-1.