How to reliably save samplemaps in preset? (Expansions)
-
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!)
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...
-
S Straticah marked this topic as a question
-
@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.
-
@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.
-
@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
-
@Christoph-Hart sry to bother - is there a less hacky way?
@bendurso I would have never thought about that good idea. -
@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.
-
S Straticah has marked this topic as solved
-
Multiple options:
- 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 besavedInPreset
for this to work. - 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.
- Use a hidden panel with
-
@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.
-
@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 :)
-
@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())
-
@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.
-
@Christoph-Hart
Ah, I see. Thanks for explaining!