The MIDI protocol which transfers musical information between keyboards and synthesizers, etc. is described here.
You should become familiar with hexadecimal numbers to understand better the organization of the MIDI protocol. Here is a basic review:
The symbol 165 is a shorthand representation of a particular number. More specifically, 165 can be represented by:
165 = 1 x 10^{2} + 6 x 10^{1} + 5 x 10^{0}I will write 165_{10} to mean the number 165 in base10 representation.
Using other number bases other than base10 is an equally valid way to represent the number 165_{10}. Computers work well with binary numbers, so let's convert 165 to binary form:
165_{10} = 1 x 2^{7} + 0 x 2^{6} + 1 x 2^{5} + 0 x 2^{4} + 0 x 2^{3} + 1 x 2^{2} + 0 x 2^{1} + 1 x 2^{0} = 10100101_{2}
Hexadecimal numbers are a base16 representation of numbers and are useful for humans when dealing with binary numbers. Every 4 binary digits can be repesented by one hexadecimal digit. Below is a table of equivalence between decimal, hexadecimal, and binary number representations for the numbers between 0 and 15:

Using the above table, you should quickly be able to convert the number 10100101_{2} to hexadecimal by grouping every four binary digits into a group and looking up the hex equivalent in the table.
10100101_{2} ==> 1010 0101 ==> A 5 ==> A5_{16}
Since hexadecimal numbers contain digits for 10 through 15, it is standard practice to use the letters of the alphabet to reresent those digits, starting at A = 10.
In base36, you would use all letters of the alphabet to represent all of the possible digits. Try to convert base36 words to base10, e.g.:
the_{36} = t x 36^{2} + h x 36^{1} + e x 36^{0} = 29 x 36^{2} + 17 x 36^{1} + 14 x 36^{0} = 37584 + 612 + 14 = 38210_{10}
Hexadecimal numbers are often written with an h following them to distinguish them from decimal numbers, e.g.: A5h indicates that A5 is a hexadecimal number. There is no confustion in this case, but you would need to know if 42 is in base10 or in base16 since it is an entirely different number in each base and you can't tell which base it is by looking at it out of context.
In the C programming language, hexadecimal numbers are indicated by prepending the string "0x" in front of the number, e.g.: 0xA5 which would be the same as A5h. I will use the 0x notation later on this page.

Note that a byte is a binary number that contains 8 digits. Looking at the binary range above you should be able to see that the range from 00000000 to 11111111 will cover all possible combinations of digits in a byte.
MIDI commands and data are distinguished according to the most significant bit of the byte. If there is a zero in the top bit, then the byte is a data byte, and if there is a one in the top bit, then the byte is a command byte. Here is how they are separated:

Furthermore, command bytes are split into half. The most significant half contains the actual MIDI command, and the second half contains the MIDI channel for which the command is for. For example, 0x91 is the noteon command for the second MIDI channel. the 9 digit is the actual command for noteon and the digit 1 specifies the second channel (the first channel being 0). The 0xF0 set of commands do not follow this convention.
Here is a table of the MIDI commands:

The messages from 0x80 to 0xEF are called Channel Messages because the second four bits of the command specify which channel the message affects. The messages from 0xF0 to 0xFF are called System Messages; they do not affect any particular channel.
A MIDI command plus its MIDI data parameters to be called a MIDI message . The minimum size of a MIDI message is 1 byte (one command byte and no parameter bytes). The maximum size of a MIDI message (note considering 0xF0 commands) is three bytes. A MIDI message always starts with a command byte. Here is a table of the MIDI messages that are possible in the MIDI protocol:
Command  Meaning  # parameters  param 1  param 2 

0x80  Noteoff  2  key  velocity 
0x90  Noteon  2  key  veolcity 
0xA0  Aftertouch  2  key  touch 
0xB0  Continuous controller  2  controller #  controller value 
0xC0  Patch change  2  instrument #  
0xD0  Channel Pressure  1  pressure  
0xE0  Pitch bend  2  lsb (7 bits)  msb (7 bits) 
0xF0  (nonmusical commands) 
I won't discuss the 0xF0 set of commands (System messages) here very much, but here is a basic table of them:
command  meaning  # param 

0xF0  start of system exclusive message  variable 
0xF1  MIDI Time Code Quarter Frame (Sys Common)  
0xF2  Song Position Pointer (Sys Common)  
0xF3  Song Select (Sys Common)  
0xF4  ???  
0xF5  ???  
0xF6  Tune Request (Sys Common)  
0xF7  end of system exclusive message  0 
0xF8  Timing Clock (Sys Realtime)  
0xFA  Start (Sys Realtime)  
0xFB  Continue (Sys Realtime)  
0xFC  Stop (Sys Realtime)  
0xFD  ???  
0xFE  Active Sensing (Sys Realtime)  
0xFF  System Reset (Sys Realtime) 
Running status should be mentioned around here...