Hi. I have created a valuebox that returns a value within the following range: **-12 to +12**

Through the midi_mapping of the vaulebox I have done the following:

rnt:add_midi_mapping { name = "Tools:PhraseTouch:Panel_1:Transpose:Transpose Valuebox", invoke = function( message ) if message:is_abs_value() then vws["PHT_VAL_TRANS_1"].value = math.min( 12, math.max( message.int_value - 12, -12 ) ) end end }

**math.min( 12, math.max( message.int_value - 12, -12 ) )** return returns the correct range, which is exactly this:

-12, -11 ... -2, -1, 00, 01, 02 ... +11, +12

The problem is that I can not return the correct range to fit the range of a rotating wheel, which is from 0 to 127. "0 to 127" corresponds to the value of "message.int_value".

Ok, I have tried to do the following:

**math.min( 12, math.max( (message.int_value/(128/25) -12 ), -12 ) )**

rnt:add_midi_mapping { name = "Tools:PhraseTouch:Panel_1:Transpose:Transpose Valuebox", invoke = function( message ) if message:is_abs_value() then vws["PHT_VAL_TRANS_1"].value = math.min( 12, math.max( message.int_value/(128/25) - 12, -12 ) ) end end }

...but this returns the next range:

-12, -11 ... -2, -1, -0, 00, 01, 02 ... +11, +12

The operation also returns a "**-0**" a value that should not be. If you change the divisor to any other number, there always appears a 0 that should not be, -0 or +0, but should only return a "0" (neither negative nor positive).

Is there a different way to achieve this correctly? The intention is that the rotating wheel turns completely (**-12** left, **0** up center, **+12** right).

To be exact, this is the complete range that I want to return:

-12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12

__ Note__: I also use

**tostring**and

**tonumber**to adjust the values of the

**valuebox**. But the problem is in the

**message.int_value**of the

**midi_mapping**

**Edited by Raul (ulneiz), 04 February 2018 - 16:50.**