A brief introduction to the MIDI specification

MIDI is a specification that allows digital musical equipment to communicate. MIDI messages consist of a status byte followed optionally by additional data bytes. Status bytes always begin with 0, and data bytes always begin with 1, leaving each data byte seven remaining bits, or 2= 128 different values to describe its data.

For the NOTE ON message, this consists of three bytes. The first byte indicates that it is a NOTE ON together with a channel (which can be used to differentiate between different instruments); the second byte is the pitch (specifying the musical note); and the third byte is the velocity (specifying how loud the musical note should be played). Out of the eight bits in the byte encoding the pitch of a note, the first bit is always a 0. You can read more at https://www.midi.org/specifications-old/item/table-1-summary-of-midi-message.