Button read other buttons state

Hello. everyone.

I'm totally newbie but OSC is really great. I'm really enjoying it.

I have a question that I can't figue it out by myself.
Can I do this?

for example
When I press button A it send cc1 (If button B is On)
When I press button A it send cc2 (If button B is Off)

Thank you

Hi,

in the onValue scripting

var state = get('button_1')
if (state == 1){
  send('midi:virtual_midi', '/control', 1, 1, value)
}
else {
  send('midi:virtual_midi', '/control', 1, 2, value)
}

basically var state get the position of the button_1 and then send the midi data contain within the conditional if / else

midi_button.json (3.3 KB)

1 Like

Thnks you zoltan

I’ll try it right now

Have a nice day

Hey @whereissun,

also you can try this one-liner:
send('midi:virtual_midi', '/control', 1, get("button_1") === 0 ? 1 : 2, value)

You can use this syntax in any script field or #{}. Have a look at button_2's label for example:
midi_button_2.json (3.2 KB)

Cheers

1 Like

Oh thanks Open-Stage-Composer

It look simpler!

1 Like