Maybe the part where Message.D2 gets its value, could be done in 1 command, but i haven't figured it out how
Also, this method possibly won't work in all situations, because my initial 16 bit integer contains only max. 14 bit numbers, and D2&D3 should represent that number in two 7 bit parts, the MSB in each byte will be always 0.
This is a soluion for sending pitch bend data over midi, and it is a bit overcomplicated i think, because the Pitch Bend message includes two data bytes to specify the pitch bend value. The two bytes of the pitch bend message form a 14 bit number ( 0 to 16383 ).
EDIT: The part where I give value to Message.D2 possibly could be done like this:
Message.D2=Val & 0x7F;
I found this solution in an already existing MIDI library, but haven't tested it yet.