Pan mode on a rotary encoder

How to program a 0 to 7F
encoder to work so 0=-20 and 7F=+20
and mid position equals 0
The Leds come with the setting in hardware encoded
but the controll section stays standard 0 to 7F
i have been looking for similer topic to get some pointers

Hi Mikael,

Well in MIDI since they there are no negative numbers so negative numbers are generally represented by the high or bit being set.

So 0x7F (or 127 decimal) is -1, 0x7E (126) is -2 and so on. This changes the interpreted positive values as 0-63 and negative values of -1(127 or 0x7F) to -64 (64 or 0x40) .

Now you say you want a value of negative 20 to positive 20. Of course positive 20 is 20 (0x14)
Negative 20 would be 108 (0x6c) .

Now that it itself probably doesn’t help in the conversion process but is just four your information.

Now since MIDI controllers have a range of 128 (0-127) and your desired range is 41 (-20 to +20). We will first need to “scale” it to the desired range. This is done by multiplication and division in MT Pro as follows:. Say the incoming value is captured in local variable “qq”

// desired output range
qq=qq*41
// desired input range
qq=qq/128

That will give us the correct ranging but not the right offset. If qq is greater than 20 we need to convert it so that the high order bit is set:

if qq>20 then rr=128-qq
if qq>20 the qq=qq*-1

It’s early here so I hope I got it right. :wink:

See this tutorial on scaling.

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

Thanks mate for the quick response
i have not been testing much i am on nights
again for one more night then i will test it
more

Yes, things might need a little tweaking based on what your encoder sends and also based on what your application actually expects. It is never clear when they are not talking MIDI. So let me know.

Steve

hi mate
just tried it worked like it should
in bome but in the software
fliped out .
so the reaction is
in normal with out any rules
0 on the rotary is -20
and 127 is 20 soo
how to make the encoder
beleve mid is 0
but puting out standard value

So with no rules, 0 = -20 and 127= +20? Then it should already be at 0 when encoder is at mid position of 64. Is it not?

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

was trying to make it so it woke at mid point and so it wasn’t doing decimal but did not work
but your code worked when i tried it on another piece of software
so i just when’t with the easiest i set a global var to 64 and have the preset call on it when booting up
for example translator
incoming activation of preset rules qq=ja outgoing P0 14 qq to port apc pro
aka back to midi board and ja is my global var
and this is working
i Know you know it Steve
just wrote so if some one is having a brain fart like me dont need to ask

Hi Mikael,

I’m glad you got it working. Take care!

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz