Adding MSB and LSB to get 0-511

152 views Asked by At

I'm trying to get 9 bits out of a MIDI controller. According to the manual, the position of a fader on the MIDI controller is sent out as 9 bits, which would make it 0-511.

In my software (Max/MSP), the MSB comes in as only 7 bits (0-127) and the LSB flickers between 0/64 generally and occasionally I see 32 and 96.

I think I need to do some bit shifting and then add the MSB and LSB somehow to get the full 0-511.

Any ideas?

from the manual:

MSB=0 M M M M M M M
LSB=0 L L 0 0 0 0 0

The position is sent out with 9 bits of accuracy. The 2 least significant bits can be ignored for 7-bit accuracy.
1

There are 1 answers

2
Brad On

MIDI data values can only use 7 bits, so it's spread the most significant 7 to that first CC data byte, and the last couple bits to the next CC data byte.

If you convert the least significant bits, possible values are 0, 32, 64, and 96 as you have seen. But of course, those aren't meant to be taken out of context.

Assemble your bits like this:

0000 000M MMMM MMLL