HISE Logo Forum
    • Categories
    • Register
    • Login

    Index issue with Sample maps?

    Scheduled Pinned Locked Moved General Questions
    8 Posts 2 Posters 450 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.
    • ThinkTankT
      ThinkTank
      last edited by ThinkTank

      Hello all,

      I have 3 samplers, with a combobox each for selecting samplemaps.
      However presets gets messed up, and the samplers load wrong samplemaps when i add new sample maps in HISE.

      How would i go around this issue?

      ChatGPT recommends doing it in a manual way:
      const var sampleMapNames = ["SampleMap1", "SampleMap2", "SampleMap3", ...];

      That just seems and feels so wrong :grinning_face_with_sweat:

      Without problems that test the limits of your abilities, you can not expand them.

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

        Put a number at the beginning of all sample map names and sort the array so that new sample maps are always at the end.

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

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

          @d-healey

          Would you care to share a code of that?

          • or snippet?
            Not sure how to make a combobox sort by number...

          Without problems that test the limits of your abilities, you can not expand them.

          1 Reply Last reply Reply Quote 0
          • ThinkTankT
            ThinkTank @ThinkTank
            last edited by

            @ThinkTank

            ChatGPT says:

            const var pianos = Content.getComponent("pianos");
            
            // Manually list your sample map names here in the order you want
            const var sampleMapNames = ["01_Piano", "02_Violin", "03_Flute", ...]; // and so on
            
            pianos.set("items", sampleMapNames.join("\n"));
            
            inline function onpianosControl(component, value)
            {
                var selectedSampleMapName = sampleMapNames[value];
                Sampler1.asSampler().loadSampleMap(selectedSampleMapName);
            };
            
            pianos.setControlCallback(onpianosControl);
            

            But i dont want to write all my sample maps in manually

            Without problems that test the limits of your abilities, you can not expand them.

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

              @ThinkTank said in Index issue with Sample maps?:

              ChatGPT says:

              🤦

              There is a built in function to get an array of sample maps. Once you've got it you can sort it using the built in sort functions.

              ba8d2c43-e28a-40fc-b1d8-8574caf08c9e-image.png

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

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

                @d-healey said in Index issue with Sample maps?:

                There is a built in function to get an array of sample maps. Once you've got it you can sort it using the built in sort functions.

                // Make Sound Selector (Layer A)
                
                const var pianos = Content.getComponent("pianos");
                
                // Retrieve the array of sample map names using the built-in function
                const var sampleMapNames = getSampleMapList(); // Assuming this is the correct function name
                
                // Sort the array
                sampleMapNames.sort();
                
                pianos.set("items", sampleMapNames.join("\n"));
                
                inline function onpianosControl(component, value)
                {
                    // Directly use the array and index without re-declaring a local variable
                    Sampler1.asSampler().loadSampleMap(sampleMapNames[value]);
                };
                
                pianos.setControlCallback(onpianosControl);
                

                Seems to not work

                Without problems that test the limits of your abilities, you can not expand them.

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

                  @ThinkTank The getSampleMapList() function is part of the Sampler class so needs to be called on a Sampler reference. For example if you had a reference variable called Sampler1 you could use Sampler1.getSampleMapList();

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

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

                    @d-healey

                    I think i got it, thanks!

                    Without problems that test the limits of your abilities, you can not expand them.

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

                    9

                    Online

                    1.7k

                    Users

                    11.8k

                    Topics

                    102.7k

                    Posts