HISE Logo Forum
    • Categories
    • Register
    • Login

    Broadcaster error

    Scheduled Pinned Locked Moved Scripting
    14 Posts 4 Posters 623 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.
    • d.healeyD
      d.healey
      last edited by

      This was working in previous commits.

      Now I get an error argument amount mismatch: 2, Expected: 3

      const isDownloading = Engine.createBroadcaster(false);
      
      isDownloading.addListener(btnLogout, function(state)
      {
      	this.set("enabled", !state);
      });	
      

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      Christoph HartC 1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart @d.healey
        last edited by

        @d-healey Ah yes, sorry I didn't know anyone is already using the broadcasters, so I have absolutely no ambition of maintaining backwards compatibility :)

        I've changed the method signatures to expect a metadata object so that the broadcaster map contains more information (I'll update the docs what to put in there soon). In the meantime, you can just pass in any string for the metadata parameter.

        d.healeyD Christoph HartC ulrikU 3 Replies Last reply Reply Quote 3
        • d.healeyD
          d.healey @Christoph Hart
          last edited by

          @Christoph-Hart Thank you :)

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

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

            For quick reference, your example must look like this:

            namespace ServerLogic
            {
            
            /** The broadcaster construction will expect a JSON object with an id, a args array containing the argument names and other optional properties (TBD).
            */
            const isDownloading = Engine.createBroadcaster({
              "id": "Download Status",
              "colour": -1, // -1 will create a pseudo random colour from the id hash
              "args": ["state"]
            });
            
            /** The addListener function expects a metadata parameter as second object, the most simplest option is a plain ol' string. */
            isDownloading.addListener(btnLogout, "Disable the Logout Button during download", function(state)
            {
            	this.set("enabled", !state);
            });	
            	
            }
            

            By enforcing this metadata, you'll get self-documented code and this visualisation for free:

            fc4420f2-30c1-4377-9a61-77667bb20c92-image.png

            d.healeyD ulrikU 2 Replies Last reply Reply Quote 2
            • d.healeyD
              d.healey @Christoph Hart
              last edited by

              @Christoph-Hart Oh that looks excellent!

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              1 Reply Last reply Reply Quote 0
              • ulrikU
                ulrik @Christoph Hart
                last edited by

                @Christoph-Hart said in Broadcaster error:

                @d-healey Ah yes, sorry I didn't know anyone is already using the broadcasters...

                I'm using it to get mouse events on tables, working great!
                The broadcaster is a great compliment when working in Hise 👍

                Hise Develop branch
                MacOs 15.3.1, Xcode 16.2
                http://musikboden.se

                lalalandsynthL 1 Reply Last reply Reply Quote 0
                • lalalandsynthL
                  lalalandsynth @ulrik
                  last edited by

                  @ulrik I am using it to get scrolling info text when hovering knobs :)
                  I am sure it has lots of uses

                  https://lalalandaudio.com/

                  https://lalalandsynth.com/

                  https://www.facebook.com/lalalandsynth

                  https://www.facebook.com/lalalandsynth

                  1 Reply Last reply Reply Quote 0
                  • ulrikU
                    ulrik @Christoph Hart
                    last edited by

                    @Christoph-Hart could you help me with this code, I know you changed the way Broadcaster works so, this code worked before I updated Hise today, what do I have to change to make it work again?

                    const var TBLWatch = Engine.createBroadcaster({"component": undefined, "event": undefined});
                    TBLWatch.setEnableQueue(true);
                    
                    TBLWatch.attachToComponentMouseEvents(TBL, "All Callbacks");
                    
                    //	TBL CALLBACK	--------------------------------------------------
                    TBLWatch.addListener("RefreshFunction", function(component, event)
                    {   	
                        if (TempoFlexBtn.getValue() && event.mouseUp || event.rightClick)
                        {
                            setFlexiNotes();
                            TableData.setValue(TBLdata.getTablePointsAsArray());
                        }
                    });
                    

                    It is the line

                    TBLWatch.attachToComponentMouseEvents(TBL, "All Callbacks");
                    

                    that is complaining about having 3 arguments

                    Hise Develop branch
                    MacOs 15.3.1, Xcode 16.2
                    http://musikboden.se

                    ulrikU 1 Reply Last reply Reply Quote 0
                    • ulrikU
                      ulrik @ulrik
                      last edited by

                      @ulrik @d-healey @lalalandsynth any tips how to?

                      Hise Develop branch
                      MacOs 15.3.1, Xcode 16.2
                      http://musikboden.se

                      Christoph HartC 1 Reply Last reply Reply Quote 0
                      • Christoph HartC
                        Christoph Hart @ulrik
                        last edited by Christoph Hart

                        It's like the answer I gave to David: you need to pass in a metadata object that describes what the broadcaster is doing. Also the createBroadcaster call needs a JSON object with an id property and the arguments as Array of Strings:

                        const var TBLWatch = Engine.createBroadcaster({
                          "id": "TBL Watcher",
                          "args": ["component", "event"]
                        });
                        
                        TBLWatch.setEnableQueue(true);
                        
                        TBLWatch.attachToComponentMouseEvents(TBL, "All Callbacks", "Mouse Listener for TBL");
                        
                        //	TBL CALLBACK	--------------------------------------------------
                        TBLWatch.addListener("RefreshFunction", "updates FlexiNotes and sets the table data from TBL",
                        function(component, event)
                        {   	
                            if (TempoFlexBtn.getValue() && event.mouseUp || event.rightClick)
                            {
                                setFlexiNotes();
                                TableData.setValue(TBLdata.getTablePointsAsArray());
                            }
                        }); 
                        

                        The advantage of this is that you'll get this visualization of your broadcaster logic:

                        df2e3ea3-1899-4d6c-9184-2417a1943561-image.png

                        ulrikU 1 Reply Last reply Reply Quote 4
                        • ulrikU
                          ulrik @Christoph Hart
                          last edited by

                          @Christoph-Hart Thank you, I read what you wrote to David several times and I was close, but now I understand it more :)

                          Hise Develop branch
                          MacOs 15.3.1, Xcode 16.2
                          http://musikboden.se

                          1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey
                            last edited by d.healey

                            I saw this in another thread addComponentPropertyListener. There is no documentation for it. What is the difference between that and attachToComponentProperties followed by addListener?

                            Also when using attachToComponentProperties I get this error If you want to attach a broadcaster to property events, it needs three parameters (component, propertyId, value)"

                            But the function definition is void ScriptBroadcaster::attachToComponentProperties(var componentIds, var propertyIds, var optionalMetadata)...

                            Libre Wave - Freedom respecting instruments and effects
                            My Patreon - HISE tutorials
                            YouTube Channel - Public HISE tutorials

                            Christoph HartC 1 Reply Last reply Reply Quote 0
                            • Christoph HartC
                              Christoph Hart @d.healey
                              last edited by

                              @d-healey it means that the broadcaster itself needs to have three arguments (specified through the args property of the metadata at construction).

                              What is the difference between that and attachToComponentProperties followed by addListener?

                              It directly sets the component properties that you specify (and shows the current properties in the broadcaster map). Nothing that you can't achieve with the base addListener(), but more convenient (and concise in most cases).

                              I've some local edits for the docs with the new methods, but I need to clean it up a bit before pushing.

                              Christoph HartC 1 Reply Last reply Reply Quote 1
                              • Christoph HartC
                                Christoph Hart @Christoph Hart
                                last edited by

                                Alright, the docs are online, but let me know if something is unclear.

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

                                46

                                Online

                                1.7k

                                Users

                                11.7k

                                Topics

                                102.2k

                                Posts