Load specific samplemap via combobox and search bar
-
How can I load specific samplemap via viewport and ComboBox?
I can do it via Switch Case but when I am adding https://forum.hise.audio/topic/7898/for-you-searching-a-viewport search bar things, it doesn't load specific sample maps.
-
@DabDab post a snippet of what you're working with
-
Content.makeFrontInterface(200, 330); const var lblSearch = Content.getComponent("lblSearch"); const var vptResults = Content.getComponent("vptResults"); //Pre-Set Values lblSearch.set("text", "Search"); const var defaultEntries = ["Drum", "Piano", "Guitar", "Viola"]; //Change these values to change viewport entries vptResults.set("items", defaultEntries.join("\n")); //Search Bar Callback inline function onlblSearchControl(component, value) { local searchResults = []; local regexKey = []; vptResults.set("items", defaultEntries.join("\n")); if(Engine.matchesRegex(value, "^\\s*$")) //If search is empty, then reset entries { vptResults.set("items", defaultEntries.join("\n")); } else { for(character in value.toLowerCase().split("")) //Makes regex key to find case-insensitive matches { regexKey.push("[" + character + character.toUpperCase() + "]"); }; for(item in vptResults.get("items").split("\n")) //Puts matching values into new array { if(Engine.matchesRegex(item, regexKey.join(""))) { searchResults.push(item); } }; searchResults.sortNatural(); vptResults.set("items", searchResults.join("\n")); }; }; Content.getComponent("lblSearch").setControlCallback(onlblSearchControl); // Samplemaps Console.stop(true); const var Sampler1 = Synth.getSampler("Sampler1"); const var list = Sampler.getSampleMapList(); inline function onvptResultsControl(component, value) { Sampler1.loadSampleMap(list[value]); }; Content.getComponent("vptResults").setControlCallback(onvptResultsControl);
-
Your snippet isn't loading for me
-
Content.makeFrontInterface(200, 330); const var lblSearch = Content.getComponent("lblSearch"); const var vptResults = Content.getComponent("vptResults"); //Pre-Set Values lblSearch.set("text", "Search"); const var defaultEntries = ["Drum", "Piano", "Guitar", "Viola"]; //Change these values to change viewport entries vptResults.set("items", defaultEntries.join("\n")); //Search Bar Callback inline function onlblSearchControl(component, value) { local searchResults = []; local regexKey = []; vptResults.set("items", defaultEntries.join("\n")); if(Engine.matchesRegex(value, "^\\s*$")) //If search is empty, then reset entries { vptResults.set("items", defaultEntries.join("\n")); } else { for(character in value.toLowerCase().split("")) //Makes regex key to find case-insensitive matches { regexKey.push("[" + character + character.toUpperCase() + "]"); }; for(item in vptResults.get("items").split("\n")) //Puts matching values into new array { if(Engine.matchesRegex(item, regexKey.join(""))) { searchResults.push(item); } }; searchResults.sortNatural(); vptResults.set("items", searchResults.join("\n")); }; }; Content.getComponent("lblSearch").setControlCallback(onlblSearchControl); // Samplemaps Console.stop(true); const var Sampler1 = Synth.getSampler("Sampler1"); const var list = Sampler.getSampleMapList(); inline function onvptResultsControl(component, value) { Sampler1.loadSampleMap(list[value]); }; Content.getComponent("vptResults").setControlCallback(onvptResultsControl);
My problem is Label is isolating the samplemaps name. but it doesn't load specific samplemaps.
-
@DabDab Your
list
variable contains all of the sample maps but your viewport only contains the filtered ones. You need to put the filtered results into an array and use that instead of list to load the sample maps. -
@d-healey Hmmm... can I get a minimal snippet ? I tried it with Switch case. But didn't work. A simple example will be helpful.
//Sampler1.loadSampleMap(list[value]); Sampler1.loadSampleMap(defaultEntries[value]);
??
-
@DabDab You already have the code. Instead of using the
searchResults
array to store your results, put them in an array outside of the function, then you can access it in the same way as you are currently accessinglist
.You're probably going to run into problems though when it comes to presets because presumably the filter will reset and then the indexes won't match.
-
-
@d-healey I will make a snippet.