Midi Script Processor - How to callback from a ui control?
-
How can I get a midi processor to react to a UI control?
I've got a scriptnode synth, and I need a callback or listener of some kind, so that when I change a control on the UI, the scriptnode synth Midi Script Processor knows that there has been a change.
The purpose is to kill all voices and reset some arrays for the scriptnode synth when a control is altered.
-
So, my workaround has been to use global variables to pass stuff between the synth scripts and the UI.
This works, but idk if it's optimal. And it's not a callback, but this way I can edit data that belongs to the scriptnode synth in the main UI script, since the data is global... -
@griffinboy said in Midi Script Processor - How to callback from a ui control?:
global variables
You can connect your UI components to other modules using the parameter id and processor id settings in the property editor. Or you can use
.setAttribute()
to do it through scripting. -
I'm not sure I get it!
What I'm trying to do is trigger code.
Say I have an array inside a midi processor inside of a scriptnode synth.If I wanted to clear the array using a button on the main UI, I don't see any way of doing so!
Since code that exists in the interface script is not in the same scope as the scriptnode synth. Since that's the whole point of the encapsulation I guess
-
@griffinboy Think of every midi processor as a self-contained island. In your midi processor with the array you want to clear, add a button that clears the array. Then you can connect the button on your UI to the button on your midi processor.
Avoid global variables if you can - and I've never "had" to use them yet.
In fact yesterday someone sent me a link to a script I posted as part of a project on github many years ago. They wanted to use this script in their project but it wasn't working. I took a look and realised it wasn't working because it was relying on various global variables existing and being set in other midi processors that weren't present in their project. This was a bad design choice but past Dave didn't know it.
-
Interesting.
Okay I've never done this before I didn't know set attribute could be used that way.
I'll have a go