-------------------------------------------------------------------------------- --! @title FX Controls --! @brief Bind a Program insert effect to the script UI --! @category UIHelpers --! --! Builds a small control panel for the first insert effect on the Program, here --! a "Drive". The Param* widgets bind straight to the effect's parameters: each --! control inherits its range, default and unit from the parameter and stays in --! sync with host automation, modulation and preset changes - no changed callback --! is needed to drive the effect. ParameterValue adds a non-visual binding, used --! here to read a parameter's live value from script. --! --! The parameter names ("Bypass", "DriveAmount", "Mode") are the internal names of --! the Drive effect; point Program.inserts[1] at that effect, or swap the names --! for those of your own FX. --! --! @demonstrates ParamKnob, ParamOnOffButton, ParamMenu, ParameterValue, Panel --! @asset FXControls.uvip Bundled Drive patch (load in Falcon) -------------------------------------------------------------------------------- -- the effect we want to control: first insert on the Program local fx = Program.inserts[1] setBackgroundColour("1a1a1a") local panel = Panel{"drive"} panel.bounds = {20, 20, 420, 150} panel.backgroundColour = "2a2a2a" -- No ranges are given: they are inherited from the bound parameter. -- Bounds are relative to the panel. local bypass = panel:ParamOnOffButton(fx, "Bypass") -- boolean parameter bypass.bounds = {25, 58, 110, 36} local amount = panel:ParamKnob(fx, "DriveAmount") -- 0..1, shown as % amount.bounds = {180, 25, 100, 100} local mode = panel:ParamMenu(fx, "Mode") -- enumerated parameter (entries from the param) mode.bounds = {290, 54, 110, 44} -------------------------------------------------------------------------------- -- Non-visual (logical) binding: read the live drive amount from script without -- placing a control for it. ParameterValue draws nothing; it just exposes the -- parameter through its .value. -------------------------------------------------------------------------------- local driveValue = ParameterValue(fx, "DriveAmount") bypass.changed = function(self) local state = self.value and "bypassed" or "active" print(string.format("Drive %s (amount = %d%%)", state, math.floor(driveValue.value * 100 + 0.5))) end setSize(460, 190) makePerformanceView()