MIDI controllers and virtual instruments define any action on keyboard keys with three pieces of information:
- Was this a key press, or a key release? (Note on, or Note off?)
- What note was it? (using a note number)
- How hard did you press that key? (this is called velocity)
The note and velocity are summarized with numbers between 0 and 127. (Having 2^7 possibilities is great for binary!)
Middle C is always note number 60, C#4 is 61, D4 is 62, etc. The hardest key press you can do comes in at velocity 127, the softest is 1, and a key release is 0.
Of course, MIDI does stand for musical instrument DIGITAL interface, so at the circuit/computer level, these values will be sent in the form of binary numbers. It might look like the following:
To translate all this to human speak, when you press down the key for middle C as hard as possible, your MIDI Controller says:
STATUS BYTE: Here comes a note on, from channel 0! (of course, computers start counting from 0)
DATA BYTE 1: The note is 60!
DATA BYTE 2: The velocity is 127!
This happens literally lightning fast! Whenever you press or let go of a key on a midi keyboard, your midi controller is sending this summary of what just happened to your computer or synth. Of course, MIDI is digital, so behind the scenes, everything is going to be broken down into binary.