From e2e560ef06b4be7ac400d99fe1c6e45513db4bc0 Mon Sep 17 00:00:00 2001 From: Nikolaus Gullotta Date: Fri, 17 Aug 2018 08:47:51 -0500 Subject: stop trying to guess plugin type, just ask the plugin during store-time --- scripts/mixer_settings_recall.lua | 15 ++++++++------- scripts/mixer_settings_store.lua | 23 +++++++++++++---------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/scripts/mixer_settings_recall.lua b/scripts/mixer_settings_recall.lua index a15333b1b4..a299c63f6b 100644 --- a/scripts/mixer_settings_recall.lua +++ b/scripts/mixer_settings_recall.lua @@ -60,11 +60,9 @@ function factory () return function () until proc:isnil() 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 + function new_plugin(name, type) + local plugin = ARDOUR.LuaAPI.new_plugin(Session, name, type, "") + if not(plugin:isnil()) then return plugin end end function group_by_id(id) @@ -187,9 +185,11 @@ function factory () return function () proc = Session:processor_by_id(PBD.ID(v)) end 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 - proc = new_plugin(name) + proc = new_plugin(name, type) for _, control in pairs(well_known) do if name == control then 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? enable[k] = v --queue any assignments/enables for after the initial parameter recalling to duck the 'in-on-change' feature end + print(string.format("%s (Port: %s) -> %s", label, k, v)) ARDOUR.LuaAPI.set_processor_param(proc, k, v) end diff --git a/scripts/mixer_settings_store.lua b/scripts/mixer_settings_store.lua index ff861e4f43..0236e820bf 100644 --- a/scripts/mixer_settings_store.lua +++ b/scripts/mixer_settings_store.lua @@ -82,13 +82,6 @@ function factory () return function () until proc:isnil() 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) local id = tonumber(id) 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 local file = io.open(path, "w") + --file:write(string.format("instance = { whoami = '%s' }", whoami()) file:write("") file:close() end @@ -153,6 +147,7 @@ function factory () return function () local processor_string = [[instance = { plugin_id = %d, + type = %d, display_name = '%s', owned_by_route_name = '%s', owned_by_route_id = %d, @@ -162,7 +157,7 @@ function factory () return function () local group_route_string = " [%d] = %s," local proc_order_string = " [%d] = %d," - local proc_cache_string = " [%d] = '%s'," + local proc_cache_string = " [%d] = {'%s', %d}," local params_string = " [%d] = %s," --ensure easy-to-read formatting doesn't make it through @@ -225,6 +220,7 @@ function factory () return function () x = x + 1 until proc:isnil() + local route_group = route_group_interrogate(r) if route_group then route_group = route_group:name() else route_group = "" end local rid = r:to_stateful():id():to_s() @@ -234,10 +230,15 @@ function factory () return function () local order_nmbr = 0 local tmp_order_str, tmp_cache_str = "", "" 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() if not(string.find(p:display_name(), "latcomp")) then 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 order_nmbr = order_nmbr + 1 end @@ -270,6 +271,7 @@ function factory () return function () local active = proc:active() local id = proc:to_stateful():id():to_s() local plug = proc:to_insert ():plugin (0) + local type = 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 @@ -277,7 +279,7 @@ function factory () return function () 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) + print(r:name(), "->", proc:display_name(), label, val) params[n] = val end n = n + 1 @@ -293,6 +295,7 @@ function factory () return function () local proc_str = string.format( processor_string, id, + type, proc:display_name(), r:name(), r:to_stateful():id():to_s(), -- cgit v1.2.3