Knob display value and midi send

Hi,
I this knob which display the sync time division '1/32' '1/16' and so on
But when I change the value to 0 - 127 the time division is no more correctly display.

var division = ["8/1", "4/1", "2/1", "1/1", "1/2","1/4","1/8","1/16","1/32","1/64"]

set("speedsync_mon_1", division[value])

I tried fews solutions but nothing works fine.
Best

Button_Sync.json (5.2 KB)

By writing division[value] you’re raising multiple issues:

  • value is between 0 and 127 while the array (division) has only 10 elements (indices 0 to 9). Solution: divide value by 127 and multiply it by 9
  • value may not be an integer (eg 1.5) while array indices must be integers. Solution: round the value

So I tried something like :

var division = [“8/1”, “4/1”, “2/1”, “1/1”, “1/2”,“1/4”,“1/8”,“1/16”,“1/32”,“1/64”]

set(“speedsync_mon_1”, division[math.round(value/127*9)])

but it sends value and not the division.

Is there a reason to set the range to 0-127 insead of 0-9 if you don’t want to send a 0-127 value ? Anyway, if you want to send a different value from that range you have to call send()

EDIT: I get it, by “send” you mean updating the text widget, nevermind.

I don’t understand why but I deleted math.round and it works ?!

I'm working with prehistorical midi :confused:

Math takes a capital M.

:sweat_smile: