HISE Logo Forum
    • Categories
    • Register
    • Login

    A way to make preset up and down buttons? (SOLVED)

    Scheduled Pinned Locked Moved General Questions
    44 Posts 6 Posters 2.6k 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.
    • SteveRiggsS
      SteveRiggs
      last edited by SteveRiggs

      Hi guys,

      Whats the best way to make preset up and down buttons?

      Screen Shot 2019-10-18 at 18.37.37.png

      www.anarchyaudioworx.com

      www.facebook.com/groups/audioworx/

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

        @SteveRiggs I have this code for scrolling through a cmb:
        using 2 btns, prev and next
        the "count" variabel is how many items there is in the cmb

        //  Previous & Next -------------------------------------
        
        inline function onPrevBtnControl(component, value)
        {
            if(value == 1)
            {
                if(scalesCmb.getValue() == 1)
                {
                    scalesCmb.setValue(count);
                }
                else
                {
                    scalesCmb.setValue(scalesCmb.getValue()-1);
                }
                scalesCmb.changed();
            }
        };
        
        Content.getComponent("PrevBtn").setControlCallback(onPrevBtnControl);
        
        inline function onNextBtnControl(component, value)
        {
            if(value == 1)
            {
                if(scalesCmb.getValue() == count)
                {
                    scalesCmb.setValue(1);
                }
                else
                {
                    scalesCmb.setValue(scalesCmb.getValue()+1);
                }
                scalesCmb.changed();
            }
        };
        
        Content.getComponent("NextBtn").setControlCallback(onNextBtnControl);
        
        

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

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

          @SteveRiggs I just realised that maybe you didn't ask for a code example, but for how to make the GUI stuff like on the picture? :)
          If so, sorry

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

          SteveRiggsS 2 Replies Last reply Reply Quote 1
          • SteveRiggsS
            SteveRiggs @ulrik
            last edited by SteveRiggs

            @ulrik Thats perfect mate thankyou!

            Hopefully this should work with the way I have my project set up as there is a hidden cmb with the sample maps in there, and then I have a label which shows the current preset name.

            I assume that I just need to change the name of 'scalesCmb' to the name of my combo box and it should work? :)

            www.anarchyaudioworx.com

            www.facebook.com/groups/audioworx/

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

              @ulrik With the count variable, do I need to replace the word 'count' with the number of presets I have?

              www.anarchyaudioworx.com

              www.facebook.com/groups/audioworx/

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

                @SteveRiggs Yes to both questions, the count, or number if you want, will do so that if you have the last item selected in the cmb and press "next", it will jump back to the first item

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

                SteveRiggsS 1 Reply Last reply Reply Quote 1
                • SteveRiggsS
                  SteveRiggs @ulrik
                  last edited by

                  @ulrik Brilliant mate. Thankyou! :)

                  www.anarchyaudioworx.com

                  www.facebook.com/groups/audioworx/

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

                    @SteveRiggs I'm glad I could help, good luck with your project!

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

                    SteveRiggsS 1 Reply Last reply Reply Quote 1
                    • SteveRiggsS
                      SteveRiggs @ulrik
                      last edited by

                      @ulrik Hey man, I finally got around to trying this out but I can't get it to work. It's giving me these errors in the console:

                      Interface:! Line 27, column 30: Unknown function 'getValue' {SW50ZXJmYWNlfHw1Nzd8Mjd8MzA=}
                      Interface:! Line 9, column 30: Unknown function 'getValue' {SW50ZXJmYWNlfHwyMDd8OXwzMA==}
                      

                      I just realized as well the way that my projects are set up, I don't usually have a combo box attached to preset browsers with a list of presets in, apart from in my sampled instruments where the combo box just changes the sample map but not the actual preset itself (so even if I did find a way to link them then no parameters would change on the GUI).

                      I'm not sure how this method would work now for going up and down presets on effects plugins with no combo box, or with a synth vst with no items in a combo box, or even on the sampled instruments.

                      I made a snippet here anyway below just to test it and added 2 things into the combo box list (even though they aren't linked to the preset browser yet) but I'm still getting the 2 errors and it doesn't switch between the 2 items.

                      I used the same names as the ones in your code for the components just for this test, and I changed the word "count" to "2" to reflect the 2 items in the list.

                      Any idea what's gone wrong? Or any idea how I'd be able to use it to change presets anyway? At the moment I'm not sure how to link a combo box to items in the preset browser and sub folders.

                      It's also confusing me that if a new preset is added, if the "count" number has to be changed manually in the code for it to work, if I add new presets during development then do I have to manually change the "count" number every time to match how many presets are there? That could get difficult if there are multiple folders and I would end up losing track how many along the way... and also if a user added a preset in the exported plugin then the number would also change and obviously they wouldn't be able to change the code then to match. Surely every time a new preset is added or the name is edited it doesn't have to be manually written into a combo box list? 🤔

                      Apologies for the lengthy message. This was top of my job list for today to add this to all of my projects to flick up and down between presets in the preset browsers, but I don't see how it works now if some are effects plugins, some are synths, and some are sampled instruments.. and the only ones that use combo boxes are the sampled instruments and they only change the sample maps anyway, not the preset.

                      Confusing stuff 🤣

                      Any help would be massively appreciated as I'm totally lost now lol

                      Thanks man. Here's my test snippet here anyway:

                      HiseSnippet 1187.3ocsW0saaaCElJIboVoYsEXO.B4hAazjVIme61BhqcRFBZSpwravtqiVh1lHRjFRTIwnH.cuI6QY2sa6iReC1NThxRNwNy0nQWId9ie56b3gG0LT3RihDgHiRsGNfhLdLt0Ptrei9DFGcxgHimiaFRuz5L50RK3sHpz58CrHbOqCEWwspGKkBdjU6iZ0FUe3.RTD0CYXr3upBfQokPIOe4f5DeB2klKBgNWvboukEvj4RaV6MLe+iIdz1rfBVuUsSbE7FBeQL.1Ew1nAD2KH8nmQTls.FY7cG4wjhvVRhjFgLVptvaXq9.HSs+bVDqiOUsvA0BBTp3iE9dJDqjhZzm460LiThPPTZlSQKlRQ+.9TlGaj7bp5oIJrx8nHeXrv8AOmhvyd1gmQA3sTJ7dFtkaHafLWiBaqfOgKogcIPJnHrRsEsvxKgaH.K3xWDPtfdbHrXjGk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Ce1YN7Y24vm8tWeT+P2qikhfziIfflGkdehwQbBTkkTQh9OX+MAPO
                      

                      www.anarchyaudioworx.com

                      www.facebook.com/groups/audioworx/

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

                        @SteveRiggs the code I showed is for a comboBox and I guess it will not work for a presetmanager, I guess they work different.
                        I just wanted to show you how the way was setup for changing presets in a cmb, then you have to see if it could be applied to a presetmanager.
                        I think there is examples, of how to setup a preset preview and next buttons, in Hise source code... I will check

                        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

                          @SteveRiggs check this BasicSynth example:
                          https://github.com/christophhart/hise_tutorial/tree/master/BasicSynth

                          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

                            @SteveRiggs you've forgotten to declare the cmb, paste this line in your initCallback

                            const var scalesCmb = Content.getComponent("scalesCmb");
                            

                            Then the cmb will work :)

                            About the "count" variabel, in my code it will dynamically count how many presets there is inside the cmb, so to answer you question, yes it has to be the exact number of presets.

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

                            SteveRiggsS 1 Reply Last reply Reply Quote 1
                            • SteveRiggsS
                              SteveRiggs @ulrik
                              last edited by

                              @ulrik said in A way to make preset up and down buttons?:

                              you've forgotten to declare the cmb

                              Ah. I did wonder why that wasn't there. I just copied and pasted the code exactly as it was to test it quick. My bad.

                              @ulrik said in A way to make preset up and down buttons?:

                              check this BasicSynth example:

                              I just check this example but it doesn't include preset up and down buttons. I found one in the music box tutorial but that looks as if its all json stuff which I don't really understand :( It json even still being used?

                              I was hoping to just make 2 buttons and add them into my existing projects and somehow link them to the preset browser to switch previous to next.

                              I'm wondering if these parts below from the customUserPresets tutorial can be picked apart and applied somehow? I can see in there that a list can be created automatically from the user presets, but they're loaded into a viewport then. Trying to work out a way.....

                              // This gets a list of all available user presets
                              const var list = Engine.getUserPresetList();
                              
                              /** removes the directory names from the path. */
                              inline function getPresetName(relativePath)
                              {
                                  local l = relativePath.split("/");
                                  
                                  if(l.length == 3)
                                      return l[2];
                                      
                                  return "";
                              }
                              
                              const var prettyList = [];
                              prettyList.reserve(list.length);
                              
                              // Copy the preset names without the paths into a new array
                              for(i in list) prettyList.push(getPresetName(i));
                              
                              
                              // Load the pretty names into a viewport list
                              const var PresetListSelector = Content.getComponent("PresetListSelector");
                              PresetListSelector.set("items", prettyList.join("\n"));
                              
                              
                              inline function onPresetListSelectorControl(component, value)
                              {
                                  // Grab the preset name from the array and load it.
                              	Engine.loadUserPreset(list[value]);
                                  
                              };
                              
                              PresetListSelector.setControlCallback(onPresetListSelectorControl);
                              
                              

                              www.anarchyaudioworx.com

                              www.facebook.com/groups/audioworx/

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

                                Just add two buttons and put the loadNextPreset and loadPreviousPreset functions in their respective callbacks.

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

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

                                  @SteveRiggs what Dave says...

                                  like this(ish) where I have a button called myPresetName to display the preset name:

                                  
                                  const var myPresetName = Content.getComponent("myPresetName");
                                  
                                  inline function onNextUserPresetControl(component, value)
                                  {
                                  	//next preset.
                                  
                                  	Engine.loadNextUserPreset(false);
                                  	myPresetName.set("text", Engine.getCurrentUserPresetName());
                                  
                                  };
                                  
                                  Content.getComponent("NextUserPreset").setControlCallback(onNextUserPresetControl);
                                  
                                  
                                  inline function onPrevUserPresetControl(component, value)
                                  {
                                  	//prev preset
                                  
                                  	Engine.loadPreviousUserPreset(false) ;
                                  	myPresetName.set("text", Engine.getCurrentUserPresetName());
                                  
                                  };
                                  
                                  Content.getComponent("PrevUserPreset").setControlCallback(onPrevUserPresetControl);
                                  
                                  

                                  HISE Development for hire.
                                  www.channelrobot.com

                                  SteveRiggsS 2 Replies Last reply Reply Quote 1
                                  • SteveRiggsS
                                    SteveRiggs @Lindon
                                    last edited by

                                    @Lindon @d-healey

                                    Cheers fellas. I just tried this way but HISE instantly crashes as soon as I hit compile.

                                    Content.getComponent("NextBtn").setControlCallback(onNextBtnControl);
                                    
                                    inline function onNextBtnControl(component, value)
                                    {
                                         Engine.loadNextUserPreset(false);
                                    };
                                    
                                    
                                    Content.getComponent("PrevBtn").setControlCallback(onPrevBtnControl);
                                    
                                    inline function onPrevBtnControl(component, value)
                                    {
                                         Engine.loadPreviousUserPreset(false);
                                    };
                                    

                                    www.anarchyaudioworx.com

                                    www.facebook.com/groups/audioworx/

                                    ulrikU 1 Reply Last reply Reply Quote 0
                                    • SteveRiggsS
                                      SteveRiggs @Lindon
                                      last edited by

                                      @Lindon The same crash happens as soon as I hit compile on your code as well

                                      www.anarchyaudioworx.com

                                      www.facebook.com/groups/audioworx/

                                      1 Reply Last reply Reply Quote 0
                                      • SteveRiggsS
                                        SteveRiggs
                                        last edited by SteveRiggs

                                        @Lindon @d-healey @ulrik

                                        Snippet here but it wont let me compile it. HISE just closes as soon as I push compile :(

                                        HiseSnippet 1052.3ocsV0saaaCElxIbc1sdcEX6dgbkCVVfTh+IccC00+MXzkTiYmhdWAsDsMQjHMnnRhQQ.5dS1ixta2tGk8FrcnjrkbhsmgwhtRjmy2ge7vuygrmT3PCBDRjQ9AylRQFOC2eFWMo4DBii51BY7c3dR50lWPuUYB+EPUlWN0jvcMaItga1HToD7.yAs6O.0X1TRP.0EYXr2OqCfQ98QQe+8qaP7HbGZ5THz6ELG5uv7YpzY6U+sLOuNDW5.leFuKWuqif2T3IBAxtG1BMk3bEYL8Bh1sbXjwWz1koDx9JhhFfL1ugvcV+I.Ii8+8r.1POpdfMpODn3o6H7b0LVOKp4Dlmau4Ik.DDkdoon8hSQeC9blKaw7oopuNxfYJhr4Cibahd1Yom01SOiLza+X58BbeGIapJ0hlaOE2kqnxQD3HHKsh8Ek6aygaJ.O3pi8IWQ6HgAKPTppk0QlUrrN7UEKTrvbGGSUME9SEbXPoCzJjFJ9AGdbfddtRJ7ZR77FBmSkD7DyIFN7UEJv3dLN0bTH2QwDby66SIm4A+HyqIdgzCK7oBl5u17w.xi8DDWMjKCnxXoYoQDu.JD76f3uFdpkyafmIl2HOW1mshmZHLQXvJ4Z1TfPQeGujND4KbWAy6aZznUZKgJdT4JMqqkjaBXIdn+PpLyFHxQPTsrpEudUa1hJm3LeFGE7tbl5cSo70okQIGWfpduDVA+ohzzeUhltuGykJQLP59D7a4hg1nHBmzm3y+Tg+70n0ANtUUD373jivkfG+sUvSTpq.9kcaQTDcoYx9A1iSoRESm9LZAp.GZbgZdbKZvUJwTHKuPeB++etkuMcAeS8YoCpTGkINOUkzsJNNc.UnhwGOfAGW5n8b7zHcXCo3FPTlMpkyD0OOn9MLW0jES7G+V8IT13IoMs+qaqmrWi2XOG2aoHOb7791OCW1tpUsxurR0yPLE0OigSNqV0Z0rO6zLFNI1xKA.111UPQoVieG+ohPA1AZ4Uex0z3SlC9ASkLjdzBSQsNkqwntXJ3AypE6I2n8vvQtVHApouGZIiWDpYaneDlSKV3NT1igmrEhvzTec1xGnKm5gyh6k5Q+XcVv4BeXoHxYyKs1tUetFNypK+eX0e3MRv8hB2POhZ4KK0uPHw.zKZoakz27vCXpYYeAwixMnaKceAtGS4LY07M2J3KzA3wluIuGoHt8nQTGUJY2G24CO9O9.8qhPcGkyIJICDQXnPnOTz5PAlv4TO88EF4zsTiGaoGqyL8ob2nA+C7kXzVO1Hwn8biHehiT7Qm3dx5W77kQy.bhG8vu73y0iMWbQ.FacrExGdH1GcbzohuG39pwbxNf4zc.S4c.Skc.S0c.Ssc.yYaDi9MvuITI7iKSfI50NtusQaNATYQJRz+Ry8jIL
                                        

                                        www.anarchyaudioworx.com

                                        www.facebook.com/groups/audioworx/

                                        d.healeyD LindonL 2 Replies Last reply Reply Quote 0
                                        • ulrikU
                                          ulrik @SteveRiggs
                                          last edited by

                                          @SteveRiggs said in A way to make preset up and down buttons?:

                                          > inline function onNextBtnControl(component, value)
                                          > {
                                          >      Engine.loadNextUserPreset(false);
                                          > };
                                          

                                          Why have you set it to false, it should be set to true if you want it to load next or previous preset I think.

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

                                          LindonL d.healeyD 2 Replies Last reply Reply Quote 0
                                          • LindonL
                                            Lindon @ulrik
                                            last edited by

                                            @ulrik please read the documentation.....BEFORE you comment (yeah I know I do that too sometimes - silly me)

                                            false here is (bool stayInDirectory) not do or not do....

                                            HISE Development for hire.
                                            www.channelrobot.com

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

                                            48

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.9k

                                            Posts