Search code examples
midifile-format

Synthesia plays well midi file without any note off event?


I have a .mid file - this one specifically. Apart from the header chunk here is the relevant part of the midi. The first track chunk contains only meta events and is described as

4D 54 72 6B 00 00 00 52 // Track chunk #1 info

00 FF 58 04 04 02 18 08 // Meta event

00 FF 59 02 00 00 // Meta event

00 FF 51 03 15 CC 5B // Meta event

81 88 70 FF 51 03 16 E3 60 // Meta event

81 70 FF 51 03 1A 28 6E // Meta event

81 70 FF 51 03 1C 9C 38 // Meta event

81 70 FF 51 03 1E 84 80 // Meta event

81 70 FF 51 03 20 B2 89 // Meta event

81 70 FF 51 03 23 36 6C // Meta event

81 70 FF 51 03 2B 98 B7 // Meta event

00 FF 2F 00 // Meta event. End of track #1

This is the second track chunk, which contains only Note on events:

4D 54 72 6B 00 00 04 02 // Track chunk #2 info

00 FF 21 01 00 // Meta event

00 FF 03 1F 53 69 6E 66 6F 6E 69 
61 20 66 72 6F 6D 20 4B 61 6E 74 61 74 61 20 23 
31 30 36 20 2D 4A 53 20 // Meta event

00 C0 4A // Midi event

00 B0 07 7C // Midi event

00 B0 0A 52 // Midi event

00 B0 5B 4B // Midi event

96 40 90 4B 50 // Midi "Note on" event

81 63 4B 00 // Midi "Note on" event because of running status 

... // No note offs event in this track chunk.

FF 2F 00 // Meta event. End of track #2

This is track #3:

4D 54 72 6B 00 00 03 27 // Track chunk #3 info

... // Some meta and non-note-on, non-note-off midi events

96 40 91 4B 50 // "Note on" event

81 63 4B 00 // Another "Note on" event

... // No note offs

FF 2F 00 // End of track #3

Track chunks #4, #5 and #6 have the same structure as #3; #7 contains two meta events only.

Note that every track chunk which doesn't contain only meta events starts with two Note on events, and no one of them contains a single Note off event.

But this is what synthesia (a midi player) sees when loading the file, just at the start of the song:

Synthesia capture

The structure of this midi would be a Note on event followed by a Note off event in the same track chunk, but this doesn't happen.

What's happening here?


Solution

  • 96 40
          90 4B 50 // Midi "Note on" event
    81 63
             4B 00 // Midi "Note on" event because of running status
                ^^
    

    The MIDI specification says:

    MIDI provides two roughly equivalent means of turning off a note (voice). A note may be turned off either by sending a Note-Off message for the same note number and channel, or by sending a Note-On message for that note and channel with a velocity value of zero. The advantage to using "Note-On at zero velocity" is that it can avoid sending additional status bytes when Running Status is employed.

    Due to this efficiency, sending Note-On messages with velocity values of zero is the most commonly used method.