Hello,
I want to send xy values separately to my knobs by filtering them according to the selection of a dropdown widget to control different parts of a synth.
What is the best way to do this? JS, Script?
In the dropdown ? something like :
If dropdown_1 = LFO-Vibrato, send {xy_FM8}[0]} to Vibrato_knob, else if etc..
or in each knob
If dropdown_1 == LFO-Vibrato, receive {xy_FM8}[0]}, else if etc..
Here is a demo: xy_and_knobs.json (8.5 KB)
The xy updates the knobs using its script property and read the dropdown's state to determine which knobs should be affected. The knobs and the dropdown are all linked to a script widget that reads the dropdown's state and merges the selected knobs' values to update the xy.
Thanks @jean-emmanuel , it works great.
As I use 2 differents dropdown for X and Y targets on 11 knobs, I change the script in XY widget like this :
var choice = get('dropdown_1')
if (choice == 1) { set('knob_1', value[0]) } else if (choice == 2) { set('knob_2', value[0]) } //etc..
var choice = get('dropdown_2')
if (choice == 1) { set('knob_1', value[1]) } else if (choice == 2) { set('knob_2', value[1]) } // etc..
For the script widget "knobs_to_xy" I modified with this code to be able to manage separately X and Y.
I don't know if it's very ortodox! but it works !
var choice = get('dropdown_1')
if (choice == 1) { set('xy_1', [get('knob_1'),'']) } else if (choice == 2) { set('xy_1', [get('knob_2'),'']) } // etc..
var choice = get('dropdown_2')
if (choice == 1) { set('xy_1', ['',get('knob_1')]) } else if (choice == 2) { set('xy_1', ['',get('knob_2')]) } // etc..
@jean-emmanuel I've been looking at your demo and I have a couple of questions. I've removed everything except the xy and two faders. They aren't linked and there's no script widget. For learning purposes.
Putting this in the script property of the xy works
set('fader_1', value[0])
set('fader_2', value[1])
produces this
Putting this on a button happily resets the xy
set('xy_1', [0, 0])
But none of the following on a fader/knob update the xy without linkIDs and a script widget (as per your post).
This however is kind of wrong : set('xy_1', [this, 1])
(the variable this is null here, usually in js it represents the execution context, but scripts are executed in a detached context in OSC. The use of "this" in the @{} syntax and in some scripting functions as a shortcut to "this widget's id" may be misleading, it's just a sementical convenience, not an actual object reference)