I got it working using the persitent state of the Javascript output. I added an enter scene trigger that sends the output to a new input called stored JSON, then I trigger an initialize on a small delay, which builds the JSON from the last JSON state. A bit more complex, but not overly so.
@woland. Your javascript for the toggles was inspiring and lead me to an complete shift in how I am handling midi. The idea of generating the JSON values for the toggle based on the button pressed and the use of a global variable to hold the current state of the JSON were revelations to me.
Previously, I had created a receiver user actor that I used for each page which would take midi values from a defined range of controller#s and then output values for each button. These were then combined into a JSON for the page. I itterated this over the 9 pages (2-10) and then combined this into the larger JSON that you have seen.
Here's some grabs of that build. It's huge.
Looking at how you did your Javascript I broke it down into chunks: the calculation of page#/button# based on my midi layout, calculate which midi values were for the only-one-on toggles (designated buttons) and which were for non designated buttons. I created a script (with the help of CHATGPT) that would output the the correct page/button and a booelan each for designed and non designated button presses for midi values that are in range for a given track. I filter the boolean for the designated buttons for 0 so that the script will not trigger when the button is released.
From there I used your only-one toggle generation for the designated buttons and am updating the JSON with any non-designed button values - I have some value cycles on some buttons to choose audio track, bank/page group etc. The result is this tiny thing that builds and updates my entire JSON for the Streamdeck XL.
While I am a bit sad to throw away all that other work, I learned a lot and am ultimately very happy to find this sleak solution. It will make me think much differently about how to solve some of problems moving forward. I am also slowing learning some more advanced Javascript from you and from Chat GPT :-) I am an oldschool Basic/Pascal/C guy from my earlier years. I know how to break a problem down, but I am unfamilar with many Javascript operations, the way it works with classes, and the fineries of its syntax....but i'm learning.
A quick question for you. It looks like the global variable in the javascript actor is cleared when changing scenes. This causes an error for me when I reenter the scene. Is there a way in javascript to store a global variable that is persistent, or would I use a global variable actor and trigger this on scene enter to restore the current state of the JSON for the JSON Generating Javascript?
Thank-you again for all of your help.
@wwachalovsky Just following up on this as it continues to be an issue for me. In my experience the crashes only occur when jumping between scenes at the same time as sending a plink command. I've come up with a successful workaround by creating a second instance of Isadora that only sits in one scene, but receives command via a listener (or OSC) from the main show file which broadcasts the desired triggers to the pj link actor in this secondary instance. It's maybe a little clumsy, but it has resolved my issue. I can share a file to give you an example of how this works if that's useful.
@fred Thanks for this. I have to wrap my head around it since I'm not a programmer...