Monitor changes inside Scriptfx - the correct method? (broadcasters listeners)
-
Christoph wrote an example for exactly that somewhere... I wonder where it was I'm not sure, search for global cable posts!
That template above has a version of it. Use GPT to untangle my comments itll understand mostly what I was writing there
-
@griffinboy I tried many keywords already with no luck...
-
@griffinboy Cool I got it to compile with the callback!
Now it's a matter of properly reading the JSON I am sending...-> WorkingUI code:
const var RoutingManager = Engine.getGlobalRoutingManager(); const var DataCable = RoutingManager.getCable("dataCable"); const var data = {level: 0.0}; inline function onKnob1Control(component, value) { data.level = value; DataCable.sendData(data); };
C++
global_cable_data() { // Register a data callback for the global cable this->registerDataCallback<GlobalCables::dataCable>([this](const var& data) { if (auto* obj = data.getDynamicObject()) { const var& levelVar = obj->getProperty("level"); //if (levelVar.isDouble() || levelVar.isInt()) //{ gain = static_cast<float>(static_cast<double>(levelVar)); //} } }); }
This doesn't seem to updategain
EDIT: my bad... wasn't listening on the right set of speakers lol
WORKING LKE A CHARM!!!
Thanks a lot @griffinboy ! -
Nice thanks for posting the working answer
-
@ustk said in Monitor changes inside Scriptfx - the correct method? (broadcasters listeners):
@griffinboy I tried many keywords already with no luck...
In the docs:
HISE | ScriptNode | global_cable
Send a double precision float value anywhere to HISE
(docs.hise.dev)
What is the way to send the value to the node from the UI?
Is there a callback that should be defined?For UI -> Node communication, just use the stock parameter system. Only for Node -> UI communication (eg. reporting back analysis values from your C++ class) you need to use the global cables - and then you can choose between a realtimesafe single value or any arbitrary data that will be allocated and copied around over the DLL boundaries (which is not realtime safe).
-
@Christoph-Hart hmmm... have to look at this ! I made it to work UI -> global cable -> node, but I'll try with standard parameter to send an array of JSON
-
GCs are the only way to send an array into a node, unless you encode it as audio or other.
-
@griffinboy oh that's what I was thinking, @Christoph-Hart's shortcut needed a sequel
-
@ustk ah ok, I was just underwhelmed by the data you send over the cable in your example (a single gain number lol) but I have no idea what you're doing in the real world.
If you need to send more to your node, then yeah the global cable might be the best option.
-
@Christoph-Hart said in Monitor changes inside Scriptfx - the correct method? (broadcasters listeners):
@ustk ah ok, I was just underwhelmed by the data you send over the cable in your example (a single gain number lol)
Yeah you make me feel padawan like, which I probably am lol.
but I have no idea what you're doing in the real world.
I'm wondering the same thing every single day, until I'm uploaded to the cloud...
More seriously, I draw a spline in the interface, and send the control points to the node in order to reconstruct the wave shaper in a buffer...
Sounds the right approach or did I spend a week luring myself? -
@ustk the table UI component is exactly that - a path with (quadratic) curves that are rendered to a float buffer and can be send to a C++ class over the ExternalData API. If for some reason the Table doesn't fit your requirements then yes your approach would be the next best thing.
-
@Christoph-Hart I am making a cubic B-spline so a quadratic is somewhat underwhelming lol
But that would be so much easier