Set Min and Max values of a slider with a button
-
Hi all,
I'm trying to make a button that changes a sliders value from min to max with one click.
I almost got it but not quite. Can anyone see what I've missed in the code?
const var ReverbBypassBtn = Content.getComponent("ReverbBypassBtn"); const var ReverbBypassGainKnob = Content.getComponent("ReverbBypassGainKnob"); inline function onReverbBypassBtnControl(component, value) { if (value ==1) { ReverbBypassGainKnob.setMaxValue; } else { ReverbBypassGainKnob.setMinValue; } }; Content.getComponent("ReverbBypassBtn").setControlCallback(onReverbBypassBtnControl);
-
@SteveRiggs
.setMaxValue
needs an argument to work, like.setMaxValue(0)
This is not what you want anyway, because this method is for setting the min/max limit of the slider, not its value...
You may want to use.setValue(0 or -100)
instead.
Don't forget to addReverbBypassGainKnob.changed();
at the end of your callback -
wild guess but I would try this:
inline function onReverbBypassBtnControl(component, value) { if (value) { ReverbBypassGainKnob.setValue(ReverbBypassGainKnob.getMaxValue()); }else{ ReverbBypassGainKnob.setValue(ReverbBypassGainKnob.getMinValue()); } };
-
@ustk Thanks, dude. That works now changing the slider on the interface. I'm making a right mess of this one though
When I link the slider to the simple gain modules gain with the processor Id, it will move the gain in the back end if I turn the slider down manually, but by pushing the button the gain in the back end doesn't change, even though the slider on the interface is.
So I figured it needs to be hardcoded instead of using the processor Id? If I'm doing it that way then there's no real need for the slider as that would have been a hidden slider anyway.
If I can get the button just to change the value of the simple gains gain control that would be loads better... but again I've missed something in the if/else statement I think?
Sorry about this. My brains not working properly at all today.
const var ReverbGainTESTbypass = Synth.getEffect("ReverbGainTESTbypass"); const var ReverbBypassBtn = Content.getComponent("ReverbBypassBtn"); inline function onReverbBypassBtnControl(component, value) { if (value ==1) { ReverbGainTESTbypass.setValue(Gain, 0); } else { ReverbGainTESTbypass.setValue(Gain, -100); } }; Content.getComponent("ReverbBypassBtn").setControlCallback(onReverbBypassBtnControl);
-