11

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

enter image description here

How to open this in notepad or any other text editor?

2
  • Your opening is right but take a look a midi file specifications this might help you ccarh.org/courses/253/handout/smf
    – JSmith
    Jul 29, 2016 at 8:21
  • Your seeing the ANSI representation of the binary data when you open it in notepad. That's right, I'm multi-talented... ;)
    – n00dles
    Aug 5, 2016 at 1:45

4 Answers 4

11

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.

3
  • 2
    I just tried 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.?
    – Basj
    Jan 23, 2021 at 15:44
  • @Basj There are multiple possible ways to encode the same events. This is most likely not a problem.
    – CL.
    Jan 23, 2021 at 21:28
  • 1
    Yes @CL., but I sometimes have .mid files with Sysex data, etc. so if for example I need to modify 1 MIDI event (let's say a NoteOn or NoteOff event), I would prefer the other bytes to be untouched.
    – Basj
    Jan 23, 2021 at 22:15
6

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.

0

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.

1
  • This describes how to open and edit them, but it doesn't answer the question.
    – Rory Alsop
    Dec 18, 2017 at 8:26
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.