Hi there,
So things are getting complex , but I'm almost on there and quite happy about it
Basically I got this device that has a functionality that upon pressing some buttons it will change the MIDI channel which the device is setted into , so all the widgets will have to be switched to this newly selected Channel accordingly.
To switch those channels you have to press a modifierButton + stateButton
, (there are 2 modifier buttons , but that is not important) . If the stateButton
is pressed by its own it sends a MIDI message as well
modifierButton
"type": "button",
(...)
"id": "user",
(...)
"mode": "push",
stateButton
"type": "button",
(...)
"id": "trackControl01",
(...)
"mode": "push",
(...)
"script":
if((get('user') == 1)) {
setVar( 'globalVariables', 'deviceMode' , 1);
} else if ((get('factory') == 1)) {
setVar( 'globalVariables', 'deviceMode' , 9);
} else {
send('midi:virtual-launchcontrolxl', '/note', getVar('globalVariables' , 'deviceMode') , 73 , 127);
send('midi:virtual-launchcontrolxl', '/note', getVar('globalVariables' , 'deviceMode') , 73 , 0);
}
This above works fine if I define a variable in my initScript (which runs once upon initiation of the device, with all globals. definintion
setVar( 'globalVariables', 'deviceMode' , 9);
Ok so this work great for when I have to retrieve the variable in an script widget , the issue is that now I have knobs that need to parse that variable channel on their preArgs parameter, so I'm trying
knobAA
"preArgs": "[
JS {{ getVar('globalVariables' . 'deviceMode') }} ,
13
]"
And that is not working.
My question is , how would you ideally Set a global variable? (with a default value) , How would you change it and how would you call it within your widgets?
Thanks