Samplemaps Not Loading via Combobox
-
Hey Gang,
So I've got 4 Samplers, each with a combobox that should allow the Sampler to load the selected sample.
The combobox displays the name of the samples and allows you to click. However, the sample never changes in the Sampler.
This does for all 4 samplers.
What am I doing wrong?
//SAMPLEMAP COMBOBOX const var Sampler0 = Synth.getChildSynth("Sampler0"); const var Sampler1 = Synth.getChildSynth("Sampler1"); const var Sampler2 = Synth.getChildSynth("Sampler2"); const var Sampler3 = Synth.getChildSynth("Sampler3"); //samplemaps const var sampleMaps = Sampler.getSampleMapList(); //combobox note: cmb = name of combobox const var SamplemapsCmb0 = Content.getComponent("SamplemapsCmb0"); SamplemapsCmb0.set("items", sampleMaps.join("\n")); const var SamplemapsCmb1 = Content.getComponent("SamplemapsCmb1"); SamplemapsCmb1.set("items", sampleMaps.join("\n")); const var SamplemapsCmb2 = Content.getComponent("SamplemapsCmb2"); SamplemapsCmb2.set("items", sampleMaps.join("\n")); const var SamplemapsCmb3 = Content.getComponent("SamplemapsCmb3"); SamplemapsCmb3.set("items", sampleMaps.join("\n")); //Note: Sampler = name of Sampler inline function onSamplemapsCmb0Control(component, value) { Sampler0.loadSampleMap(sampleMaps[value-1]); }; Content.getComponent("SamplemapsCmb0").setControlCallback(onSamplemapsCmb0Control); inline function onSamplemapsCmb1Control(component, value) { Sampler1.loadSampleMap(sampleMaps[value-1]); }; Content.getComponent("SamplemapsCmb1").setControlCallback(onSamplemapsCmb1Control); inline function onSamplemapsCmb2Control(component, value) { Sampler2.loadSampleMap(sampleMaps[value-1]); }; Content.getComponent("SamplemapsCmb2").setControlCallback(onSamplemapsCmb2Control); inline function onSamplemapsCmb3Control(component, value) { Sampler3.loadSampleMap(sampleMaps[value-1]); }; Content.getComponent("SamplemapsCmb3").setControlCallback(onSamplemapsCmb3Control);
-
@trillbilly You can condense that a lot.
You need to use the{PROJECT_FOLDER}
wildcard I think. -
@d-healey Ive never use this "wildcard" before. I have used this code on separate occasions with no error except for this time. Seems strange its only now.
Yes, condensing will make things look much cleaner. Baby steps lol
-
@trillbilly Oh I see the problem... childSynths don't have a loadSampleMap function. You need to get them as samplers.
Here's the fixed condensed version:
//SAMPLEMAP COMBOBOX const sampler = []; for (i = 0; i < 4; i++) { sampler.push(Synth.getChildSynth("Sampler" + i)); } //samplemaps const var sampleMaps = Sampler.getSampleMapList(); //combobox note: cmb = name of combobox const cmbSampleMap = []; for (i = 0; i < 4; i++) { cmbSampleMap.push(Content.getComponent("SamplemapsCmb" + i)); cmbSampleMap[i].set("items", sampleMaps.join("\n")); cmbSampleMap[i].setControlCallback(oncmbSampleMapControl); } inline function cmbSampleMapControl(component, value) { local index = cmbSampleMap.indexOf(component); sampler[index].asSampler().loadSampleMap(sampleMaps[value - 1]); };
-
@d-healey This looks much better! Unfortunately it did not fix my issue. I still cannot switch samplemaps for some odd reason.
I created an initial panel with all knobs, combobox, buttons, etc I would need for each sampler. Then, I duplicated this panel to create the total 4 samplers for UI. Could copying like this cause issues?
Ive had trouble in the past with items going missing, UI being gone, etc that I was told could the result of moving things around different panels.
-
-
@d-healey I only did the code after copying everything. I will try deleting and just manually adding elements to see if it works.
-
@trillbilly Luckily, I only had to delete Comboboxes and add again manually. All is well.