diff options
author | Nikolaus Gullotta <nik@harrisonconsoles.com> | 2020-04-15 13:38:33 -0500 |
---|---|---|
committer | Nikolaus Gullotta <nik@harrisonconsoles.com> | 2020-04-15 13:38:33 -0500 |
commit | 858bb4294da608f1cb548a911804b890b4049501 (patch) | |
tree | 780ec64a52c651b3ba490f7ff450da2c2f60af8a /share | |
parent | 250da353d4bb6c03d645a96431e2fc7cc1ae4406 (diff) |
Fix Mixer Store/Recall
Two main problems are addressed by this commit.
First, storage of
parameters was broken because the index for values was set by the
parameter count, not the control port count which set_processor_param()
expects.
Second, the value was not clamped to pd.upper and pd.lower causing some
parameters to fail when set.
This invalidates previous mixer store files.
Diffstat (limited to 'share')
-rw-r--r-- | share/scripts/mixer_settings_recall.lua | 23 | ||||
-rw-r--r-- | share/scripts/mixer_settings_store.lua | 31 |
2 files changed, 38 insertions, 16 deletions
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 |