Wish to modify an encoder widget to pulse an on/off value as the encoder is turned each increment

Hi everyone,

I'm not very proficient in js scripting or the structure of Open Stage Control, so thank you if you are able to help.

I'm using Open Stage Control with MIDI2vJoy to trigger game device buttons. I have basic buttons triggering correctly using the button widgets.

I'd also like to have a pair of game device buttons pulse on / off as I rotate an encoder widget - one game device button pulse on/off as the encoder widget rotates clockwise per increment, and another game device button do the same when the encoder widget rotates counter-clockwise. I'm guessing it would require a midi data value, note value and a high velocity value to be sent, followed briefly after by the same message but with a zero velocity value, per increment, per direction.

Would it be possible to modify the existing encoder widget to behave in this way using the script pane?

Thank you for your help, regards, Jay

I think I may be part way to a solution. Could you let me know if I'm on the right track?

I've bypassed the OSC output.

In the widget's scripting "OnValue" I can use something like this for each direction;

  • send('midi:mymidiport', '/note', 2, 0, 127)
  • create a short delay
  • send('midi:mymidiport', '/note', 2, 0, 0)"

I think all I now need is a way to read the direction of the encoder so I can pop the above code into an "if / then".

Can anyone suggest a relatively simple way to read the current OSC output value of the encoder? Depending on it's rotation direction, would I be expecting to see the output as a +1 / -1 or 0 / 127?

Can it be done with the OSC bypassed?

Thanks again. Jay

Got it to work. it's not very responsive, maybe because of latency between OSC, LoopMIDI and MDI2Vjoy? I've experimented with the setTimeout timing.

If anyone has a more elegant way of achieving this please let me know.

The Get("encoder_1") returns a value of either -1 or +1

Setting the "Release" parameter to 0 seems to prevent the occasional button getting stuck on

Added the script below to the "On Value" scripting box for the encoder widget.

var bob = get("encoder_1")

if (bob > 0) {
send('midi:VirtualMIDI', '/note', 1, 1, 127)
setTimeout(function(){send('midi:VirtualMIDI', '/note', 1, 1, 0)}, 30);
if (bob < 0) {
send('midi:VirtualMIDI', '/note', 1, 2, 127)
setTimeout(function(){send('midi:VirtualMIDI', '/note',1, 2, 0)}, 30);


Because I would occasionally get a stuck on game button, I've tried adding a note off message for the two buttons when the encoder is released, though the issue might be within MIDI2vJoy itself.

Just an update - It appears to be the MIDI2vJoy python installable version that is slow (Github Master version). I've uninstalled that and I'm now using a version called MIDI2vJoy2 (v2.2.0) which is an executable. It's far more responsive. Your .conf file will need small modifications if you wish to use it instead.

Works very well so far.

1 Like

Instead of get('encoder_1') you could use the value variable directly since you are in that encoder's onValue script.

if (value > 0) {
  // etc
1 Like

Thank you Jean.

Is there an easy way, just for cosmetic reasons, to enter a "release" value in the field and have the encoder handle remain where it is at release? (and not snap back to 12 o clock on release even though the encoder setting is "circular")

Leave the release property empty and use the onTouch script to send the release message:

if (event.type == 'stop') {
  // send release message
1 Like

Excellent, thank you Jean :+1: