1

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.
JohnH
  • 2,713
  • 12
  • 21

1 Answers1

1

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
Brad
  • 159,648
  • 54
  • 349
  • 530
  • Thanks for the reply. Can you please clarify what you mean by "assemble my bits"? The data is coming into Max/MSP as numbers ie: 176 32 0. Do I need to convert it to binary or something? – user2313418 Feb 27 '21 at 21:18
  • @user2313418 I'm not sure how to do it in Max, but essentially you need to bit-shift your MSB value two positions to the left (i.e. multiply it by `4`), bit-shift your LSB value five positions to the right (i.e. divide it by `32`), and then add those values together. – Brad Feb 27 '21 at 23:19