stop trying to guess plugin type, just ask the plugin during store-time

This commit is contained in:
Nikolaus Gullotta 2018-08-17 08:47:51 -05:00
parent 904d594712
commit e2e560ef06
2 changed files with 21 additions and 17 deletions

View file

@ -60,11 +60,9 @@ function factory () return function ()
until proc:isnil() until proc:isnil()
end end
function new_plugin(name) function new_plugin(name, type)
for x = 0, 6 do local plugin = ARDOUR.LuaAPI.new_plugin(Session, name, type, "")
local plugin = ARDOUR.LuaAPI.new_plugin(Session, name, x, "") if not(plugin:isnil()) then return plugin end
if not(plugin:isnil()) then return plugin end
end
end end
function group_by_id(id) function group_by_id(id)
@ -187,9 +185,11 @@ function factory () return function ()
proc = Session:processor_by_id(PBD.ID(v)) proc = Session:processor_by_id(PBD.ID(v))
end end
if proc:isnil() then if proc:isnil() then
for id, name in pairs(cache) do for id, sub_tbl in pairs(cache) do
local name = sub_tbl[1]
local type = sub_tbl[2]
if v == id then if v == id then
proc = new_plugin(name) proc = new_plugin(name, type)
for _, control in pairs(well_known) do for _, control in pairs(well_known) do
if name == control then if name == control then
proc = get_processor_by_name(rt, control) proc = get_processor_by_name(rt, control)
@ -253,6 +253,7 @@ function factory () return function ()
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[k] = v --queue any assignments/enables for after the initial parameter recalling to duck the 'in-on-change' feature
end end
print(string.format("%s (Port: %s) -> %s", label, k, v))
ARDOUR.LuaAPI.set_processor_param(proc, k, v) ARDOUR.LuaAPI.set_processor_param(proc, k, v)
end end

View file

@ -82,13 +82,6 @@ function factory () return function ()
until proc:isnil() until proc:isnil()
end end
function new_plugin(name)
for x = 0, 6 do
local plugin = ARDOUR.LuaAPI.new_plugin(Session, name, x, "")
if not(plugin:isnil()) then return plugin end
end
end
function group_by_id(id) function group_by_id(id)
local id = tonumber(id) local id = tonumber(id)
for g in Session:route_groups():iter() do for g in Session:route_groups():iter() do
@ -122,6 +115,7 @@ function factory () return function ()
function empty_last_store(path) --empty current file from last run function empty_last_store(path) --empty current file from last run
local file = io.open(path, "w") local file = io.open(path, "w")
--file:write(string.format("instance = { whoami = '%s' }", whoami())
file:write("") file:write("")
file:close() file:close()
end end
@ -153,6 +147,7 @@ function factory () return function ()
local processor_string = [[instance = { local processor_string = [[instance = {
plugin_id = %d, plugin_id = %d,
type = %d,
display_name = '%s', display_name = '%s',
owned_by_route_name = '%s', owned_by_route_name = '%s',
owned_by_route_id = %d, owned_by_route_id = %d,
@ -162,7 +157,7 @@ function factory () return function ()
local group_route_string = " [%d] = %s," local group_route_string = " [%d] = %s,"
local proc_order_string = " [%d] = %d," local proc_order_string = " [%d] = %d,"
local proc_cache_string = " [%d] = '%s'," local proc_cache_string = " [%d] = {'%s', %d},"
local params_string = " [%d] = %s," local params_string = " [%d] = %s,"
--ensure easy-to-read formatting doesn't make it through --ensure easy-to-read formatting doesn't make it through
@ -225,6 +220,7 @@ function factory () return function ()
x = x + 1 x = x + 1
until proc:isnil() until proc:isnil()
local route_group = route_group_interrogate(r) local route_group = route_group_interrogate(r)
if route_group then route_group = route_group:name() else route_group = "" end if route_group then route_group = route_group:name() else route_group = "" end
local rid = r:to_stateful():id():to_s() local rid = r:to_stateful():id():to_s()
@ -234,10 +230,15 @@ function factory () return function ()
local order_nmbr = 0 local order_nmbr = 0
local tmp_order_str, tmp_cache_str = "", "" local tmp_order_str, tmp_cache_str = "", ""
for p in order:iter() do for p in order:iter() do
if not(p:to_insert():isnil()) then
type = p:to_insert():plugin(0):get_info().type
else
type = 99
end
local pid = p:to_stateful():id():to_s() local pid = p:to_stateful():id():to_s()
if not(string.find(p:display_name(), "latcomp")) then if not(string.find(p:display_name(), "latcomp")) then
tmp_order_str = tmp_order_str .. string.format(proc_order_string, order_nmbr, pid) tmp_order_str = tmp_order_str .. string.format(proc_order_string, order_nmbr, pid)
tmp_cache_str = tmp_cache_str .. string.format(proc_cache_string, pid, p:display_name()) tmp_cache_str = tmp_cache_str .. string.format(proc_cache_string, pid, p:display_name(), type)
end end
order_nmbr = order_nmbr + 1 order_nmbr = order_nmbr + 1
end end
@ -270,6 +271,7 @@ function factory () return function ()
local active = proc:active() local active = proc:active()
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 type = proc:to_insert():plugin(0):get_info().type
local n = 0 -- count control-ports local n = 0 -- count control-ports
for j = 0, plug:parameter_count () - 1 do -- iterate over all plugin parameters for j = 0, plug:parameter_count () - 1 do -- iterate over all plugin parameters
if plug:parameter_is_control (j) then if plug:parameter_is_control (j) then
@ -277,7 +279,7 @@ function factory () return function ()
if plug:parameter_is_input (j) and label ~= "hidden" and label:sub (1,1) ~= "#" then if plug:parameter_is_input (j) and label ~= "hidden" and label:sub (1,1) ~= "#" then
local _, _, pd = ARDOUR.LuaAPI.plugin_automation(proc, n) local _, _, pd = ARDOUR.LuaAPI.plugin_automation(proc, n)
local val = ARDOUR.LuaAPI.get_processor_param(proc, j, true) local val = ARDOUR.LuaAPI.get_processor_param(proc, j, true)
--print(r:name(), "->", proc:display_name(), label, val) print(r:name(), "->", proc:display_name(), label, val)
params[n] = val params[n] = val
end end
n = n + 1 n = n + 1
@ -293,6 +295,7 @@ function factory () return function ()
local proc_str = string.format( local proc_str = string.format(
processor_string, processor_string,
id, id,
type,
proc:display_name(), proc:display_name(),
r:name(), r:name(),
r:to_stateful():id():to_s(), r:to_stateful():id():to_s(),