Updating multiple widgets simultaneously with one osc command?

Hey everyone (and Jean-Emmanuel of course), always a HUGE fan of this software and I’m returning to attempting improve my iteration of it.

Specifically I need to update the state of every rgb led contained within a matrix (64 buttons to be precise). Currently I am doing so inefficiently by sending lots of osc messages in order to change one rgbled at a time

This is problematic to me and I’m sure there must be a way to send ONE osc message with a list or something so that all of the rgb leds change simultaneously.

Thanks for your help or any insights that will help me improve on this practice! My understanding of javascript stuff works with o-s-c together is still very basic.

You can create a script widget to handle a specific osc address (such as /led/set_all) and dispatch the values to the leds.

JS{{ // script property

// "value" contains the values received on the script's osc address
// loop over these values and dispatch them
for (var i=0; i<value.length; i++){
  // assuming the leds' ids are led_1, led_2, etc
  set("led_"+i, value[i])
}

}}

This could also be handled in a custom module in a similar way.

1 Like

Hey Jean-Emmanuel and thanks for the help!

I’ve been attempting out more sophisticated applications of this concept but haven’t gotten it to work.

2 questions.

  1. Shouldn’t the same code work for rgbleds if the script widget (such as /rgbled/set_all) is sent an array of arrays (with rgb values?) - Couldnt get this to work and tried a few things :confused:
  2. How would I make this work for multiple widgets contained in a matrix?
    Sorry, I attempted to get this working for awhile to no avail!

Thanks for everything!

  1. Yes it should:
// "value" is a 1-dimension array containing all received values
// we need to dispatch them 3 by 3
for (var i=0; i<value.length; i+=3){
  set("rgbled_"+i, [value[i], value[i+1], value[i+2]])
}
1 Like
  1. It works as described in the first example but you need to make sure you know the widgets’ ids by setting the matrix’ props option properly, for example:
{
  "id": JS{{return 'led_' + $}}
}
1 Like