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.
This commit is contained in:
Nikolaus Gullotta 2020-04-15 13:38:33 -05:00
parent 250da353d4
commit 858bb4294d
No known key found for this signature in database
GPG key ID: C1580877951565A3
2 changed files with 38 additions and 16 deletions

View file

@ -275,18 +275,29 @@ function factory ()
if proc:isnil() then goto nextline end if proc:isnil() then goto nextline end
local plug = proc:to_insert():plugin(0) local plug = proc:to_insert():plugin(0)
for k, v in pairs(params) do local ctl = 0
local label = plug:parameter_label(k) 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? 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 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 end
print(string.format("%s (Port: %s) -> %s", label, k, v))
ARDOUR.LuaAPI.set_processor_param(proc, k, v)
end end
for k, v in pairs(enable) do for k, v in pairs(enable) do
ARDOUR.LuaAPI.set_processor_param(proc, k, v) ARDOUR.LuaAPI.set_processor_param(proc, k, v)
end end
if act then proc:activate() else proc:deactivate() end if act then proc:activate() else proc:deactivate() end
end end

View file

@ -301,15 +301,26 @@ function factory () return function ()
local id = proc:to_stateful():id():to_s() local id = proc:to_stateful():id():to_s()
local plug = proc:to_insert ():plugin (0) local plug = proc:to_insert ():plugin (0)
local ptype = proc:to_insert():plugin(0):get_info().type 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 local n = 0
if plug:parameter_is_control (j) then for j = 0, plug:parameter_count() - 1 do -- Iterate over all plugin parameters
local label = plug:parameter_label (j) if plug:parameter_is_control(j) then
if plug:parameter_is_input (j) and label ~= "hidden" and label:sub (1,1) ~= "#" then local label = plug:parameter_label(j)
--local _, _, pd = ARDOUR.LuaAPI.plugin_automation(proc, n) if plug:parameter_is_input(j) and label ~= "hidden" and label:sub(1,1) ~= "#" then
local val = ARDOUR.LuaAPI.get_processor_param(proc, j, true) local _, _, pd = ARDOUR.LuaAPI.plugin_automation(proc, n)
print(r:name(), "->", proc:display_name(), label, val) local val = ARDOUR.LuaAPI.get_processor_param(proc, n, true)
params[j] = val
-- 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 end
n = n + 1 n = n + 1
end end