HISE Logo Forum
    • Categories
    • Register
    • Login

    3 buttons, 3 panels, and lots of potential scripting...

    Scheduled Pinned Locked Moved General Questions
    18 Posts 5 Posters 714 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.
    • DanHD
      DanH @Matt_SF
      last edited by

      @Matt_SF I can't figure it out 😆 Let me know if you have any more brainwaves!

      DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
      https://dhplugins.com/ | https://dcbreaks.com/
      London, UK

      d.healeyD Matt_SFM 2 Replies Last reply Reply Quote 0
      • d.healeyD
        d.healey @DanH
        last edited by

        @DanH I'm on it

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

        1 Reply Last reply Reply Quote 0
        • Matt_SFM
          Matt_SF @DanH
          last edited by

          @DanH funny how it seems so simple at first.

          If you, HISE master who sees this post and has the answer, please send it to Dan in PM, I want to figure it on my own! 😂

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

            @DanH try this

            HiseSnippet 1210.3ocsWE2SaaDE+LfY3r0o0o8Avi+JoPgD6ttJwpVJAXBsAjsvPqZZp5h8kjS3bmk8kBQSHsOJ8ix9H0uAr2c9brM0wPRWif.26898teue97cuqaD2iDGyiPFVmOMjfL9BydSYhQcFgoLzwGHMDhYj.aAIVf1eZHNNl3iLLV8mjQXXsFR848+393.LyijYBgtfS8H+BcLUjYsa6elFDbD1mbNcbtneV6i83rN7.9DfMqZ1DEh8tDOjbJVF1JlHi0OzmJ3Q8DXfLHi01m6Os2H9Urj3ufFS6GPjCZg5AIJw7Q7.eIikVQcFQC76lV0wHHKcyzfUSzfuw7DpOcl8Ls3qTNryPjWOLVoH8Vs.8ZkmdMyQuRnjQNJsVBkdrYOuHZnHyijOet4wLAIZ.Fj87TIIVzJ89LyNbHBlXmw3KIGEAClgn9ya1baa3qF6UqFH8w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2oIZLbmy234IK+mBmRTNFmk.i6Rf4YKAluaIv77k.y2uDXdQkXjW2+USD7wIuN.F5dn5jLCiCYXXkkZUH5+.d1P0C.
            

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

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

              @ulrik You're making good use of that getAllComponents function again. I need to do that more.

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

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

                @d-healey yes it's handy, but it's easy to unintentionally collect wrong components if you're not certain of how you named the components

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

                DanHD Matt_SFM 2 Replies Last reply Reply Quote 0
                • DanHD
                  DanH @ulrik
                  last edited by

                  @ulrik brilliant, thank you!

                  so .getAllComponents will give me an array of all named components? Eg. Panel1, Panel2 etc ?

                  DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                  https://dhplugins.com/ | https://dcbreaks.com/
                  London, UK

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

                    @ulrik Elegant!
                    @DanH Content.getAllComponents returns all components whichs name matche the string you pass in the function.

                    I.e. Content.getAllComponents("pnl_") will retreive all components which have "pnl_" in their name. Obvisouly you have to be consistent in the naming of your GUI elements but it's quite handy :)

                    LindonL 1 Reply Last reply Reply Quote 0
                    • LindonL
                      Lindon @Matt_SF
                      last edited by Lindon

                      @Matt_SF said in 3 buttons, 3 panels, and lots of potential scripting...:

                      @ulrik Elegant!
                      @DanH Content.getAllComponents returns all components whichs name matche the string you pass in the function.

                      I.e. Content.getAllComponents("pnl_") will retreive all components which have "pnl_" in their name. Obvisouly you have to be consistent in the naming of your GUI elements but it's quite handy :)

                      to be honest I prefer this naming approach;
                      Button_01
                      Button_02
                      Button_03
                      etc.

                      and then load in a sequenced and ordered way into my array

                      const var NUM_VOICES = 4; //some number of voices
                      const var myButtonArray = [];
                      myButtonArray.reserve(NUM_VOICES)
                      
                      for(i=0;i<NUM_VOICES; i++)
                      {
                          myButtonArray[i] = Content.getComponent("Button_0" + (i+1));
                          myButtonArray[i].setControlCallback(onMyButtonControl);
                      }
                      

                      This gives me everyone in the array in the correct sequenced order....and lets assume these buttons are turning some filter on or off, I can also add the filter itself(again in the right order):

                      const var NUM_VOICES = 4; //some number of voices
                      const var myButtonArray = [];
                      myButtonArray.reserve(NUM_VOICES)
                      const var myFilterArray = [];
                      myFilterArray.reserve(NUM_VOICES)
                      
                      for(i=0;i<NUM_VOICES; i++)
                      {
                          myButtonArray[i] = Content.getComponent("Button_0" + (i+1));
                          myButtonArray[i].setControlCallback(onMyButtonControl);
                          myFilterArray[i] = Synth.getEffect("Filter" + (i+1));
                      }
                      

                      which means the callback for the button only needs to be this:

                      inline function onMyButtonControl(component, value)
                      {
                          local pos = myButtonArray.indexOf(component);
                          myFilterArray[pos].setBypassed(1-value);
                      }
                      

                      always interested in a faster - cleaner- better way if someone has one...

                      HISE Development for hire.
                      www.channelrobot.com

                      Matt_SFM 1 Reply Last reply Reply Quote 0
                      • Matt_SFM
                        Matt_SF @Lindon
                        last edited by

                        @Lindon if your elements are numbered the function will sort them automatically. I usualy don't number them and I also liketo have control on my elements (like the script you wrote) but sometimes it can be useful to get all of typed elements quickly.

                        1 Reply Last reply Reply Quote 0
                        • Matt_SFM
                          Matt_SF
                          last edited by

                          This post is deleted!
                          1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey
                            last edited by d.healey

                            I rarely put the full type of component in the component id, it seems redundant to call a button button.

                            I use a prefix to describe the type of component followed by a name that describes the button's function, if the button is part of a group of buttons I follow this with a number, almost always indexed from 0.

                            So I could have 10 buttons that toggle 10 panels, I might call them btnToggle0, btnToggle1, etc.

                            Then I could use either the loop technique or the getAllComponents technique to populate an array of references. I usually use the loop technique because most of the time I will also assign a LAF object and callback to the controls at the same time. From now on I think I'll be using the getAllComponents function when I only need a reference.

                            The getAll... functions are also useful when you want to loop over a set of components/modules that you haven't stored references to already. For example if I had 5 filter effects and I wanted to change a parameter on all of them but I have no other need to keep references to them:

                            for (x in Synth.getAllEffects("filter"))
                            {
                               // Do the thing
                            }
                            

                            The getAll... functions don't require additional allocation (as far as I know) so they are safe to use at runtime. By contrast you don't want to use Content.getComponent() at runtime.

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

                            Matt_SFM 1 Reply Last reply Reply Quote 2
                            • Matt_SFM
                              Matt_SF @d.healey
                              last edited by

                              @d-healey said in 3 buttons, 3 panels, and lots of potential scripting...:

                              The getAll... functions don't require additional allocation (as far as I know) so they are safe to use at runtime. By contrast you don't want to use Content.getComponent() at runtime.

                              Good to know 👍

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

                              22

                              Online

                              1.7k

                              Users

                              11.9k

                              Topics

                              103.7k

                              Posts