Empty slot for combobox?
-
Console.print("HELLO WORLD");
How can i add an empty slot on the combobox menu?
I've sampled my drumset with the room mics included, then i got IRs from other rooms. What i need to do is: if in the combobox an IR is selected, the room sampler will turn off, and the convolution reverb will turn on, else the opposite
I'm stuck here, trying to tell HISE if nothing is selected, keep the smpRoom running, but i realized there is no "no selection" slot.
//////////////////////////////////////// reverb ComboBox const irs = Engine.loadAudioFilesIntoPool(); const var ComboBox0 = Content.getComponent("ComboBox0"); const var convRev = Synth.getAudioSampleProcessor("convRev"); inline function onComboBox0Control(component, value) { local smpRoom = Synth.getChildSynth("smpRoom"); if (value > 0) convRev.setFile(irs[value - 1]); else smpRoom.setAttribute(Gain, 0); } Content.getComponent("ComboBox0").setControlCallback(onComboBox0Control); ComboBox0.set("items", ""); for (x in irs) ComboBox0.addItem(x.replace("{PROJECT_FOLDER}").replace(""));Any tips?
Thanx!
-
What about
ComboBox0.set("items", ""); ComboBox0.addItem("Nothing"); for (x in irs) ComboBox0.addItem(x.replace("{PROJECT_FOLDER}").replace("")); -
@David-Healey it adds an empty slot, but it basically loads the first file anyway, so the last file of the list won't load.
I added a blank wav file and use it to call the Room sampler, but it's not working :/ I'm doing your Hise scripting foundation course, but it's still hard to put it in an Audio context.
inline function onComboBox0Control(component, value) { local smpRoom = Synth.getChildSynth("smpRoom"); if (value > 0) convRev.setFile(irs[value - 1]) && smpRoom.setAttribute(Gain, -100) && convRev.setAttribute(WetGain, 0); else if (value = 4) convRev.setAttribute(WetGain, -100) && smpRoom.setAttribute(Gain, 0); }the IRs get loaded, but volumes don't change and i get no error when compiling. what am I doing wrong? (4 is the blank wav file)
-
@ScreamingWaves said in Empty slot for combobox?:
it basically loads the first file anyway, so the last file of the list won't load.
Yes you will need to handle that in your script because all the indexes will now be shifted by 1.
inline function onComboBox0Control(component, value) { local smpRoom = Synth.getChildSynth("smpRoom"); // This should be a const in on init like your reverb. /* if (value > 0) // Combo box values start at 1, not 0. convRev.setFile(irs[value - 1]); else smpRoom.setAttribute(Gain, 0); // "Gain" is not a valid constant, this is covered later in the course :) */ if (value > 1) // 1 is now the empty slot { convRev.setFile(irs[value - 2]); // Subtract 2 because we have an empty slot in position 1 } else { smpRoom.setAttribute(smpRoom.Gain, 0); } } -
@David-Healey
ah I forgot to write smpRoom.Gain thanx :)or did you mean that using the Gain of the sampler is not valid? because now it goes to -100, but won't go back to 0
-
@ScreamingWaves Oh yeah it's a sampler, so you need to convert the value to a gain factor because it uses that unit instead of dB. However I wouldn't set the sampler gain dynamically like this because you might get audio artefacts. Instead use a Simple Gain effect, it has smoothing applied automatically and it uses dB.
-
@David-Healey thanx, this helps a lot!! :D
-
S ScreamingWaves has marked this topic as solved