I'm trying to write some functions to read in a MIDI file. I've been referring to a number of sites that give the specification, but mostly this one: http://www.sonicspot.com/guide/midifiles.html (archive)
I have been testing it on a MIDI file for the Super Mario Bros theme that I downloaded, and I'm getting some unexpected data. It may be that the file is wrongly formatted, but I think it's more likely that I'm doing something wrong. Here is the data (from a hex editor) that I'm having trouble with, and what I think I know about it:
4D 54 72 6B 00 00 00 19 00 FF 51 03 05 7B 71 00 FF 58
|---------| |---------| || || || |------| || ||
MTrk Chunk size || || || Tempo || ||
(25 bytes) || || ||(ms per || ||
\/ || ||1/4 note) || ||
VLen value || || \/ ||
(Event at time 0)|| || VLen value ||
\/ || (event at ||
Beginning of || time 113) ||
meta-event || ||
\/ \/
Meta-event type: ????
set tempo
As you can see, if everything before the 0x00
is correct, then what is it doing there? The VLen value before has a binary value of 01110001
and so isn't expecting another part of the VLen value, and therefore, AFAIK, should be an event type. However there is no event type associated with 0x0
. Can anyone see where I'm going wrong?