diff --git a/share/scripts/mixer_settings_recall.lua b/share/scripts/mixer_settings_recall.lua index c8f683eb98..3da776fd2e 100644 --- a/share/scripts/mixer_settings_recall.lua +++ b/share/scripts/mixer_settings_recall.lua @@ -275,18 +275,29 @@ function factory () if proc:isnil() then goto nextline end local plug = proc:to_insert():plugin(0) - for k, v in pairs(params) do - local label = plug:parameter_label(k) - if string.find(label, "Assign") or string.find(label, "Enable") then --@ToDo: Check Plugin type == LADSPA or VST? - enable[k] = v --queue any assignments/enables for after the initial parameter recalling to duck the 'in-on-change' feature + local ctl = 0 + for j = 0, plug:parameter_count() - 1 do + if plug:parameter_is_control(j) then + local label = plug:parameter_label(j) + value = params[ctl] + if value then + if string.find(label, "Assign") or string.find(label, "Enable") then --@ToDo: Check Plugin type == LADSPA or VST? + enable[ctl] = value -- Queue enable assignment for later + goto skip_param + end + if not(ARDOUR.LuaAPI.set_processor_param(proc, ctl, value)) then + print("Could not set ctrl port " .. ctl .. " to " .. value) + end + end + ::skip_param:: + ctl = ctl + 1 end - print(string.format("%s (Port: %s) -> %s", label, k, v)) - ARDOUR.LuaAPI.set_processor_param(proc, k, v) end for k, v in pairs(enable) do ARDOUR.LuaAPI.set_processor_param(proc, k, v) end + if act then proc:activate() else proc:deactivate() end end diff --git a/share/scripts/mixer_settings_store.lua b/share/scripts/mixer_settings_store.lua index 1718a83ddd..e21624ed3c 100644 --- a/share/scripts/mixer_settings_store.lua +++ b/share/scripts/mixer_settings_store.lua @@ -301,17 +301,28 @@ function factory () return function () local id = proc:to_stateful():id():to_s() local plug = proc:to_insert ():plugin (0) local ptype = proc:to_insert():plugin(0):get_info().type - local n = 0 -- count control-ports - for j = 0, plug:parameter_count () - 1 do -- iterate over all plugin parameters - if plug:parameter_is_control (j) then - local label = plug:parameter_label (j) - if plug:parameter_is_input (j) and label ~= "hidden" and label:sub (1,1) ~= "#" then - --local _, _, pd = ARDOUR.LuaAPI.plugin_automation(proc, n) - local val = ARDOUR.LuaAPI.get_processor_param(proc, j, true) - print(r:name(), "->", proc:display_name(), label, val) - params[j] = val + + local n = 0 + for j = 0, plug:parameter_count() - 1 do -- Iterate over all plugin parameters + if plug:parameter_is_control(j) then + local label = plug:parameter_label(j) + if plug:parameter_is_input(j) and label ~= "hidden" and label:sub(1,1) ~= "#" then + local _, _, pd = ARDOUR.LuaAPI.plugin_automation(proc, n) + local val = ARDOUR.LuaAPI.get_processor_param(proc, n, true) + + -- Clamp values at plugin max and min + if val < pd.lower then + val = pd.lower + end + + if val > pd.upper then + val = pd.upper + end + + print(r:name(), "->", proc:display_name(), "(#".. n ..")", label, val) + params[n] = val end - n = n + 1 + n = n + 1 end end i = i + 1