Sending rate, Multi XY

Hello,

I'm using the Multi XY widget and sending values to a DAW with the onValue script.

send ('/track/1/x', value[0])
send ('/track/1/y', value[1])
...

The DAW seems to be totally lost with all the values. How can I reduce the sending rate of this widget, and by the way, the number of decimals?

Thank you !

There's no built-in options for that. To reduce the widget's output you could first enable bypass (prevents default messages from the widget, also disable cross-client sync for this widget). Then to gain control over the sending rate you could do something like this:

// onCreate script property
locals.rate = 10 // max msg per seconds
locals.lastValueSent = []
locals.limitDecimals = (num)=>{
  return Math.round(num * 100) / 100 // 100 = 2 decimals, 1000 = 3 decimals, etc  
}
// onTouch script property
var points = getProp(this, 'points')
var x, y, i
var sending = false

if (event.type === "start") {

  sending = true

  // start loop (check if values changed and send every cycle
  setInterval(()=>{
    
    // for all points
    for (i=0; i<points; i++) {

      // get coordinates
      x = locals.limitDecimals(value[i*2])
      y = locals.limitDecimals(value[i*2 + 1])

      // if value has changed, send it
      if (x !== locals.lastValues[i*2]) send('/track/' + i + '/x', x)
      if (y !== locals.lastValues[i*2 + 1]) send('/track/' + i + '/y', y)

      // store last values for next comparison 
      locals.lastValues[i*2] = x
      locals.lastValues[i*2 + 1] = y
    }

  // stop loop if interaction stopped
  if (sending === false) clearInterval()

  }, 1000 / locals.rate)

} else if (event.type === "stop") {
  // stop loop (but let it run its last cycle to make sure the last values are processed)
  sending = false
  // clear stored values (send values even if identical when starting a new interaction) 
  locals.lastValues = []
}


(when not using scripting for sending messages, the decimals property can be used to define the number of decimals.

Works great ! Thank you !

I just had to adapt the script because the "points" variable is defined as an array.

Is there a way to keep the clients in sync without sending the default message of a widget?

Is there a way to keep the clients in sync without sending the default message of a widget?

You could enable ignoreDefaults instead of bypass to only prevent messages sent to the default server targets (send option in server config)