Go to Home Page Go Back to previous page Go to bottom of page Go Forwards to next page
Go to Home Page Go Back to previous page Go to top of page Go Forwards to next page

In the real world, we work with numbers based on ten, because we have ten digits on our hands. A computer works with numbers based on two. The reason for this is that it is easy to represent two states, using a voltage which is either on or off. Off is called ‘Logic Zero’ and On is called ‘Logic One’.

This ‘Base 2’ numbering system is called ‘Binary’. The smallest digit is the ‘Binary Digit’ or ‘Bit’.

Back in the real world, we still need our decimal numbers, so by grouping bits together, it is possible to persuade computers to work in decimal. Each bit added to the group multiplies the the number of combinations possible by a factor of two. When eight bits are grouped, this is referred to as a ‘Byte’ (four bits is called a ‘Nibble’-yes, seriously!).

To calculate how many combinations are possible in binary, raise 2 to the power of the number of bits, or: 2 times 2 times 2 times 2..... Repeated for the number of bits required. ‘To the power of’ may be written using the ‘caret’ symbol “^”, e.g. 2^3 = 2x2x2 (=8).

To put what I have just said into words, a byte has eight bits, so that gives: 2^8; This gives a result of 256 combinations. Try it on a calculator: 2x2x2x2x2x2x2x2 = 256. A nibble (4 bits) = 16.

So where is all this leading? Well, in MIDI, music is represented in this numeric form, so it is useful to know how the information is stored.

The following animated table shows the bits in a byte. The right hand bit is called the ‘Least Significant Bit’ or ‘LSB’ and the left bit is called the ‘Most Significant Bit’ or ‘MSB’. The diagram also shows the decimal ‘weight’ of each bit, used to calculate the equivalent decimal number. This table could be extended if you required more bits. All that you need to do is double the previous bit weight, i.e. from 128, the next bits would be: 256, 512, 1024, etc.
The table updates every 15 seconds. Extra information will appear, if you hold the mouse over sections of the table (moving the mouse slightly will display the message longer).

In the table, a byte is shown in three forms. Binary, Hexadecimal and Decimal.

There are two basic methods of calculating the decimal value. In binary, take the decimal ‘weight’ above the bit and add it to the total if the bit=‘1’. So if the binary code was
00101000 this would show that there was a ‘1’ in the ‘32’ and ‘8’ columns. This gives: 32+8=40.

The second method is to use ‘Hexadecimal’ (meaning six and ten), or ‘Hex’ as it is called. This is a numbering system based on four bits=2^4=16 combinations per digit. The byte is shown divided into two hexadecimal digits.

Each hex digit (and its decimal value) is shown in the table to the left. Use the table to see if you can follow the code as it changes in the diagram above. Note that the hex digits have an ‘h’ appended, to distinguish them from decimal.

You can use hexadecimal to calculate the decimal as follows:

Multiply the ‘Most significant digit’ (or MSD) by 16 and add the “Least Significant Digit” (LSD).

For example, if the hex was: A9h (10101001), use the table to look up ‘A’ (=10) and ‘9’ (=9). Multiply 10 (MSD) by 16 = 160 and add 9 (LSD) = 169. This is usually a quicker way of calculating the decimal value.

Note the “h” after the hex digits. This is to avoid confusion with decimal numbers. For example decimal 42 is not the same as hex 42. 42h=66 decimal (4x16 + 2 =66).

BIN DEC HEX
0000 0 0h
0001 1 1h
0010 2 2h
0011 3 3h
0100 4 4h
0101 5 5h
0110 6 6h
0111 7 7h
1000 8 8h
1001 9 9h
1010 10 Ah
1011 11 Bh
1100 12 Ch
1101 13 Dh
1110 14 Eh
1111 15 Fh
Back Up Forward

Computer Basics

Q: Hang on a minute, you said that hexadecimal meant six and ten, the last hex digit (‘F’) is only 15?

A: Don’t forget to count the number zero. If you count the rows in the table, you will find that there are indeed sixteen digits!

This also applies to binary , ‘00000000’ is the first number. So, for example, seven bits = 128 combinations, but is numbered 0 to 127 (‘0000000’ to ‘1111111’). The highest number is: 2^N -1, where N=The number of bits.

Having only 256 numbers to play with may seem a little boring, but when you realize that most computers operate with a 32 bit operating system (2^32:
see if you can work that one out! *), then numbers become more realistic. Even then, real world numbers require higher precision than 32 bits, so computers have to manipulate more bits until the accuracy is high enough.

Sorry to ramble on about all those bits, but if you want to understand how MIDI works, then it’s pretty vital stuff!

(* 2^32 = 4294,967,296)

Hex Lookup Table

Binary/Hexadecimal/Decimal Table
Decimal Weight: 128 64 32 16 8 4 2 1
8 Bit Binary Code ('Byte'): 0 0 0 0 0 0 0 0
Hex Value (Dec): 0 (0) 0 (0)
Hex to Dec Calculation: 0 (0) 0 (0)
Total Decimal Value (Hex): 0 (00h)