HISE Logo Forum
    • Categories
    • Register
    • Login

    An efficient way to script functions for multiple knobs?

    Scheduled Pinned Locked Moved General Questions
    12 Posts 6 Posters 398 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 @orange
      last edited by

      @orange Is there a reason you're using callbacks rather than connecting the knobs via parameter I'd?

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

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

        @d-healey I'm guessing he's setting the scriptnode parameters directly.

        If you use an array for the parameters and UI elements, you can use a single callback like this:

        // Make sure that they have the same length and the positions match
        const var Parameters = [...];
        const var Knobs = [...];
        
        inline function onKnob(component, value)
        {
            local idx = Knobs.indexOf(component);
            Parameters[idx].setValue(value);
        }
        
        for(k in Knobs)
            k.setControlCallback(onKnob);
        1 Reply Last reply Reply Quote 2
        • orangeO
          orange @d.healey
          last edited by orange

          @d-healey said in An efficient way to script functions for multiple knobs?:

          @orange Is there a reason you're using callbacks rather than connecting the knobs via parameter I'd?

          I used that in case of the multiple parameter modulations for each knob (I generally use more than 1 setAttribute for each knob :) ).

          If each knob controls just one parameter, then they can be connected to the Parameter Id's too.

          develop Branch / XCode 13.1
          macOS Monterey / M1 Max

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

            @tomekslesicki If I know the knobs are named similar and also the effects (as in this case) I usually use

            const knbs = Content.getAllComponents("Knob");
            const gains = Synth.getAllEffects("SimpleGain");
            

            to get arrays for both the components and the modules and then I set it up like this:

            HiseSnippet 1044.3oc6X8uaaaCDlx1bqVasncXO.BE4Ob.5BrS69APwPcicRgQWRLlx51vPQKsDULgoHEjnxhwvdk1yPeT5SPQeC5NRIaIkY64ZrUrfY8GFl7ti22c9iejVCikdzjDY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7N3I2XG8XqbiclYD8dpEzYYZAl6JrUKXqVvVsf+unEr+xzBds9p+a0B1pErUK3ZqVvGhbDR7hkuvK68Kn2ZdCyLPcKLujxl3i0icl+VIv3160FA+wU1K77z+Gou.5OKNl82fXt+FDyC1fX9xMHluZCh4q2fX9lUFi98093TkLLi+CSL7PyK3wx5PAAXxlsBn+Dv5gyA3
            

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

            T 1 Reply Last reply Reply Quote 2
            • T
              tomekslesicki @ulrik
              last edited by

              Thanks guys, I got it working! Christoph was right, I'm controlling Scriptnode parameters so both attribute and values are set from the main script.

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

                @tomekslesicki is there a particular reason for controlling the parameters instead of connecting them to root container parameters and then using setAttribute?

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

                  @Christoph-Hart yeah, I have too many scriptnode parameters and there's a bug where after a certain number, they don't work when set like that. So I'm using parameter numbers and that works fine as a walkaround.

                  By the way - can I use the method you suggested here to change the width of multiple panels as well?

                  Matt_SFM Christoph HartC 2 Replies Last reply Reply Quote 0
                  • Matt_SFM
                    Matt_SF @tomekslesicki
                    last edited by

                    @tomekslesicki which commit are you using? IIRC Christophe fixed the scriptnode param number bug recently.

                    Develop branch
                    Win10 & VS17 / Ventura & Xcode 14. 3

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

                      @tomekslesicki said in An efficient way to script functions for multiple knobs?:

                      By the way - can I use the method you suggested here to change the width of multiple panels as well?

                      Of course. Also you can automatically create those arrays of UI components when you have selected more than one and use the „Create script variable declaration“ function in the context menu.

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

                        @Matt_SF oh, really? I'd have to check the most recent ones then!

                        @Christoph-Hart I know this, love it and use it daily! I just guess my assumption that something like this:

                        Content.setPropertiesFromJSON(Panel[idx], {
                        "width": fancynumber
                        });
                        

                        ...would work is not correct so I bet I'm missing something very obvious.

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

                        36

                        Online

                        1.8k

                        Users

                        12.1k

                        Topics

                        105.0k

                        Posts