Send Different Midi button based on Knob value

Hi, I am looking to integrate Open Stage with my 2D character control. I use the knob to control my elbow and I need to simulate different midi notes based on the knob values (this would allow me to swap wrist automatically when my arm is inside).

So I am looking to send one midi note when knob value <60 another one 60 to 120 and the third one >120.

I can see the scripting module that allows to set/get variables, but I do not see any IF Then type of controls in there. There is an option to use JS{} that does have an IF, but I cannot figure out how to feed its existing knob value.

Can someone point me to the right thing?

Just to shed some light for your idea. I'm considering the knob range to be "min": 0 and "max": 127.
You can add this code to the script field of the knob widget:

var note = 60 //sets the default note, used when knob value is lower than 60

if(value >= 60 && value <= 120) note = 60 // sets new note when knob is between 60 and 120
else if (value > 120) note = 62 // sets new note when knob value is greater than 120

send("midi:oscMIDI", "/note", 1, note, 100) // sends note "on" to channel 1, note defined by the variable, and velocity = 100
send("midi:oscMIDI", "/note", 1, note, 0) // sends note "off" using velocity = 0

Notice that in this case every time you turn the knob a new note will be sent.
I know this is not ideal. You can use the logic to set a new widget to send the note after turning the knob.
I hope it helps.

1 Like

Oh, I did not realize that I can do it in the scripting field. That answered everything, thanks!

1 Like