A Button that shows/hides knobs?
-
I've picked showControl from API.
Visible property is not working. By the way, I'm a beginner to this coding stuff :)inline function onButton1Control(component, value) { if(value == 0) Knob1.visible(true); else Knob1.visible(false); };
-
You're correct, I hadn't seen the
showControl()
command before, good to know!I think I know what is wrong with your example, are you storing the controls in variables using the
getComponent()
command? Here is a working example (note that I use the generic control callback rather than an inline function but either will work).HiseSnippet 991.3oc0V0riaaCDlz1Jo1odQRQN1CB4zt.IFVN+BDrHN1NapQ5twnJwXukRKQslwRjBhTdWuKBPOjmmf9FzduG6SPeC5aP6PIYK4V4MqaQOTdwd3LeTeb3GmgihDNToTDgv23MKBoH7WZXufql1eJgwQCGfv6XbHQpnQloS0aQHQJotHLt5K0SfqWCkL98m0i3S3Nz7oPnwBlC8aYALU9rgceEy2+.hK8MrfBQ+ftCcD79BeQLvmpFsQgDmYjSnGQzgUw.MmQOUhvsMtemVQyrlb9yaoG8Zsb7MiOlIG6LGle9wpA8S8ibhihnb0X.NBaf+CXfMdgKSIhrUDEEVyp8DtKrmJNkm9oGyjrI9TsgExF3T5zn9SY9tiVl1jHDt1n7jX0zj3sMNj4xVMedx7lINLyQTLchqrNkpsFkr1DkNP36pWfMPObA5UKkd2xv1IhEpx8n41MLFxgyYOBbBVjVowhp7KXi9BHBtpU.YF8fHvXEhceT61207gsau2Sa1nYC3bTpLmShLmDqTBt49lKwdBU0WDDJ3fwt2oWhaq6ngkCZFWLwZiXdk1aIH5boH5.H7h4NJFPGA+Hgh9Z9t603hF0a7gF+UOddk4Ru5QBeeZTYd0p4nKA1t73fIzn6BD1OlpiqYCSXv7LybYt+9YIr8RccQ5O5QRNokDjCKWtzk4oqGRm0Bw5dYAkDyGRCEHGHEVWqcsqlVyIM8VHPAeHmodcHMyNWMZUhZDkc9.5xpYbD9mJQUtSlpLURfXvhT2HSefR1FEKrf1DbaelKMJA90MRjJ+a.2oDvuc3.hhnuZksafcXHMRwzIR7.5bnjW5Es5FCnxYJQXx1MSNBI6qvF9rUexu2q6hUF+7wcOk4plpKi8Cf8TJ6joJs0WmtuV8Q14ylVNSC6GATKz+4Wg+rgkFpqfjpEZ4v0RvhBXtt9zQBISKwKzC3mfVEg1rySxXWb6O8xe67O9rfhsIPn.xYE6ZHi87XmkTe2i4GHU.cGF.k8Q3ux3sRpoK0iD6qLkyf0Y9RgItZwcayO64Xgu4oESnuu6+C10n+dQbnUhvM1mnVu+htmblCMGKVHWWrlCbeQQdrEMcZWZSmRuleEo6sLFwTNSKmuUJguvkt+q4aVK7lFuvyi5nxIaMiCN9eZ+5sfJemHVw3mbHATD5anGEGXCOHxgBLgyo9Rs1rh9tdpcassNyXS4tsW97lLmVZablSqkNAsnSj3cNoEA0OR3KRlA3DO4oV0g27A1lqJcp4Mn9YuywQmHtmEBUNhNaMh6u0HdvVi3gaMhGs0Hd7Vi3IWBB8yDedrRDjds.g9S9l4FWC
The
visible
property is a property of the control it is not a command so you can't use it like a command. To set it, or any other property, you need to call theset()
command like so:Knob1.set("visible", true);
-
Thank you so much @d-healey . It worked lke a charm...
-
What if we want to use this with an inline function? I tried this but there is something wrong.
Content.makeFrontInterface(600, 500); const var button = Content.getComponent("Button1"); const var knob1 = Content.getComponent("Knob1"); const var knob2 = Content.getComponent("Knob2"); inline function onButton1Control(number, value) { if (number == button) { knob1.showControl(value); knob2.showControl(1-value); } }
-
You have to assign the function to the control, otherwise HISE will have no way to know when to use that function.
You need to use the
setControlCallback()
command.Content.makeFrontInterface(600, 500); const var button = Content.getComponent("Button1"); const var knob1 = Content.getComponent("Knob1"); const var knob2 = Content.getComponent("Knob2"); inline function onButton1Control(number, value) { knob1.showControl(value); knob2.showControl(1-value); } button.setControlCallback(onButton1Control);
-
What‘s knob.showControl()?
-
Thank you so much @d-healey .
Last question, for example:
At the same time; if I want to assign this button to Phaser LFO Modulator TempoSync, should it be like this? But it doesn't work.Content.makeFrontInterface(600, 200); const var button = Content.getComponent("Button1"); const var knob1 = Content.getComponent("Knob1"); const var knob2 = Content.getComponent("Knob2"); inline function onButton1Control(number, value) { knob1.showControl(value); knob2.showControl(1-value); } button.setControlCallback(onButton1Control); Button1.setModule(LFO Modulator, Synth.getEffect("TempoSync"));
-
@christoph-hart
For showing or hiding 2 knobs relatively, with a button on/off.
When button is on, knob 1 will be showed (knob 2 will be hided)
When button is off, knob 2 will be showed (knob 1 will be hided) -
LOL don‘t know my own API anymore :)
-
@d-healey this worked great! Thanks!
What's the best way to set a knob's visibility at initialization? -
Just call onButton1Control in the onInit callback with the value you need.
-
@christoph-hart Can you give an example, excuse me I really struggle with this stuff bro.
-
@remarkablex There isn't a
setModule()
command so I'm not too sure what you're trying to do. Whenever you want an action to happen when a button is clicked you must put that code inside the button's callback. So if you want it to control an FX module you first need to grab that FX and store it in a variable (similarly to how a control is stored in a variable), you can then use thesetAttribute()
command to change a parameter of that effect.@dustbro If you want it set at initialisation then just set it in the property editor, no need to script it.
-
I have set visible in the property editor to disable. Once I enter in my script, the knobs become visible again. :(
Here's what I'm doing:const var Button1 = Content.getComponent("Button1"); const var Knob1 = Content.getComponent("Knob1"); const var Knob2 = Content.getComponent("Knob2"); const var Knob3 = Content.getComponent("Knob3"); const var Button2 = Content.getComponent("Button2"); const var Knob4 = Content.getComponent("Knob4"); const var Knob5 = Content.getComponent("Knob5"); const var Knob6 = Content.getComponent("Knob6"); inline function onButton1Control(component, value) { Button2.setValue(0); Knob1.showControl(value); Knob2.showControl(value); Knob3.showControl(value); Knob4.showControl(1-value); Knob5.showControl(1-value); Knob6.showControl(1-value); }; Content.getComponent("Button1").setControlCallback(onButton1Control); inline function onButton2Control(component, value) { Button1.setValue(0); Knob1.showControl(1-value); Knob2.showControl(1-value); Knob3.showControl(1-value); Knob4.showControl(value); Knob5.showControl(value); Knob6.showControl(value); }; Content.getComponent("Button2").setControlCallback(onButton2Control);
Once I hit compile, knobs 1 2 3 become visible. If I remove knobs 4 5 6 from the project, the knobs stay hidden.
-
@dustbro After initialisation all control callbacks are called so this will undo anything you set in the initialisation or in the property editor for controls that are affected by callbacks. A solution for this is to have a variable that is set to a value in the last control callback called and then in any other callback you'll be able to check this variable and only carry out the actions after it's value has been set.
For example create a variable called
initComplete
and set it to 0. Then in your last control's callback you can putinitComplete = 1
Now in all your other callbacks you just need to encapsulate the code inside an if statementif (initComplete == 1){};
Another option instead of using a variable is to use a button set to 0 and then set it to 1 in its own control callback and check its value in the other callbacks.
@Christoph-Hart Maybe it would be good to have a built in variable for this purpose that can be tested when you don't want actions to happen straight after initialization?
-
Just set
saveInPreset
to false for the button that toggles the visibility, that‘s precisely what it‘s for, then call it in the onInit and it won‘t get overriden. -
@christoph-hart said in A Button that shows/hides knobs?:
Just set
saveInPreset
to false for the button that toggles the visibility, that‘s precisely what it‘s for, then call it in the onInit and it won‘t get overriden.Is there documentation on the Property Editor?
That did work somewhat. But after I recompile, some knobs are still visible intermittently. AddingsetValue
before the callbacks did the trick.Button1.setValue(0); const var Knob1 = Content.getComponent("Knob1"); Knob1.showControl(false); const var Knob2 = Content.getComponent("Knob2"); Knob2.showControl(false); const var Knob3 = Content.getComponent("Knob3"); Knob3.showControl(false); const var Button2 = Content.getComponent("Button2"); Button2.setValue(0); const var Knob4 = Content.getComponent("Knob4"); Knob4.showControl(false); const var Knob5 = Content.getComponent("Knob5"); Knob5.showControl(false); const var Knob6 = Content.getComponent("Knob6"); Knob6.showControl(false);
-
@d-healey Hurry up and make a HISE tutorial so I can purchase it!! ;)
-
I'm almost there....
With this current script, the UI initializes with all knobs hidden and button 1 + 2 are set to off.
I can toggle between Button 1 and 2, which shows knobs 1-3 or 4-6.Content.makeFrontInterface(600, 500); const var Button1 = Content.getComponent("Button1"); Button1.setValue(0); const var Knob1 = Content.getComponent("Knob1"); Knob1.showControl(false); const var Knob2 = Content.getComponent("Knob2"); Knob2.showControl(false); const var Knob3 = Content.getComponent("Knob3"); Knob3.showControl(false); const var Button2 = Content.getComponent("Button2"); Button2.setValue(0); const var Knob4 = Content.getComponent("Knob4"); Knob4.showControl(false); const var Knob5 = Content.getComponent("Knob5"); Knob5.showControl(false); const var Knob6 = Content.getComponent("Knob6"); Knob6.showControl(false); inline function onButton1Control(component, value) { Button2.setValue(0); Knob1.showControl(true); Knob2.showControl(true); Knob3.showControl(true); Knob4.showControl(false); Knob5.showControl(false); Knob6.showControl(false); }; Content.getComponent("Button1").setControlCallback(onButton1Control); inline function onButton2Control(component, value) { Button1.setValue(0); Knob1.showControl(false); Knob2.showControl(false); Knob3.showControl(false); Knob4.showControl(true); Knob5.showControl(true); Knob6.showControl(true); }; Content.getComponent("Button2").setControlCallback(onButton2Control);
The Only thing I don't have previsions for yet is what happens when a button is unselected. For instance, If I select Button1, knobs 1-3 are revealed. When I hit Button1 again, the button turns off, but knobs 1-3 are still visible.
Would an IF/ELSE statement work after the callbacks? or is this something I need to set in each callback? -
@dustbro http://hise.audio/manual/VideoTutorials.php ;)