Need help understanding switches array, related values and JSON!

Hi,

I've successfully build an external module for OSC and Logic
It is able to access my computer articulations folder, extract the values, json them and also to access another folder with pictures of my libraries.
It is also able to get the logic Trackname (without any external software) and if the selected track match an articulation or a library picture, it is able to send all these datas to Open Stage via OSC messages.

I want to build an articulations switcher based on my selected track

Doesn't have any issue to display the selected track name, or the actual Library picture based on my track selection in OpenStage

From the external module, I'm also sending a JSON Array to a switch with articulations name from the selected track and it does work !

In conjunction with my selected track my external module send @{myjsonartlistfile} and Open Stage returns the correct number of switches with my correct articulations names value as label text for each button.
My switch values are set to @{myjsonartlistfile}
myjsonartlistfile look like this
"legato":25,"Pizz":54, etc...

Json files have key and value
In this case, key is my articulation name and value is Articulation ID from my Logic

What is value used for in this case in Open Stage (Widget/Switch/Value)?
Is it ignored?

Now, for each switch, I want Open Stage to send a different MIDI note value back to Logic when pressed.
My external module have access to these notes according to my selected track too.

The note value is set in the preArgs part of OSC
for example if I want to send midi note 78 on channel 16, I have to set OSC preArgs to [16,78]
Don't have any issue being able to send a specific note from a switch to Logic.

But with my auto populated switch from my articulations names, I'm lost...

If I set preArgs to something like [16,@{mynoteValue}], it doesn't work...
Maybe I'm not sending the right data from my external module?
what format do I need to use for @{mynoteValue} ?
Do I need to send the same kind of values as myjsonartlistfile with a key and a value ?
Do I need to send a Character chain?
How to be certain that Notes value will be assigned to the correct button?

My concern is that I don't understand what to send from my external module to Open Stage switch to get the excepted result.

I'm quite there, I have access to all the datas from Logic in my external module, just need help to understand how to send them properly to OpenStage !!!!

I can't find anything about this in the documentation, help would be really appreciated !!!!

Thanks for your help and explanations !

Cheers

The value corresponding to selected key (e.g. 25 for key "legato") is used to determine the widget's current value: when selecting "legato" the switch's value is set to 25 and that's the value the widget sends in its osc message (after the preArgs if those are defined).

Now with MIDI it's always a bit tricky, in case of a /note event for example, preArgs are indeed supposed to represent the channel and the note number, the 3rd argument (the widget's value) being the velocity. To use the value as the note number I'd simply recommend using scripting to send the message:

// switch's onValue property
// since the message is sent here we could set bypass to true
// to prevent sending the default messages based on
// address, preArgs and target
var channel = 16
var velocity = 127
var note = value
send('midi:logic', '/note', channel, note, velocity)

That's for sending out of open stage control. If you want to control the switch's value from the outside, the principle is the same for all widgets and it's better to keep static values in preArgs to make it work properly (ie avoid @{} there, changing preArgs on the fly is like changing the address).

Thank you so much Jean-emmanuel !!!!

Still got an issue
when touching a switch, note on is sent, but never stop, never send note off ???

Did I missed something?

You can send a note off right after sending the note on by passing a velocity equal to 0:

send('midi:logic', '/note', channel, note, 127) //on
send('midi:logic', '/note', channel, note, 0)   //off

jean-emmanuel, you are perfect !!!!
Thanks