HISE Logo Forum
    • Categories
    • Register
    • Login

    Change Sample Map via ComboBox

    Scheduled Pinned Locked Moved Scripting
    14 Posts 4 Posters 596 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.
    • clevername27C
      clevername27 @pgaudioworks
      last edited by

      @pgaudioworks I'm happy to help, but take a search on the forum, as this has been asked and answered previously.

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

        @pgaudioworks It's pretty straight forward. Put all your sample maps in an array (there is a built in function to do this for you).

        In your combo box's control callback you can use the combo box's value as the index to the array to get the sample map that was selected which you then load into the sampler.

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

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

          @d-healey thank you. Are you referring to getSampleMapList? I have this, bit it's giving me an error:

          const var Sampler1 = Synth.getChildSynth("Sampler1");
          
          Console.Print(Sampler1.getSampleMapList());
          

          Error:

          Interface:! Line 5, column 14: Function / constant not found: Console.Print {SW50ZXJmYWNlfG9uSW5pdCgpfDEwN3w1fDE0}
          Master Chain:! Line 5, column 14: Function / constant not found: Console.Print {SW50ZXJmYWNlfG9uSW5pdCgpfDEwN3w1fDE0}
          
          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @pgaudioworks
            last edited by

            @pgaudioworks getSampleMapList() is a function of the Sampler class, not childSynth

            Try using Synth.getSampler("Sampler1");

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

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

              @d-healey I updated it and I'm still getting the same error.

              const var Sampler1 = Synth.getSampler("Sampler1");
              
              Console.Print(Sampler1.getSampleMapList());
              

              Error:

              Interface:! Line 5, column 14: Function / constant not found: Console.Print {SW50ZXJmYWNlfG9uSW5pdCgpfDEwNHw1fDE0}
              Master Chain:! Line 5, column 14: Function / constant not found: Console.Print {SW50ZXJmYWNlfG9uSW5pdCgpfDEwNHw1fDE0}
              
              
              d.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @pgaudioworks
                last edited by d.healey

                @pgaudioworks The error message is telling you it can't find the function you are calling on line 5. You are calling two functions on that line, try eliminating one of them and see if the error remains.

                I just noticed, the error message tells you which function.

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

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

                  @d-healey really grateful for your help. I think I'm confused that I'm calling two functions. How does the console know what to print if I don't include both Console.Print and getSampleMapList?

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

                    @pgaudioworks Console.Print is not a function ;)

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

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

                      @d-healey I shouldn't have had the p capitalized, got it. I've now gotten this far:

                      const var Sampler1 = Synth.getSampler("Sampler1");
                      
                      const var SampleSelection = Content.getComponent("SampleSelection");
                      
                      
                      
                      Console.print(Sampler1.getSampleMapList()); 
                      
                      Console.print(SampleSelection.getValue()-1);
                      
                      
                      inline function onSampleSelectionControl(component, value)
                      {
                      	Sampler1.loadSampleMap(SampleSelection.getValue()-1);
                      };
                      
                      Content.getComponent("SampleSelection").setControlCallback(onSampleSelectionControl);
                      

                      The console is returning the right values, but the sampler isn't changing when I update the combo box. Am I any closer?

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

                        @pgaudioworks Is SampleSelection.getValue()-1 the name of your sample map?

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

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

                          @d-healey it's the name of the combo box.

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

                            @pgaudioworks

                            Sampler1.loadSampleMap(SampleSelection.getValue()-1);

                            loadSampleMap expects the name of a sample map.

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

                            1 Reply Last reply Reply Quote 0
                            • M
                              Mighty23
                              last edited by

                              @pgaudioworks try someting like this, where "cmbSampleMap" is my Combo Box

                              // My Sample Map on Combobox
                              const var sampleMaps = Sampler.getSampleMapList(); // get a Sample Map List
                              const var cmbSampleMap = Content.getComponent("cmbSampleMap"); //combo box
                              const var Sampler1 = Synth.getChildSynth("Sampler1"); // Sampler Reference
                              
                              // populate combo box with sample maps
                              cmbSampleMap.set("items", sampleMaps.join("\n"));
                              
                              inline function oncmbSampleMapControl(component, value)
                              {
                              	//Console.print(value);
                              	Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
                              };
                              
                              Content.getComponent("cmbSampleMap").setControlCallback(oncmbSampleMapControl);
                              

                              Free Party, Free Tekno & Free Software too

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

                              30

                              Online

                              1.7k

                              Users

                              11.8k

                              Topics

                              102.7k

                              Posts