Broadcasters working inside HISE but not inside compiled plugin
-
@Orvillain there's a bit of a paradox within the HISE development environment that doesn't happen inside the plugin:
when you compile a script, or even compile all, the global variables do not get destroyed. After they have been declared and initialized, they live until you close HISE.
This can result in you doing stuff with them before actually declaring them in code. While this will work on compiles beyond the first in HISE, it (obviously) won't in a compiled plugin.
Make sure that any global declarations are among the very first things you do in the very first MIDI processor in your project. I have a Globals processor above my Interface processor which does just that.
The only reason for the broadcasters to not work that I could think of is that you were storing their references in a global and the order of it all was whack. That's why I asked.
-
@aaronventure Would it help if recompile all scripts would clear all globals? Then you could at least reproduce the event order of the plugin.
-
Oh and loadFromJSON with a relative path is weird, not sure if that will work. Include it as script and assign it to the variable in the file.
-
@aaronventure said in Broadcasters working inside HISE but not inside compiled plugin:
Make sure that any global declarations are among the very first things you do in the very first MIDI processor in your project. I have a Globals processor above my Interface processor which does just that.
Maybe I'm being a n00b, but how come I can't just declare that stuff in the interface script?? I don't believe I'm trying to do anything with the global variables before declaring them, but I could be wrong.
@Christoph-Hart said in Broadcasters working inside HISE but not inside compiled plugin:
Oh and loadFromJSON with a relative path is weird, not sure if that will work. Include it as script and assign it to the variable in the file.
Yes I've just done this, as it was my first hunch too. But it made no difference. Seems like good practice to use dedicated explicit scripts anyway, rather than loadFromJSON.
-
@Christoph-Hart yeah we already talked about this and agreed that's the best course of action, but I think you were deep in multipage at the time so you probably forgot.
@Orvillain said in Broadcasters working inside HISE but not inside compiled plugin:
Maybe I'm being a n00b, but how come I can't just declare that stuff in the interface script?? I don't believe I'm trying to do anything with the global variables before declaring them, but I could be wrong.
you can, just make sure they're at the very top, even before you import anything. that way the chance to mess things up becomes zero.
I like having them in a separate midi processor because I often use them to pass info between the interface and other processor scripts, so when I need to add another property I can just open the Globals processor in a popup without swapping the workspace back to the interface script
-
Right, so this is my entire interface script:
Content.makeFrontInterface(1920, 1080); include("ModuleMap.js"); include("defaultRoutingMap.js"); // Only run this when I want to rebuild the Module Tree //include("TreeBuilder.js"); //TreeBuilder.buildDrumPluginModuleTree(); include("ModuleSetup.js"); ModuleSetup.setupModuleTree(); include("Colours.js"); include("Paths.js"); include("ConversionUtils.js"); include("channel_dicts.js"); include("UISetup.js"); UISetup.ui_createMicrophoneElements(); include("SetupBroadcasters.js"); SetupBroadcasters.setupSampleMapLoadListeners(); SetupBroadcasters.setupMuteSoloListeners(); SetupBroadcasters.setupPanAndLevelListeners();
Everything that is happening is predicated on the existence of the ModuleMap - which is my overall global data handler. Here's a snippet of that:
const g_moduleMap = { "mixdownBusContainer": { "index": 0, "name": "mixdownBusses", "channel_count": 52, "object": null, "routing_matrix": null, "gain_stages": {blahblahblah}, }, etc etc etc etc etc etc etc };
The only thing that happens prior to including the ModuleMap.js file, is creating the front interface. Everything that happens afterwards, is in the correct order.
The broadcasters are setup only when all of my global variables and my data is in place.
It sure is a puzzler!!
I tried moving all of the include statements to a dedicated midi processor, before the interface processor, and that just broke everything and my broadcasters stopped working even in Hise.
-
Wait... I think I might know what it is.... and I think I'm being dumb....
inline function setupMuteSoloListeners() { local mute_bc = Engine.createBroadcaster({ id: "Mute Listener", args: ["component", "value"], }); local solo_bc = Engine.createBroadcaster({ id: "Solo Listener", args: ["component", "value"], }); local micsContainer = g_moduleMap["mixdownBusContainer"]["micsContainer"]; local mutes = Content.getAllComponents("_mute"); local solos = Content.getAllComponents("_solo"); mute_bc.attachToComponentValue(mutes, ""); solo_bc.attachToComponentValue(solos, ""); mute_bc.addListener(micsContainer['routing_matrix'], "Mute", muteChannel); solo_bc.addListener(micsContainer['routing_matrix'], "Solo", soloChannel); }
That sets up my mute and solo broadcaster... but if the reference to the actual broadcaster is setup as local within an inline function..... will that break it inside a plugin???
-
FOR GOD SAKE!
Yes, that was it.
I am a huge idiot and should be thrown in the bin like Kurt Russell in the movie 'Soldier' - which I might watch tonight rather than devving, coz clearly I suck monkey nuts at it!!!
Thanks @aaronventure for the input, and the nugget that made me spot my error!
-
@Orvillain yes it will, the locals have the lifetime of the function itself. once the function is done, the locals get destroyed to free up memory.
anything you wish to store, you should return. i.e. at the end call
return [mute_bc, solo_bc]
and your function call is then
const bc_array = setupMuteSoloListeners()
-
-
-
Yeah nice one, I get it now. It worked inside HISE but not in the plugin because the scope of the broadcasters was wrong. Won't make that mistake again!
I've genuinely been hitting my head against this for 4 weeks. :pouting_face:
-
@Orvillain i wonder how or why this works in HISE in the first place.
-
@aaronventure No idea tbh!!