Re: Delphi MIDI Programming, nibble
[ DelphiLand Discussion Forum ]
Posted by webmaster Guido on March 25, 2003 at 02:22:00:
In Reply to: MIDI Programming posted by Kevin + Mullzo on March 24, 19103 at 14:45:36:
: I am writing a program for my current university course : and need help. I am developing a midi thru program which responds to incoming messages and records values in edit boxes, spin edits and scrollbars. I have everything completed ie Pitch Bend messages, velocity messages and Midi I/O controls, the one thing can't figure out is how to record incoming channel changes : as the channel change message is on the second nibble of the status byte and I don't know how to isolate it. : Please help!!! -----------------
In the examples below, the dollar-sign prefix indicates hexadecimal notation.
You can logically AND a byte with a mask-byte that contains zero's at the positions that you are not interested in. As you know, bytes are from $00 (0 in decimal, 00000000 in binary) to $FF (255 decimal, 11111111 binary).
So if you AND with $0F, you obtain the four lowest bits (low nibble), while AND-ing
with $F0 isolates the four highest bits (high nibble). Examples of Delphi functions to
return high- and low order "nibbles":
function LowNibble(B: byte): byte;
begin
Result := B AND $0F;
end;
function HighNibble(B: byte): byte;
begin
Result := B AND $F0;
end;
Regards,
webmaster Guido
Related Articles and Replies:
[ DelphiLand Discussion Forum ]
|