Retrieving and displaying knob values in a text box?

Apologies, as I'm just learning how to use OSC.

I'm trying to create a script that, as a knob is being manipulated, the value (as a range from 0-127) is shown in a text box.

For example, say I have a knob with the following properties:

range: { "min": 0, "max": 127 }
value: VAR{val}
default: 100

and the following (simplified) script attached to it:

console.log("Knob value is: " + getVar('knobID', 'val'));

All I get is:

Knob value is: 100
Knob value is: 100
Knob value is: 100
...
...

I've also tried:

send('127.0.0.1:7002', "/textBox", getVar('knobID', 'val'));

Yet I get the same thing. What am I doing wrong?

Setting the value property to VAR{val} will only change the knob's value depending on the custom variable "val", which can be set using setVal(). This variable doesn't take the knob's value without an explicit instruction.

What you want is simpler: in the knob's script property, the value variable represents its value and can be used directly:

// knob.script
console.log("Knob " + getProp("this", "id") + ": " + value)
set("text_id", value) // pass value to another widget

Alternatively, you could write @{knob_id} in the text widget's value. (no script needed).

2 Likes

Well that was very simple, thanks!