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.
    • orangeO
      orange @tomekslesicki
      last edited by orange

      @tomekslesicki

      I have no idea why you need to use the setValue instead using the setAttribute to modulate the module directly, but the below method is what you need here. I used setAttribute, you can change it to setValue if you'd like.

      HiseSnippet 1071.3oc6X8taaaCDmJ1bq1asncXO.DE6CJHYoxIcsCnaXNwNYvnKIByYYcnnHiVhNlHTjBRTYynnua6QZuAaGkTrjcjS87V6xFr9fs48Gd+9c7NRJ6Fo7XwwpHjUiSFGxPVeLt+XodTmQTtD0qKx5d3CowZVDISzdiCowwLejkUsu0HvpQcT5yu+M6QEToGqPDBcph6w9Nd.WWH0s8y4BwATe1I7fRV+3187TxNJgJAvSMrCJj5cA8b1QTiYqgQVev99bsJpulpYwHq56o7G2ej5WjY1eJOlOPvLCZg5CSTl3CTBeChMRQcFwE9tWw6XDLKtEYgZYYgOEeH2mOQdQ139oJHEdTNeXs1zvq1TvqUY34TBdU.IqRPpdFjd.tuWDOTWnwfmOB2SBKNCoPZuLTxrEs1F0vcTfER8VAzKXGDACl3g8NNNaRfOV+YMa9nGQ1MJhNl4SdtTMHtIrVDqIzLYmYjQ9ZxKeEX5PUDwlCibdFgS9JxNvWarw5MecSB7T1isBShGYeEBNmo6nBBURXf8CM5eHYCBecH7y53K4uZqXi4RcjRzgJDCfZAakrrQ4ZA2eSyoHfKMBJY.VNKK5yCBELSc6aiKW2iLtj1cXXx9CGx7.ZTXvTjI8ICUGKITIgKEbIiLLQ5o4JIQqfIYDKp4rJpji1dWk31jbIUjvfrcVHLeLORXz85FSLqw0IUdddWsNhOHQyrq1Dy2adsEHf.mZvhMPZREOoA8MkEXVmJQziTZ1wRaSkSCPGYVUCGVot7bhfEUoZytJQ2ji1xjfArnhLYlgPq1z8u342+Vd6Eurx6RFpj8jb8wgL471zAk2S.850xQE7KcZm98x6z6K39rHDGZn+PrIm6fRAb48WQKrys96371U37OzqKUSMaVkyEfegrHM2j5r5xtD14OaqqF3tr3KzpvTxlWGCS8akt+ZQ.Oo83hAG0Nn7IO+zuEPKY5mAZ88ELWUL2rvOCkW332Zdwu8O+dI9aOW9yW93e8CVfizT9IBpd5y4Ls74JLyQ4CWLGfHg4db4C++G6vuEEhO.6x0dipFiqUAFgR02EXL+JC2EmchPA.qiO3EuitePsRw+NSt31jsrSC+cKIv4Ft2FB0kInSkm9QtudTo5q1UbytdxKglcWkfFMaVt1BSyV2LMquvkBoGoeqtb8Svoo4a6fLco+1MHuO1k9u0h82qRzb44GRg6KAa4hOJInO75JdL.dRISXt0f0Zl84yF6XFa.QelzOcve.O4JaYFakqr0UJQ+E6sasp2dUu8pd6+W1au8pd6U81q5s+uQu86iXDP8hTm4k8d6lVs6jJA3sL8OIsA9PyXxj21Gic1xAAuPH+LOOy6j74sPnp8Y6kvmcVBed7R3yWrD97jkvmmtD97k2nOl+u3cSzpfrZdPf69o+wIVV6KoP0aZ4O5OQG2DD1
      

      develop Branch / XCode 13.1
      macOS Monterey / M1 Max

      d.healeyD 1 Reply Last reply Reply Quote 0
      • 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.5BrS69APwPcicRgQWRLlx51vPQKsDULgoHEjnxhwvdk1yPeT5SPQeC5NRIaIkY64ZrUrfY8GFl7ti22c9iejVCikdzjDYLxp4YSinHqOE6NUnF2aLgIPC5irtE9XRhhF6jM0ASiHIITejkU8mnmvpYCj44sO5.BmH7nESgPOSx7neGKjoJlcX2mx37iH9zyXgk79AcG3IE8jbYJfm531nHh2Dx4zSHZ2pgQVezg9LkL1UQTzDjUiCj9ScGK+UQl+OikvFwo5AcPtvBkM8QRtuFw5YQ8Fy39CmU2IHXUFVzEpm0E9b7wLe174K5F21XvoHhx8CqZUgW8JvqSY30tD7V.jrJAoFYP5NXWuXVjpvhFOeBdf.9wIf.s8xPIyWTs50v8jfGB0dgjIzihgAyin08a29dNvG69Paan0mnblHFk37sNyh4bp5wbdOYXjT.iSZc2mJjitK3el6mC8Es+FNSt2GFDP8zt5xBi3TMIQGfMSvYBpSPpvSwjBGoPmLclhk7Vdyxw8btfvSo6Z+aN5Ga8GboGg6vD9zKgjoCaOyfSCJhCRwb+Mv5WLt778R.ToTwrQoJZqJVzPaV5dnS1i8uaaGHicZMAxmIU6Z2bhdQxQZOBmOB3kspfeH6kJrSjJ5ohVPMX2DVPmqZJHXg1xWKNMdgl06VhWUfsDoginwEcvLGAJTUdId47xxaa7xHAkbTJFHXpSinhksYBkyb.Nb8bTAeSYXv2JmA6xY9zXDCHpeLVymZiL.tPIXmtn0N3NUB14OdxNuZ8Cd+JA+xff27HzOLnOQQzaByqEn9hnwJlt0Y0mdAnnkskrItOMYhRFYJ1bdHrz+sk6kEk5YcmVL3jtgkUT+4WERtrbWIj46yoCkIL8O7k0YQuG4uyxxe2W9AI+6uz5ms44+uJXBR0R+TNQUU+VuoO2fdMJKZpEFEvZOs7gZWUTuw5Ipu5ybVW3dG7Plxa7hwasEfWf19uMdyOh7l3Lg9Bv1.ezOsomG1Y0mGVuT9uw7KpL+7ES5uYoIZuh6orS29TNoRO6GY9pwk3ccWvMYFHt.DAFJ4j3q1wq+OUY1XsoE5Rx4ZCM9yvlV90I.anDWe.7swCI+WfP78xTESb9wD3BWfzM9jzPW357dT.pBAkqu8gUM84EYiaqGqAjKU3aF7N3I2XG8XqbiclYD8dpEzYYZAl6JrUKXqVvVsf+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

                          40

                          Online

                          1.8k

                          Users

                          12.1k

                          Topics

                          105.1k

                          Posts