HISE Logo Forum
    • Categories
    • Register
    • Login

    Broadcasters working inside HISE but not inside compiled plugin

    Scheduled Pinned Locked Moved Solved Scripting
    15 Posts 3 Posters 332 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • O
      Orvillain
      last edited by

      I'm at a loss here. My broadcasters are working fine inside HISE, but not inside my compiled plugin. I don't really know how to debug this.

      Are there any gotchas to watch out for?

      I have a set of mute and solo buttons. I also have a set of volume and pan faders. These are all working inside HISE without any problem. But inside the compiled VST3 plugin nothing works. I do hear my sampler audio, so I know the plugin is working on some level.

      This is a big project. Not really sure what code to provide to help debug!

      A 1 Reply Last reply Reply Quote 0
      • A
        aaronventure @Orvillain
        last edited by

        @Orvillain are you using global variables?

        O 1 Reply Last reply Reply Quote 0
        • O
          Orvillain @aaronventure
          last edited by

          @aaronventure I believe I am.

          Here's the relevant bit of my Interface startup code:

          Content.makeFrontInterface(1920, 1080);
          
          const g_moduleMap = Engine.loadFromJSON("../Scripts/ModuleMap.json");
          const g_defaultRoutingMap = Engine.loadFromJSON("../Scripts/default_channel_data.json");
          
          // Only include these lines 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();
          

          The only thing that I can think is that somehow the reference to g_moduleMap and g_defaultRoutingMap are not being setup correctly when inside the plugin.

          Should I turn these into .js files with explicit declarations of the JSON tree's I want to use as my global data handlers???

          A 1 Reply Last reply Reply Quote 0
          • A
            aaronventure @Orvillain
            last edited by aaronventure

            @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.

            Christoph HartC O 2 Replies Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart @aaronventure
              last edited by

              @aaronventure Would it help if recompile all scripts would clear all globals? Then you could at least reproduce the event order of the plugin.

              Christoph HartC A 2 Replies Last reply Reply Quote 0
              • Christoph HartC
                Christoph Hart @Christoph Hart
                last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • O
                  Orvillain @aaronventure
                  last edited by

                  @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.

                  1 Reply Last reply Reply Quote 0
                  • A
                    aaronventure @Christoph Hart
                    last edited by

                    @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

                    O 1 Reply Last reply Reply Quote 0
                    • O
                      Orvillain @aaronventure
                      last edited by

                      @aaronventure

                      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.

                      O 1 Reply Last reply Reply Quote 0
                      • O
                        Orvillain @Orvillain
                        last edited by Orvillain

                        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???

                        O A 2 Replies Last reply Reply Quote 0
                        • O
                          Orvillain @Orvillain
                          last edited by

                          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!

                          1 Reply Last reply Reply Quote 1
                          • A
                            aaronventure @Orvillain
                            last edited by

                            @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()

                            O 1 Reply Last reply Reply Quote 1
                            • O Orvillain marked this topic as a question on
                            • O Orvillain has marked this topic as solved on
                            • O
                              Orvillain @aaronventure
                              last edited by

                              @aaronventure

                              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:

                              A 1 Reply Last reply Reply Quote 0
                              • A
                                aaronventure @Orvillain
                                last edited by

                                @Orvillain i wonder how or why this works in HISE in the first place.

                                O 1 Reply Last reply Reply Quote 0
                                • O
                                  Orvillain @aaronventure
                                  last edited by

                                  @aaronventure No idea tbh!!

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post

                                  65

                                  Online

                                  1.7k

                                  Users

                                  11.7k

                                  Topics

                                  102.2k

                                  Posts