I need the change the values of a switch with an OSC message (sent by Max)
if I set my switch values to OSC{values}
and send a message (from Max) containing an array :
/switch_2/vals uno dos tres
nothing happens.
but if I delete my switch_2 widget, and undo, it is updated with the new values (uno dos tres)
(or if I select the field values and hit enter to evaluate it’s content, it refreshes the widget and display my values correctly)
How can I send an object of pairs “label”:value in an OSC message ? (instead of an array)
what is the stringified and OSC / Max friendly version of
{
“Value 1”: 1,
“Value 2”: 2
}
?
is there a repository of example files somewhere, demonstrating simple user cases like this one ?
I couldn’t fin any example or template O-S-C files on the website, it would really help beginners like me to start working with this amazing tool
The technique you're using is correct, you've just found a bug in the switch widget :). It'll be fixed in v1 alpha soon.
How can I send an object of pairs “label”:value in an OSC message ? (instead of an array)
what is the stringified and OSC / Max friendly version of
{
“Value 1”: 1,
“Value 2”: 2
}
sending '{“Value 1”: 1, “Value 2”: 2}' as a string should do. I'm not familiar with MAX but it seems you can easily convert dict objects to JSON strings (the format used to serialize object in open stage control): The Dict Object - Max 7 Documentation
is there a repository of example files somewhere, demonstrating simple user cases like this one ?
I couldn’t fin any example or template O-S-C files on the website, it would really help beginners like me to start working with this amazing tool
There no such thing currently although it's on the todo/wish list for v1.
ok, looking forward the next version to be able to make dynamic switches
I didn’t manage to use a default state with OSC listener :
if I set values to
OSC{values, {
“Value 1”: 1,
“Value 2”: 2
}
}
and my switch looks like this :
what is the correct syntax to use an object as a defaultValue ?
about sending an object of pairs “label”:value in an OSC message :
I tried sending
/switch_2/values ‘{Value1: 1, Value2: 2}’
/switch_2/values “{Value1: 1, Value2: 2}”
/switch_2/values {Value1: 1, Value2: 2}
( comma need to be escaped with a \ in Max, otherwise it is used to separate messages…)
nothing works ; values ? shows
and all values are displayed in one single cell
(with default values, ? shows
The Max dict stringify doc you pointed do not really helps, as it’s a method to manipulate dict inside javascript in Max ; we need to find a solution to format a standard Max message that will be sent to a udpsend object.
would you have an example of a message containing object of pairs “label”:value sent with other softwares that is interpreted correctly in O-S-C ?
about sending an object of pairs “label”:value in an OSC message [...]
In JSON, double quotes around keys are mandatory, so you'd need to send '{"Value1": 1, "Value2": 2}'. I've actually pushed a change yesterday to make the syntax a little less strict regarding this.
arg... this is really problematic in Max
double quotes can be used only to define a string containing several items separated by spaces
"Value 1"
but if I need a key without spaces
"Value1"
Max will automatically turn it into
Value1
I managed to make it it work sending it like this from Max :
/switch_2/values "{"ValueA": 1, "ValueB": 2}"
note that the whole objects needs to be sent as a symbol in Max (between double quotes)
and we need to force double quotes around keys using \
it works, ... but it's gonna be a pain in the * to create this kind of message in Max dynamically...
(probably same kind of issue in PD and other softwares..)
In the change you've just pushed, will we be allowed to use keys without double quotes ?