Retrieve multiple values with a single input widget

Hi there!

I have four switch widgets, the first outputs numbers 1 to 5, second 1 to 10, third 1 to 15 and fourth 1 to 20.

How can I have a single input widget retrieve the value of all four switches independently?

The output value would be 1 to 20, coming from four different switches. Is this possible?

Thanks in advance!

hi,

have a look at the ardour online example “strip types”
if the id of a switch is “test1” and you set its value to 11, you can catch its value with @{test1} in another widget (e.g. in a value property via #{} , or via JS {{}} ) this is possible in all properties which are dynamic.

hope this helps

Hi abstrus, thanks for the response. That was the first thing I’ve tried but in this particular case, I’m trying to catch the value of four different switches independently.

If I set the value of the input to @{test1} @{test2} @{test3} @{test4} the result will be four different values at the same time ie. 1, 2, 3, 4

I need the result to be one switch at a time. Example: If I press switch1 value 4, the input widget will retrieve the number “4” alone. If I press switch2 value 7, the input widget will retrieve the number “7” alone, etc etc. Instead of retrieving all four numbers at the same time.

Dunno if that’s possible?

Thanks!

yes of course, what you are referring to is often called “radio button” (think so…).
Made a quick test.

just use a switch, fill in the values in the corresponding field.
if the id of the switch is “switch_1” you can catch this value via @{switch_1}.

Usefull if you use it in a JS{{}} context and trigger there OSC messages, etc…

But there might be other tricky stuff here e.g. when loading at first time-> setting the default value to ‘0’ the input is showing “undefined” (no switch is pressed) -> would have expected a 0 on the input obejct, maybe @jean-emmanuel could jump in here?

(maybe it is of interest when no button is pressed -> value of 0)

I’m using one input widget to catch four different switches values and send them as MIDI data. I need the input widget output to be one value at a time. What you are suggesting won’t work for me unfortunately. :frowning:

But the reset idea is great! Or an option to reset the switch whenever another widget is used. I tried to use Jean’s @{switch_example} invalid value method but in my particular case it’s causing errors because I’m outputting MIDI data.

The most straightforward solution is to use the linkId property:

  • set the switches’ linkId’s to >> switchlink
  • set the input’s linkId to << switchlink
  • only send midi with the input widget

Thanks a lot @jean-emmanuel ! I was able to go from 14 input widgets down to two! :raised_hands: I now have one input widget listening to all switches and a second input widget sending midi.

I've tried to use the @{switch_x} invalid value method, it does for example reset switch_1 when I use switch_2 but it gives me the following error:

ERROR: MIDI: Traceback (most recent call last):
File "E:\open-stage-control\resources\app\server\python\midi.py", line 214, in send_midi(*msg)
File "E:\open-stage-control\resources\app\server\python\midi.py", line 176, in send_midi args = [int(round(x)) for x in args]
File "E:\open-stage-control\resources\app\server\python\midi.py", line 176, in args = [int(round(x)) for x in args]
TypeError : type str doesn't define _ round _ method

Since I'm sending midi, it's expecting only midi data, instead of "invalid value". Is there another way to reset a switch (unselected) in this particular case?

Thanks again, Jean. You are a lifesaver :pray:

You can solve this by linking the four switches together as well, checkout this session file : switchlinks.json (2.7 KB)

1 Like

Simple and elegant… worked like charm! Thank you so much Jean :fist_right::fist_left: