Set dropdown values via osc

Hi there.
Im quiet new to o-s-c and struggle to set values via osc.

I want to great a dropdown menu with key/value pairs which are set by a osc string. I'm able to get some data in, but it seems to to be parsed as array.

Example:
OSC: "/list/"{"Cue 1": 1, "Cue 2": 2}"

Dropdown will display: {"Cue 1": 1, "Cue 2": 2}
but won't parse it to:
{
"Cue 1": 1,
"Cue 2": 2
}

Any suggestions how to achieve this?

Thanks in advance.

Could you enable the server's debug mode and paste here the message printed when attempting to update the dropdown ?

Sure.
Thanks for getting back.

(DEBUG, OSC) In: { address: '/list', args: ' {„Cue 1“: 1, „Cue 2“: 2}' } From: 127.0.0.1:49830

Are you using curly quotes („Cue 1“) or is it just formatted this way here on the forum ? If you are, try using regular double quotes instead.

Sorry.

I’m at work.

I use regular double quotes.

No problem, please upload your session file when you can so that I can try to reproduce the issue.

Sadly I'm not able to upload any files since I'm a new user.

I guess the program I'm sending osc from (QLab) parses the message wrongly. I'm able to get something like:

(DEBUG, OSC) In:  { address: '/list', args: [ 'one:', 1, 'two:', 2 ] } From: 127.0.0.1:59317

Is there any way to reformat this to:

 {'one:', 1, 'two:', 2  } 

Maybe using scripting?

I assume you wrote something like this in the dropdown's values property to receive the message from qlab:

OSC{/list}

Sending /list '{"Cue 1": 1, "Cue 2": 2}' as a string is supposed to work, but it is possible to parse [ 'one', 1, 'two', 2 ] too:

JS{
var qlab_values = OSC{/list} || []
var values = {}
for (var i = 0; i < qlab_values.length; i+=2) {
  values[qlab_values.length[i]] = qlab_values[i+1]
}
return values
}

(I removed the colon from one: and two: to simplify the process.)

1 Like

Hi.

Thanks for all your support. I finally got it working with the first syntax.

OSC{/list}

I just had to change the QLab osc string to:

"{'Cue1':1, 
'Cue2':2
}"

I really appreciate you helping out. Keep up the great work.

Sorry to bother you again....
I had to change some OSC stuff and am now struggling tp parse some input.
Could you point me in the right direction?

I'm getting a string with seconds (elapsed time).

21:19:18.644 | RECEIVE    | ENDPOINT([::ffff:127.0.0.1]:61304) ADDRESS(/time_elapsed) STRING(0,268961)

How could I parse that to time format (mm:s)?

Thanks in advance.

Here is a javascript one liner found here:

JS{
var time_in_seconds = parseInt(OSC{/time_elapsed})
return new Date(1000 * time_in_seconds).toISOString().substr(11,8)
}

Thanks.

You've built a really great tool.