Two or more osc address on a toggle button

Good morning!
Is it possible to send two osc command from a toggle button?
Like:
/exec/2/1
/exec/3/1

osc

As you see in the screenshot, it works with one of two comands but not with both. Maybe miss a “,” or “;” or something else?

A widget can’t have multiple addresses. To achieve this you need to either use a script widget or a custom module.

1 Like

Thanks! I never used custom module.
Where I can associate it to a toggle button?
Can you send me an example?

Solution 1: script widget

  • create a script widget
  • set its value property to @{toggle_id}
  • set its target property (if not using the server’s send option)
  • set its script property as follows:
JS{{

send(false, "/exec/2/1", value)
send(false, "/exec/3/1", value)

}}

The script will be executed when the toggle’s value changes;
Referece : https://openstagecontrol.ammd.net/docs/widgets-reference/#script


Solution 2: custom module

This solution works differently, the custom module filters outgoing and incoming osc message, there is no actual “binding” with the widgets but one can use conditions and functions to achieve pretty much anything. Here is a minimal custom module file that routes messages with address /toggle_1 to addresses /exec/2/1 and /exec/3/1.

module.exports = {

  oscOutFilter: function(data) {

    var {address, args, host, port} = data

    if (address == '/toggle_1') {

      // intercept messages from toggle_1 and send some messages

      send(host, port, '/exec/2/1', ...args)
      send(host, port, '/exec/3/1', ...args)

      return // bypass original osc message
    }

    return data

  }

}

You need to set at least one target for the widget or a global default target (server’s send option) to ensure it actually sends a message and gets filtered.

Reference: https://openstagecontrol.ammd.net/docs/custom-module/

1 Like

Hello

I've been appreciating the support here and just joined. I have extremely limited basic programming knowledge and skills but I did manage to build a working OSC setup that includes mainly 1-function buttons, some modals and a couple of keyboards, spread across 3 tabs.

I've tried to follow this thread but I'm clearly missing some knowledge of how to program a script widget or what a custom module actually is. I am wondering if anyone might help me with some code, (or at least understand) how I can accomplish sending the following two commands from one button. (they could happen in either order theoretically.)

command 1: (midi program change - midi channel 13, program 1)
command 2: (midi CC - channel 11, cc 91)

Not sure if this is considered "multiple addresses" as jean-emmanuel expresses here, or if there's just much more to it than I'm qualified to understand.

Any help much appreciated.

Thx

Things have changed a bit since my last post in this thread. To make that button send two messages in a row you'd set

  • mode to momentary (assuming we don't need a on/off behavior)
  • bypass to true (to prevent the widget's default messages from being sent)
  • onValue to
send('/program', 13, 1)
send('/control', 11, 91, 127) 

This assumes the widget's target property is set (or that the server has a default target set for all widgets using its send option), otherwise you'd need to specify the target like this:

send('midi:port', '/program', 13, 1)
send('midi:port', '/control', 11, 91, 127) 
3 Likes

Jean-Emmanuel

Thanks so much for these prompt instructions. They worked flawlessly. I of course couldn't explain technically, the coding behind this why this formatting work over what I was attempting but ultimately I'm very appreciative.

I'll continue digging in here in hopes that I'll find answers to some of my additional questions related to some other programming challenges. (need to understand how to get OSC to receive a range of midi messages and modify them, based upon a single button being depressed, then outputting the modified message back to continue on the path it was before entering OSC.)

Thx

Andy

What if you wanted to send 2 /note messages, while keeping the button on toggle? Would you still need to use a script widget?