Value different of range

Hey
on a knob, I wanted to display value for example : 0 to 100% or -12st to +12st
but need to send midi cc 0 to 127 is it possible ?
Best
Z

Hi, since you’re using a text widget to display the value, you can apply any mathematical conversion to it without changing the knob’s actual range:

JS{{
// text.value
var val = @{knob_id}
return Math.round(val / 127 * 100)+ '%'
// or
// return Math.round(val / 127 * 24 - 12)+ 'st'
}}
1 Like

I tried to get a value from 0.5 to 2.5, so which to divide val by ((127200+25)/100)
but it seems to do not accept this so I tried an other possibility :
JS{{
var val = @{knob_speedfree}
var result = Math.round(val / 127
200+50)+‘x’
var result2 = result/100
return result2
}}

But same problem :confused:
is it a problem between math.round and decimal ?
best

To convert a value from range 0-127 to 0.5-2.5 the formula is

var result = val / 127 * 2 + 0.5
2 Likes

Thank you !
ok I added this part of the code to limit to 2 decimal :

var result = (val / 127 * 2 + 0.5)
result = result.toFixed(2);
return result