HISE Logo Forum
    • Categories
    • Register
    • Login

    Combobox List Alphabetically

    Scheduled Pinned Locked Moved General Questions
    comboboxlistingalphabetical
    19 Posts 3 Posters 1.4k 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.
    • trillbillyT
      trillbilly
      last edited by

      Hey Gang,

      Ive got a 4 comboboxes scripted to 4 different audio loop players. These comboboxes list audiofiles. This is all working great except, the list is in the order of "Oldest to Newest" and would like it to be in Alphabetical Order. Below is my script, any help is appreciated.

      const var SlotSelectors = 
      [Content.getComponent("SampleSelection1"),
      Content.getComponent("SampleSelection2"),
      Content.getComponent("SampleSelection3"),
      Content.getComponent("SampleSelection4")];
      
      const var AudioLoopPlayers = [Synth.getAudioSampleProcessor("LoopPlayer1"),
      Synth.getAudioSampleProcessor("LoopPlayer2"),
      Synth.getAudioSampleProcessor("LoopPlayer3"),
      Synth.getAudioSampleProcessor("LoopPlayer4"),];
      
      
      const var expHandler = Engine.createExpansionHandler();
      const var expansionList = expHandler.getExpansionList();
      
      
      const var allList = [];
      const var allIds = [];
      
      const var rootList = Engine.loadAudioFilesIntoPool();
      
      allList.push("No Sample Loaded");
      allIds.push("");
      
      for(r in rootList)
      {
          allList.push(r.split("}")[1]);
          allIds.push(r);
      }
      
      
      for(e in expansionList)
      {
          for(af in e.getAudioFileList())
          {
              allList.push(af.split("}")[1]);
              allIds.push(af);
          }
      }
      
      for(s in SlotSelectors)
          s.set("items", allList.join("\n"));
      
      
      
      inline function onSlotSelectorControl(component, value)
      {
          local index = SlotSelectors.indexOf(component);
          
          if(value != 0)
          {
      	AudioLoopPlayers[index].setFile(allIds[value-1]);
          }
      };
      
      const var numbers = [64, 48];
      const var ids = [-1, -1];
      
      for(s in SlotSelectors)
          s.setControlCallback(onSlotSelectorControl);
      
      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @trillbilly
        last edited by

        @trillbilly Try array.sort();

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

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

          @d-healey Thanks. Does it go within the "rootlist" element? I've tried placing it where I suspected it would go but get the error "Unknown function 'sort'" whenever I try to compile.

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

            @trillbilly allList.sort() probably.

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

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

              @d-healey ahhh, yes, I see now. I added this and it did nothing to effect the list. I also use allList.sortNatural which did work, but now it loads the samples out of order (kind of like when you move samplemaps around or add new samplemaps).

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

                @trillbilly said in Combobox List Alphabetically:

                @d-healey ahhh, yes, I see now. I added this and it did nothing to effect the list. I also use allList.sortNatural which did work, but now it loads the samples out of order (kind of like when you move samplemaps around or add new samplemaps).

                -probably because you are not sorting allIds, try sorting e.getAudioFileList instead...

                Guessing something like this(not at my machine):

                var afl =[];
                for(e in expansionList)
                {
                    afl = e.getAudioFileList();
                    afl.sortNatural();
                    for(af in afl)
                    {
                        allList.push(af.split("}")[1]);
                        allIds.push(af);
                    }
                }
                

                HISE Development for hire.
                www.channelrobot.com

                trillbillyT 1 Reply Last reply Reply Quote 0
                • trillbillyT
                  trillbilly @Lindon
                  last edited by

                  @Lindon Thanks, that seemed to do the trick! 2 samples are still out of order but they load the correct audiofile. Ill try deleting and exporting t hem again to see if they fall in place.

                  LindonL trillbillyT 2 Replies Last reply Reply Quote 0
                  • LindonL
                    Lindon @trillbilly
                    last edited by

                    @trillbilly that may well be a naming issue - lower and upper case etc.

                    HISE Development for hire.
                    www.channelrobot.com

                    trillbillyT 2 Replies Last reply Reply Quote 0
                    • trillbillyT
                      trillbilly @Lindon
                      last edited by

                      @Lindon I dont think its naming. Ive posted a pic of the names below. Its exactly as I named the audiofiles. I just got into the studio and will try the delete method to see if it works.

                      alt text

                      1 Reply Last reply Reply Quote 0
                      • trillbillyT
                        trillbilly @Lindon
                        last edited by

                        @Lindon @d-healey I changed name with no results. I also deleted and exported the samples again with a new name and still, the new files show at the bottom of the list.

                        I will export some new samples to the audiofiles folder and see if they load correctly.

                        1 Reply Last reply Reply Quote 0
                        • trillbillyT
                          trillbilly @trillbilly
                          last edited by

                          @d-healey @Lindon When I add new samples to AudioFiles, they are also at the bottom of the list now, even after recompiling. Here is the new code with @d-healey advice and script. Can you see what Ive done wrong?

                          const var SlotSelectors = 
                          [Content.getComponent("SampleSelection1"),
                          Content.getComponent("SampleSelection2"),
                          Content.getComponent("SampleSelection3"),
                          Content.getComponent("SampleSelection4")];
                          
                          const var AudioLoopPlayers = [Synth.getAudioSampleProcessor("LoopPlayer1"),
                          Synth.getAudioSampleProcessor("LoopPlayer2"),
                          Synth.getAudioSampleProcessor("LoopPlayer3"),
                          Synth.getAudioSampleProcessor("LoopPlayer4"),];
                          
                          
                          const var expHandler = Engine.createExpansionHandler();
                          const var expansionList = expHandler.getExpansionList();
                          
                          
                          const var allList = [];
                          const var allIds = [];
                          
                          const var rootList = Engine.loadAudioFilesIntoPool();
                          
                          allList.push("No Sample Loaded");
                          allIds.push("");
                          
                          for(r in rootList)
                          {
                              allList.push(r.split("}")[1]);
                              allIds.push(r);
                          }
                          
                          
                          var afl =[];
                          for(e in expansionList)
                          {
                              afl = e.getAudioFileList();
                              afl.sortNatural();
                              for(af in afl)
                              {
                                  allList.push(af.split("}")[1]);
                                  allIds.push(af);
                              }
                          }
                          
                          for(s in SlotSelectors)
                              s.set("items", allList.join("\n"));
                          
                          
                          
                          inline function onSlotSelectorControl(component, value)
                          {
                              local index = SlotSelectors.indexOf(component);
                              
                              if(value != 0)
                              {
                          	AudioLoopPlayers[index].setFile(allIds[value-1]);
                              }
                          };
                          
                          const var numbers = [64, 48];
                          const var ids = [-1, -1];
                          
                          for(s in SlotSelectors)
                              s.setControlCallback(onSlotSelectorControl);
                          
                          d.healeyD 1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey @trillbilly
                            last edited by

                            @trillbilly Why are you using sortNatural instead of sort?

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

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

                              @d-healey I was just trying to see if it made any difference. They both do the same thing in this case. Sorts all previous audiofiles but new audiofiles list at the bottom and out of order.

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

                                @trillbilly What happens if you sort root list instead? I haven't looked through your code so there might be something obvious but I don't have time at the moment

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

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

                                  @d-healey Youree right, it is part of my issue, I sorted the allList.sort instead of rootList.sort. This fixed the issue for the most part. Now my issue is.

                                  1. I have a repeating sample, and they are not even one above the other. It only repeats one time.

                                  example:
                                  GTR A
                                  GTR B
                                  GTR A
                                  GTR C
                                  GTR D
                                  so on...

                                  1. If I add a new sample that has a name that would go before my current first sample (GTR A) then that sample doesnt show. Its almost like it replaces that sample with itself?
                                  d.healeyD 1 Reply Last reply Reply Quote 0
                                  • d.healeyD
                                    d.healey @trillbilly
                                    last edited by

                                    @trillbilly You could just put a number at beginning of each one and then you get the order you want.

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

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

                                      @d-healey I could, but doesnt look as good from the user end. I was hoping to name them GTR Name, PAD Name, SYN Name, etc so they are easy to view in the dropdown combobox.

                                      I will keep plucking away for the time being. Just strange behavior is all.

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

                                        @trillbilly You don't have to display the numbers to the end user ;) They're just used for sorting. Look up substring()

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

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

                                          @d-healey Of course they are lol. I will check it out. Thanks.

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

                                          23

                                          Online

                                          1.7k

                                          Users

                                          11.8k

                                          Topics

                                          103.0k

                                          Posts