HISE Logo Forum
    • Categories
    • Register
    • Login

    How to reliably save samplemaps in preset? (Expansions)

    Scheduled Pinned Locked Moved Solved General Questions
    11 Posts 5 Posters 222 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.
    • StraticahS
      Straticah
      last edited by Straticah

      Hey there i have a basic setup that loads the samplemaps of my 3 expansions into a multi column dropdown for the user to choose from (works fine!)

      15a81d18-4607-4b1a-a837-64a8da64592a-image.png

      We have been adding a few more samplemaps today and experienced that the old presets dont work anymore because the combobox only saves a value/index (but array+values change due to variable expansion content)

      <Control type="ScriptComboBox" id="ComboBox1" value="123.0"/>
      

      That is why i would prefer saving my samplemaps as a path inside of the preset file instead - quick example mockup:

      <CustomData>
        <Data key="ComboBox1_SampleMap" value="{EXP::Hardware Lab}Absorbing"/>
        <Data key="ComboBox2_SampleMap" value="{EXP::Pro Essentials}Detuner"/>
      </CustomData>
      

      Any ideas on how to solve this? Maybe Expansion-specific indexing (i dont think that is possible)? I think i am overlooking something beacuse with this setup expansions in general would not be possible...

      creating user interfaces: www.vst-design.com
      founder @prototype.audio https://www.prototype.audio/

      bendursoB 1 Reply Last reply Reply Quote 0
      • StraticahS Straticah marked this topic as a question
      • bendursoB
        bendurso @Straticah
        last edited by bendurso

        @Straticah Oh, I just reread your original question—you were actually asking how to do it.

        Yes, I used a label to save the samplemap name. The combobox still relies on the samplemaps array (with saveInPreset disabled), but I use the label to store the string name. Then I restore the combobox by matching the samplemap name.

        edit: actually, David told me to do this a couple a months ago lol.

        Christoph HartC 1 Reply Last reply Reply Quote 1
        • bendursoB
          bendurso @Straticah
          last edited by

          @Straticah Oh, I did something similar a few days ago.

          I asked ChatGPT to create a script to transform all the numeric values ​​into strings. To do this, I gave it the list of sample maps for each expansion (using Expansion.getSampleMapList), letting it know that the combo box has index 1. It worked like a charm.

          I can't find the script.. but in my case it was a little different because I used a hidden label to store the names of the samplemaps. Then of course it's required to update all the expansions.

          StraticahS 1 Reply Last reply Reply Quote 1
          • StraticahS
            Straticah @bendurso
            last edited by Straticah

            @bendurso Yes that makes a lot of sense - whats the way you used to save strings to a preset?

            Edit: oh i see you used a hidden label

            creating user interfaces: www.vst-design.com
            founder @prototype.audio https://www.prototype.audio/

            StraticahS bendursoB 2 Replies Last reply Reply Quote 0
            • StraticahS
              Straticah @Straticah
              last edited by

              @Christoph-Hart sry to bother - is there a less hacky way?
              @bendurso I would have never thought about that good idea.

              creating user interfaces: www.vst-design.com
              founder @prototype.audio https://www.prototype.audio/

              ChazroxC 1 Reply Last reply Reply Quote 0
              • bendursoB
                bendurso @Straticah
                last edited by bendurso

                @Straticah Oh, I just reread your original question—you were actually asking how to do it.

                Yes, I used a label to save the samplemap name. The combobox still relies on the samplemaps array (with saveInPreset disabled), but I use the label to store the string name. Then I restore the combobox by matching the samplemap name.

                edit: actually, David told me to do this a couple a months ago lol.

                Christoph HartC 1 Reply Last reply Reply Quote 1
                • StraticahS Straticah has marked this topic as solved
                • Christoph HartC
                  Christoph Hart @bendurso
                  last edited by Christoph Hart

                  Multiple options:

                  1. Use a hidden panel with saveInPreset=true and store all loaded sample map in a JSON array, then call Panel.setValue() with this. In its control callback, restore all comboboxes / load the sample maps. The comboboxes must not be savedInPreset for this to work.
                  2. Use the custom user preset system and define your data model as you wish.

                  Number 2 is probably overkill, so I would go with option 1.

                  1 Reply Last reply Reply Quote 3
                  • ChazroxC
                    Chazrox @Straticah
                    last edited by

                    @Straticah Have you tried calling presets by its name? I do that because if I add new presets AND sort in alphabetical order, the index obviously changes and will break my presets.

                    StraticahS 1 Reply Last reply Reply Quote 0
                    • StraticahS
                      Straticah @Chazrox
                      last edited by Straticah

                      @Chazrox The issue is currently only with samplemaps not with loading presets.
                      I am now doing what @Christoph-Hart and @bendurso suggested which is saving the samplemap via a label which adds it to the preset data.

                      <Control type="ScriptLabel" id="presetpath_01" value="{EXP::Hardware Lab}Juno Elements"/>
                      <Control type="ScriptLabel" id="presetpath_02" value="{EXP::Hardware Lab}Movement-120"/>
                      

                      Not as hacky for HISE as i thought :)

                      creating user interfaces: www.vst-design.com
                      founder @prototype.audio https://www.prototype.audio/

                      Oli UllmannO 1 Reply Last reply Reply Quote 1
                      • Oli UllmannO
                        Oli Ullmann @Straticah
                        last edited by Oli Ullmann

                        @Straticah
                        Why don't you do it this way? It works in my project.

                        First, get all the sampleMaps into the project:

                        const sampleMaps = Sampler.getSampleMapList();
                        

                        Then fill your combo box with all the maps.

                        And the combo box callback looks something like this:

                        for(m in sampleMaps)
                        {
                            if(m.contains(combobox.getItemText()))
                                sampler.asSampler().loadSampleMap(m);
                        }
                        

                        The combo box must, of course, be saveInPreset.

                        I think that should still work even if you add new sample maps to the existing plug-in. But I still need to test that.

                        You also could do:

                        if(m == combobox.getItemText())
                        
                        Christoph HartC 1 Reply Last reply Reply Quote 0
                        • Christoph HartC
                          Christoph Hart @Oli Ullmann
                          last edited by

                          @Oli-Ullmann said in How to reliably save samplemaps in preset? (Expansions):

                          The combo box must, of course, be saveInPreset.

                          comboboxes store their value as index, so if the sample map items change because you load in a different expansion, it will not load the correct one.

                          Oli UllmannO 1 Reply Last reply Reply Quote 1
                          • Oli UllmannO
                            Oli Ullmann @Christoph Hart
                            last edited by

                            @Christoph-Hart
                            Ah, I see. Thanks for explaining!

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

                            30

                            Online

                            1.9k

                            Users

                            12.5k

                            Topics

                            108.8k

                            Posts