Scripting - get result of send() function

Heya!

First of all, thanks for creating this amazing piece of software!

Currently I'm using [AbletonOSC](https://github.com/ideoforms/AbletonOSC) to control Ableton via OSC which works great.
AbletonOSC also has addresses to query information from Ableton. For example the state of the metronome:
/live/song/get/metronome

This gave me the idea to call this address in the onCreate script of my metronome Button widget, so it gets the state of the metronome from Ableton when starting up O-S-C.

I've created the following script and noticed that the send() function doesn't return the value of the call:

const HOST = 'localhost'
const PORT = 11000
const QUERY_METRONOME_URI = '/live/song/get/metronome'

const isMetronomeOn = send(HOST, PORT, QUERY_METRONOME_URI)

console.log('isMetronomeOn', isMetronomeOn)

// isMetronomeOn seems to be undefined since send() doesn't seem to return anything. 
if (isMetronomeOn) {
  set('this', true)
}

This raises a couple of questions:

  1. What's the reason why send() doesn't return anything?
  2. Is it possible to change the send function so it does return the result? Right now it only seems valuable to set values but not to receive values. I did see there's a receive function but that's not available in the Widget scripts and also doesn't return anything.
  3. Is there another workaround available?

Keep in mind that the setting of the metronome uses a different address:
/live/song/set/metronome.

Hereby a screenshot of the Widget. You can also see that there's no result in the Console:

Thanks a lot for your help!

Kind Regards,

Ron

I noticed that the results of send() are automatically added to the value of the Widget.
Also AbletonOSC uses port 11001 to send messages to.
So in the O-S-C server config I had to correct the osc-port:

To make sure that the state of the widget keeps listening for an update from Ableton I've added the following in the onCreate script:

setInterval(() => {
  send('localhost:11000', '/live/song/get/metronome')
}, 1000)

Also it seems I had to add OSC{/live/song/get/tempo} in the value of the Widget. Without that the value isn't updated.
Hereby a screenshot of the widget to be complete:

Hopefully this helps :).

i don't know about liveosc but try to put localhost:11000 into the send property on the main configuration will help you.

Nice thanks for the tip! That indeed saves some typing :smiley:

send() doesn't return anything because in the OSC protocol there's no synchronous reply. When the send function returns, there's no way for open stage control to be aware of a reply message, if any.