Dynamic FX Panels
-
So I gather this is doable but challenging in HISE but here is what I am working on:
A dynamic FX Page with swappable FX networks. I hope to share it here once its done but I have hit a wall regarding saving my UI panel and knobs to the presets.
Here are the details:
12 FX slots (Hardcoded Master FX) and 12 FX panels (UI). These are namedFxSlot[i] //1-12 FxPanel[i] //1-12
Each of the 12 panels has 8 knobs and a label.
KnbParam[i] //1-96 FxLabel[i] //1-12
I've made it this far:
-
Loading different FX networks into the FX slots.
-
Displaying those networks in their corresponding panels, and being able to exchange them.
-
Connecting the corresponding panels and knobs to the corresponding slot (FxPanel1 & Knobs 1-8 to FxSlot1, FxPanel2 & Knobs 9-18 to FxSlot2, etc.).
-
Updating the Knobs based on the parameter information of the FX network (min, max, mid, name, suffix, etc.)
-
Creating a browser/menu for the Fx with categories and that will load the corresponding network by name into the appropriate slot and panel
-
Clearing and resetting knob/browser callbacks for each panel.
-
I am able to save and load presets with the Fx Networks in the FxSlots with no issues thanks to the
Engine.addModuleStateToUserPreset
So everything was dandy until the point of saving presets, where the FxPanels and knob data just won't be recalled. I tried Engine.compressJSON and Engine.loadJSON to no avail, and I even tried
Effect.exportState & Effect.restoreState
(though I don't think it is useful in this case).Just wondering if anyone can shed some light on the issue, perhaps a way for me to overwrite any previous controls and force my panels and knobs to redraw their content based on what is provided in the EffectSlots? It is also possible I am not entirely understanding how the Engine.compressJSON works.
-
-
I thought this was something that was directly supported in the API, no?
-
@clevername27 Yes it is but I think I am starting to see where I went astray, mainly I am just overriding it with my control callbacks.
I put together a simplified version of the script for updating knobs.
Here the EffectsArchive.js possesses all the JSON data necessary to rewrite the knobs when a new effect is loaded. One thing that is happening is that the knobs on the UI will reset to the defaultValue instead of reflecting the state of the knob in the Effect Slot (as saved in the preset):
Content.makeFrontInterface(600, 600); include("Effects/EffectsArchive.js"); const var FxSlot1 = Synth.getSlotFX("FxSlot1"); const var Slot1 = Synth.getEffect("FxSlot1"); const var Panel1 = Content.getComponent("Panel1"); const var Label1 = Content.getComponent("Label1"); const var Knob1 = Content.getComponent("Knob1"); const var ComboBox1 = Content.getComponent("ComboBox1"); var effectName = FxSlot1.getCurrentEffectId(); // Add FxSlot1 to the user preset system Engine.addModuleStateToUserPreset({ "ID": "FxSlot1", "RemovedProperties": ["bypass"], "RemovedChildElements": ["Modulator"] }); // Function to update the knob based on the effect loaded into FxSlot1 function updateKnobForEffect(effectName) { if (knobSettings[effectName]) { var knobConfig = knobSettings[effectName][0].config; Knob1.set("text", knobConfig.text); Knob1.setRange(knobConfig.min, knobConfig.max, knobConfig.stepSize); Knob1.set("defaultValue", knobConfig.defaultValue); Knob1.setValue(knobConfig.defaultValue); Knob1.showControl(true); } } inline function onKnob1Control(component, value) { Slot1.setAttribute(0, value); }; Content.getComponent("Knob1").setControlCallback(onKnob1Control); // Function to load an effect into FxSlot1 and update UI elements function loadEffect(effectName) { if (FxSlot1.setEffect(effectName)) { Label1.set("text", effectName); updateKnobForEffect(effectName); } else { Label1.set("text", "Empty"); Knob1.showControl(false); } } inline function onComboBox1Control(component, value) { local effectName = ComboBox1.getItemText(); loadEffect(effectName); } ComboBox1.setControlCallback(onComboBox1Control);
So first mistake was an oversight on my part, I need to change this line
Knob1.setValue(knobConfig.defaultValue);
...to grab the value from the FxSlot
Knob1.setValue(Slot1.getAttribute(0));
So I will just have to write some functions to make the knobs disappear when there is no effect loaded (already done), to load on default values when an effect is selected, and to load on the SlotFx values when loaded from a preset (though I am not sure how to do that).
Still trying to workout the issue with the Panels loading on the right effects with the presets but I will post a snippet in a bit once I break it down into easier to digest parts.
-
@HISEnberg It's those little things that can us in circles for hours. Nice work, looks like you're on your way.