Here's the format of a midi channel voice message (based on the MIDI Summary of MIDI messages) for "Note Off" and "Note On" events:
status_byte + key_data_byte + velocity_data_byte
e.g.:
10010100 00111100 01111111
---
"status byte":
The status byte is composed of 2 four-bit parts (or nibbles). The first nibble specifies the function/type of message ("note on", "note off", etc).
The
second nibble specifies the midi channel. midi channel values are
between 1-16, so to provide the correct number you give a binary value that is
1 less than the midi channel number, e.g. a binary value of 0100 (decimal value 4) means midi
channel #5.
e.g.:
10010100
1001 is the "note on" function.
0100 is midi channel #5, i.e. (2*2)+1.
---
"key data byte" is the binary representation of the midi key number value, expressed generally as 0kkkkkkk.
e.g.:
00111100
is midi note #60 ("counting" from right to left):
0 + 0 + (2*2) + (2*2*2) + (2*2*2*2) + (2*2*2*2*2) + 0 + 0
0+0+4+8+16+32+0+0==60
---
"velocity data byte" is the binary representation of the midi velocity number value, expressed generally as 0vvvvvvv.
e.g.:
01111111
is midi velocity 127--the loudest possible velocity ("counting" from right to left):
(2 to the zero power == 1) + (2 to the 1th power == 2) + (2*2) + (2*2*2) + (2*2*2*2) + (2*2*2*2*2) + (2*2*2*2*2*2) + 0
1+2+4+8+16+32+64==127
---
Additional reading:
why any number raised to the zero power is 1
binary numbers and arithmetic
No comments:
Post a Comment