HISE Logo Forum
    • Categories
    • Register
    • Login

    Change Sample map via Prev-Next Button

    Scheduled Pinned Locked Moved General Questions
    37 Posts 6 Posters 1.5k 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.
    • ?
      A Former User
      last edited by A Former User

      I've found the easiest way to approach + - buttons for ComboBoxes, is to just have the buttons adjust the ComboBox, instead of trying to call modified versions of the ComboBox's function:

      inline function onprevControl(component, value)
      {
          if (value)
          {
              cmbsmp.setValue(cmbsmp.getValue() - 1);
              cmbsmp.changed();
          }
      };
      
      LindonL Tania GhoshT 2 Replies Last reply Reply Quote 0
      • LindonL
        Lindon @A Former User
        last edited by

        @iamlamprey said in Change Sample map via Prev-Next Button:

        I've found the easiest way to approach + - buttons for ComboBoxes, is to just have the buttons adjust the ComboBox, instead of trying to call modified versions of the ComboBox's function:

        inline function onprevControl(component, value)
        {
            if (value)
            {
                cmbsmp.setValue(cmbsmp.getValue() - 1);
                cmbsmp.changed();
            }
        };
        

        does this wrap round?

        HISE Development for hire.
        www.channelrobot.com

        ? Tania GhoshT 2 Replies Last reply Reply Quote 0
        • ?
          A Former User @Lindon
          last edited by

          @Lindon I don't know what wrap around means 😲

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User
            last edited by A Former User

            Here's an example of implementation:

            In this case it's allowing a RR group based on the ComboBox, but it should work for samplemaps

            Edit: forgot to mention to add checks for min/max value of the combobox, otherwise your + - buttons will go to infinite :)

            Tania GhoshT 1 Reply Last reply Reply Quote 0
            • Tania GhoshT
              Tania Ghosh @Lindon
              last edited by

              @Lindon said in Change Sample map via Prev-Next Button:

              if (value)
              {
              cmbsmp.setValue(cmbsmp.getValue() - 1);
              cmbsmp.changed();
              }

              Thank you @Lindon it is working but doesn't stop when it reaches the First and last sampleMap. Instead it is going beyond. And ends up with the error.

              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
              
              

              Tania Ghosh

              1 Reply Last reply Reply Quote 0
              • Tania GhoshT
                Tania Ghosh @A Former User
                last edited by

                @iamlamprey Exactly it is not stopping. Going beyond.And ends up with the error.

                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                Interface:! Line 17, column 24: API call with undefined parameter 0 {SW50ZXJmYWNlfHw0Mjl8MTd8MjQ=}
                
                

                Tania Ghosh

                1 Reply Last reply Reply Quote 0
                • Tania GhoshT
                  Tania Ghosh @A Former User
                  last edited by

                  @iamlamprey Can you edit the code? please :)

                  Tania Ghosh

                  ? 1 Reply Last reply Reply Quote 0
                  • ?
                    A Former User @Tania Ghosh
                    last edited by A Former User

                    @Tania-Ghosh I just used a nested if statement

                    if (value)
                    {
                        if (cmbsmp.getValue > 1)
                        {
                            cmbsmp.setValue(cmbsmp.getValue() - 1);
                            cmbsmp.changed();
                        }
                        else
                        {
                            cmbsmp.setValue(whateveryourmaxvalueishere);
                            cmbsmp.changed();
                        } 
                    }
                    

                    Then do the opposite on the + button, if it's reached your max value, then go back to 1

                    in my case i just ignored the event if it would otherwise go "out of bounds", instead of wrapping round (i guess that's what Lindon meant)

                    Tania GhoshT d.healeyD LindonL 3 Replies Last reply Reply Quote 0
                    • Tania GhoshT
                      Tania Ghosh @A Former User
                      last edited by

                      @iamlamprey said in Change Sample map via Prev-Next Button:

                      cmbsmp.getValue > 1

                      Superb... :) Thank you :)

                      Tania Ghosh

                      1 Reply Last reply Reply Quote 0
                      • d.healeyD
                        d.healey @A Former User
                        last edited by

                        if (value)
                        {
                            cmbsmp.getValue > 1 ? cmbsmp.setValue(cmbsmp.getValue() - 1) : cmbsmp.setValue(whateveryourmaxvalueishere);
                            cmbsmp.changed();
                        }
                        

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

                        Tania GhoshT 1 Reply Last reply Reply Quote 0
                        • Tania GhoshT
                          Tania Ghosh @d.healey
                          last edited by Tania Ghosh

                          @d-healey @iamlamprey
                          Can you correct the code?

                          Content.makeFrontInterface(500, 400);
                          const var Sampler1 = Synth.getSampler("Sampler1");
                          const var prev = Content.getComponent("prev");
                          const var next = Content.getComponent("next");
                          
                          
                          
                          
                          const var smpmap = Sampler.getSampleMapList();
                          const var cmbsmp = Content.getComponent("cmbsmp"); //ComboBox
                          
                          cmbsmp.set("items",smpmap.join("\n"));
                          
                          
                          inline function oncmbsmpControl(component, value)
                          {
                          	Sampler1.loadSampleMap( smpmap[value-1]);
                          };
                          
                          Content.getComponent("cmbsmp").setControlCallback(oncmbsmpControl);
                          
                          
                          inline function onprevControl(component, value)
                          {
                          if (value)
                          {
                              cmbsmp.getValue > 1 ? cmbsmp.setValue(cmbsmp.getValue() - 1) : cmbsmp.setValue(1);
                              cmbsmp.changed();
                          }
                          };
                          
                          Content.getComponent("prev").setControlCallback(onprevControl);
                          
                          
                          
                          inline function onnextControl(component, value)
                          {
                          if (value)
                          {
                              cmbsmp.getValue > 1 ? cmbsmp.setValue(cmbsmp.getValue() + 1) : cmbsmp.setValue(4);
                              cmbsmp.changed();
                          }
                          };
                          
                          Content.getComponent("next").setControlCallback(onnextControl);
                          
                          

                          Currently I have 4 sample Maps. It is working but only two steps.

                          Tania Ghosh

                          ? 1 Reply Last reply Reply Quote 0
                          • LindonL
                            Lindon @A Former User
                            last edited by

                            @iamlamprey said in Change Sample map via Prev-Next Button:

                            @Tania-Ghosh I just used a nested if statement

                            if (value)
                            {
                                if (cmbsmp.getValue > 1)
                                {
                                    cmbsmp.setValue(cmbsmp.getValue() - 1);
                                    cmbsmp.changed();
                                }
                                else
                                {
                                    cmbsmp.setValue(whateveryourmaxvalueishere);
                                    cmbsmp.changed();
                                } 
                            }
                            

                            Then do the opposite on the + button, if it's reached your max value, then go back to 1

                            in my case i just ignored the event if it would otherwise go "out of bounds", instead of wrapping round (i guess that's what Lindon meant)

                            thats what "wrap around" means....👍

                            HISE Development for hire.
                            www.channelrobot.com

                            1 Reply Last reply Reply Quote 0
                            • ?
                              A Former User @Tania Ghosh
                              last edited by

                              @Tania-Ghosh Hint: Both your previous and next buttons are checking for the same condition

                              @d-healey I really have to learn that single line if statement wizardry 😲

                              @Lindon took me a minute 🤣

                              Tania GhoshT 1 Reply Last reply Reply Quote 1
                              • Tania GhoshT
                                Tania Ghosh @A Former User
                                last edited by Tania Ghosh

                                @iamlamprey Thnaks i have modified the code. Now ERROR is

                                Interface:! Line 17, column 24: API call with undefined parameter 0
                                

                                Line no 17 Giving me the error. ComboBox and Buttons working to change sampleMaps but it is throwing ERROR after reaching out bounds/wrap around.

                                Content.makeFrontInterface(500, 400);
                                const var Sampler1 = Synth.getSampler("Sampler1");
                                const var prev = Content.getComponent("prev");
                                const var next = Content.getComponent("next");
                                
                                
                                
                                
                                const var smpmap = Sampler.getSampleMapList();
                                const var cmbsmp = Content.getComponent("cmbsmp"); //ComboBox
                                
                                cmbsmp.set("items",smpmap.join("\n"));
                                
                                
                                inline function oncmbsmpControl(component, value)
                                {
                                	Sampler1.loadSampleMap( smpmap[value-1]); //Throwing error
                                };
                                
                                Content.getComponent("cmbsmp").setControlCallback(oncmbsmpControl);
                                
                                
                                inline function onprevControl(component, value)
                                {
                                if (value)
                                {
                                    if (cmbsmp.getValue < 1)  // > didn't work so <
                                    {
                                        cmbsmp.setValue(cmbsmp.getValue() - 1);
                                        cmbsmp.changed();
                                        
                                    }
                                    else
                                    {
                                        cmbsmp.setValue(4); // I have 4 Sample maps 
                                        cmbsmp.changed();
                                    } 
                                }
                                };
                                
                                Content.getComponent("prev").setControlCallback(onprevControl);
                                
                                
                                
                                inline function onnextControl(component, value)
                                {
                                if (value)
                                {
                                    if (cmbsmp.getValue < 1) // Same here
                                    {
                                        cmbsmp.setValue(cmbsmp.getValue() + 1);
                                        cmbsmp.changed();
                                        
                                    }
                                    else
                                    {
                                        cmbsmp.setValue(4); // same here
                                        cmbsmp.changed();
                                    } 
                                    
                                    
                                }
                                };
                                 
                                Content.getComponent("next").setControlCallback(onnextControl);
                                

                                Tania Ghosh

                                ? ulrikU 2 Replies Last reply Reply Quote 0
                                • ?
                                  A Former User @Tania Ghosh
                                  last edited by A Former User

                                  @Tania-Ghosh add whatever functionality to your combobox

                                  HiseSnippet 1478.3oc4X80aSbDD+t3boXCAAHdnOzJsxpOXKfH6P.pf1hwNInnR.q3PDuAaNu1dE2s6o81K0oH9tzOBUpeA3iDeCZmc267s9hiwXnkpV+Rt4e69alc1YlMcEbeRbLW33V9vSiHNtWxq2oL4nNivTlyda639Md97vi4GyGiXjwRTjfbBhLFGFEPbZeZDNNlz2w0sziUV3VdUG8u2+v13.Lymjyxw4HN0m7DZHUlysaqelFDrKtO4PZnk1a0ZOeNqCOfm.nqjWCmHr+qwCIOEqTaEOG201oOUxE8jXII1wc0179m1aD+WXF8OhFSOF.IPzzoGrPF16xC5qPr5amNinA86lEEhcbb85lGSJYhIW2aeZe5D94wlqnEfxsvNd3tx7fWykDdtVvaUC7tpWOeAMRlKQgsK5sGSRDCv9SeLYz0Yk+XUuNbPClbiP7qI6J.hIVT6NMZbSzVMZT+AqWY8JvAQrDcBVf5oO2EMQ+HRmmrwPhTCRMUspYxqVzP+viiCi.yx1Tkg7vHNCHpU0H9LVoS1NOaTB0VjquNC87zWILcGVuBkEPYDzfDlujxYHNy.AkoBdPM+L6tIrvAIj5qW4MqWoLHNlGP1HRPUK4ginwnXsOiBwQn.NjG2+9npnajZFrcuUuky2u2HVwVu0cvAAGCo50J.oyG4p.wG.2zAnZYzH32aL+Q8yrIJbcjRgZ0Q+jEuZUCorp0QOLiWbldm0tagZVGc+4nH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NbKYl8UO9W.zTNvNkNFlvPAIn81+HnLD6K3uz27RJEVuflCfRl9+aYYu8UznlYugxyqwFMbBgdUuz2WcQ3VPDd11r4RXysWBa1ZIr4NKgM2cIr4dKgMe+bsQMlviRj7PSQRfQ2cLIVt6LIwpjyeA7fARUO
                                  
                                  Tania GhoshT 1 Reply Last reply Reply Quote 1
                                  • ulrikU
                                    ulrik @Tania Ghosh
                                    last edited by

                                    @Tania-Ghosh

                                    Content.makeFrontInterface(600, 500);
                                    const var Sampler1 = Synth.getSampler("Sampler1");
                                    const var prev = Content.getComponent("prev");
                                    const var next = Content.getComponent("next");
                                    
                                    const var smpmap = Sampler.getSampleMapList();
                                    const var cmbsmp = Content.getComponent("cmbsmp"); //ComboBox
                                    
                                    cmbsmp.set("items",smpmap.join("\n"));
                                    
                                    
                                    inline function oncmbsmpControl(component, value)
                                    {
                                    	Sampler1.loadSampleMap(smpmap[value-1]); //Throwing error
                                    };
                                    
                                    Content.getComponent("cmbsmp").setControlCallback(oncmbsmpControl);
                                    
                                    
                                    inline function onprevControl(component, value)
                                    {
                                        if (value)
                                        {
                                            cmbsmp.getValue() == 1 ? cmbsmp.setValue(smpmap.length): cmbsmp.setValue(cmbsmp.getValue() - 1);
                                            cmbsmp.changed();
                                        }
                                    };
                                    
                                    Content.getComponent("prev").setControlCallback(onprevControl);
                                    
                                    
                                    
                                    inline function onnextControl(component, value)
                                    {
                                        if (value)
                                        {
                                            cmbsmp.getValue() == smpmap.length ? cmbsmp.setValue(1): cmbsmp.setValue(cmbsmp.getValue() + 1);
                                            cmbsmp.changed();
                                        }
                                    };
                                     
                                    Content.getComponent("next").setControlCallback(onnextControl);
                                    

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

                                    Tania GhoshT 1 Reply Last reply Reply Quote 2
                                    • MikeBM
                                      MikeB
                                      last edited by

                                      This is exactly the function I am trying to code for the Audio Loop Player
                                      How can I implement this for it?

                                      "One hour of trial and error can save 10 minutes of reading the manual."
                                      "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                                      HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

                                      ? ulrikU 2 Replies Last reply Reply Quote 0
                                      • Tania GhoshT
                                        Tania Ghosh @ulrik
                                        last edited by

                                        @ulrik Yeahhhhh... Superb Thank you so very much :)
                                        Working perfectly.

                                        Tania Ghosh

                                        1 Reply Last reply Reply Quote 0
                                        • Tania GhoshT
                                          Tania Ghosh @A Former User
                                          last edited by

                                          @iamlamprey Awesome. Thank you :)

                                          Tania Ghosh

                                          1 Reply Last reply Reply Quote 1
                                          • ?
                                            A Former User @MikeB
                                            last edited by

                                            @MikeB I'm not familiar with the Audio Loop Player, what are you trying to do?

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

                                            13

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            103.2k

                                            Posts