Forum

    • Register
    • Login
    • Search
    • Categories

    Change Sample map via Prev-Next Button

    General Questions
    6
    37
    194
    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.
    • Tania Ghosh
      Tania Ghosh last edited by

      can you help me how to change sample maps via Prev-Next buttons?

      
      const var Sampler1 = Synth.getSampler("Sampler1");
      const var prev = Content.getComponent("prev"); //Pre Button
      const var next = Content.getComponent("next"); //Next Button
      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)
      {
      	Sampler1.loadSampleMap(smpmap[1-value]);
      };
      
      Content.getComponent("prev").setControlCallback(onprevControl);
      
      
      
      inline function onnextControl(component, value)
      {
      	Sampler1.loadSampleMap(smpmap[value]);
      };
      
      Content.getComponent("next").setControlCallback(onnextControl);
      
      

      Tania Ghosh

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

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

        inline function onprevControl(component, value)
        {
        Sampler1.loadSampleMap(smpmap[1-value]);
        };

        Content.getComponent("prev").setControlCallback(onprevControl);

        Well lets look at this bit of code:

        inline function onprevControl(component, value)
        {
        	Sampler1.loadSampleMap(smpmap[1-value]);
        };
        
        Content.getComponent("prev").setControlCallback(onprevControl);
        

        So you've got an array called smpmap filled with the names of the sample maps...

        The above is the call back from a BUTTON, what are the states of value for a button? - yep either on or off (also known as 0 or 1)

        so what is this line doing?

        	Sampler1.loadSampleMap(smpmap[1-value]);
        

        same for your next button callback.....

        HISE Development for hire.
        www.channelrobot.com

        Tania Ghosh 1 Reply Last reply Reply Quote 0
        • iamlamprey
          iamlamprey last edited by

          Also add

          if (value) 
          

          To any sort of momentary button functions to avoid unnecessarily calling them twice.

          New Song 🥰 - Instruments

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

            @Lindon Got it. That's why it is only going one step.
            Then what is the way to change sample map via button? is it possible?

            Tania Ghosh

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

              @iamlamprey Nice. Can I use for loop? I tried but unable to figure our how to & where to write.

              Tania Ghosh

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

                I guess changing samplemaps via Button / Scriptpanel is not possible for this moment. Because I didn't find any function like loadNextSamplemap & loadPrevSampleMap

                Tania Ghosh

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

                  @Tania-Ghosh Sure it's possible. You just need to store the index of the current sample map in a variable and increment/decrement that index when the button is clicked.

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

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

                    @d-healey Can I get a brief example sir ? please 🙂

                    Tania Ghosh

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

                      HiseSnippet 929.3ocsV01aaaCDlxwpaVatXEX+.35mrgabkSeYCvaXYwIYvnMIFycECnnnfghJlHTjBjTY0nH.8Gx9Qt+AaG0KQxcpEMFX7KI2cOOjO7zcG8BshxLFkF406EqSYHuu1e4Zoc0rUDtDM+Pj2c8OgXrLMtv0AqSIFCKB44syu5b30qKJe82+7ADAQRY0tPnWp3T1y4Ibas2E6+LtPbLIh8BdRCzOd+4TkblRnx.8rieHJkPujbA6ThCVGej2cNJhaU5kVhkY.LGnhVubk5OkE3eI2vOWvbFSPKgMpvMZ1JtHZQ0c0fPdcWTey2o3l+s9mvi323uNC7M4Av0LZlC75roj5tgjl7wjzwJQjaC9Hxyqg75VHu64ujp4o15HNs8U9ykvGmXBj1aJqBrnN+UG+YJ.gzNNgbI6XMXbCiAOML7A3mDFNbZ+f9AZ1EXpJyEE+S3vbeO7g3CxrVkzzO.93Xr3yKLADu504PhUZ7.dNCLG+i38f+LZzv9Auqe.FVkDFmlYVMnRLWvryTIoJIXL39EGw8wibazH7jgCcJpA4Wwe8XiihzpUhYDg3bnzXfRVvrz+voAW6TDWJ3RFNNSRsbkD+AvFPqN4GfuhHxX0ZkGiGT4xYW51sDJJQf4xH1ag6Z0kJ29r35srR30Dc642kiaXsS2pLWu6tSq8yDFVqnFMZ5l9qsfqkQIXiS0bHYVhuRGWGbci7voJK6L4fgAuKnWv0A3OLTbbqwJSbBlt0vt1X8mh3.YVx4LcU5tBHTauYyyc97ZdnEEQM.pjykb6YorR651qIszdgJqBg+62meHwRbcbk9.boLsk6ji2grqfwWE8e87OjYtzpRgIQ2T5h79Badz6V1cVTng3QNBEFSPusdF2z8Weiw6e19FxUr4xEZFTb6Za4lSTIv9Rz.LuNLIAt9toOOmQzRGBzs5r2qwY+dQyyd91b1+2oRvrQUTlfX2bfo6kgx.PgvFSlbSejFtccyWNtESQCacJZqel+Lk687WvszUsq2NsnWnb4+a8V9lTe+ihiYTasX65e7ersO.cKjxuoxrb4EmPrZNTB4eZVxR3YYJCThTBSo.edcbsRE1gNaWlYISFka7OvpL3DmsWYvIUAQIDpV8FZwHB2qdeYtGPSx7G76A+xCvFOAkO1.34GNNDk.kjugRcohcAs2Nm81BNOZK373sfyS1BNOcK378aAme3SxwMM3Wxrpjh1Dvwhixme54cT93h7JRz+d.kEmJ
                      

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

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

                        @d-healey Nice.. Thank you 🙂
                        Will try to attach Samplemap with it to change it.

                        Tania Ghosh

                        1 Reply Last reply Reply Quote 0
                        • iamlamprey
                          iamlamprey last edited by iamlamprey

                          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();
                              }
                          };
                          

                          New Song 🥰 - Instruments

                          Lindon Tania Ghosh 2 Replies Last reply Reply Quote 0
                          • Lindon
                            Lindon @iamlamprey 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

                            iamlamprey Tania Ghosh 2 Replies Last reply Reply Quote 0
                            • iamlamprey
                              iamlamprey @Lindon last edited by

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

                              New Song 🥰 - Instruments

                              1 Reply Last reply Reply Quote 0
                              • iamlamprey
                                iamlamprey last edited by iamlamprey

                                Here's an example of implementation:

                                https://i.gyazo.com/41b6e5e0ed6c7b0c719e9f71a6a3b246.mp4

                                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 🙂

                                New Song 🥰 - Instruments

                                Tania Ghosh 1 Reply Last reply Reply Quote 0
                                • Tania Ghosh
                                  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 Ghosh
                                    Tania Ghosh @iamlamprey 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 Ghosh
                                      Tania Ghosh @iamlamprey last edited by

                                      @iamlamprey Can you edit the code? please 🙂

                                      Tania Ghosh

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

                                        @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)

                                        New Song 🥰 - Instruments

                                        Tania Ghosh d.healey Lindon 3 Replies Last reply Reply Quote 0
                                        • Tania Ghosh
                                          Tania Ghosh @iamlamprey 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.healey
                                            d.healey @iamlamprey 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 Ghosh 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            4
                                            Online

                                            1.2k
                                            Users

                                            7.0k
                                            Topics

                                            64.8k
                                            Posts