Mixer Save+Recall (Lua): support args for local+global separation
This commit is contained in:
parent
3387d127e7
commit
9a580078f0
@ -3,7 +3,7 @@ ardour {
|
|||||||
name = "Recall Mixer Settings",
|
name = "Recall Mixer Settings",
|
||||||
author = "Mixbus Team",
|
author = "Mixbus Team",
|
||||||
description = [[
|
description = [[
|
||||||
Recalls mixer settings outined by files
|
Recalls mixer settings files
|
||||||
created by Store Mixer Settings.
|
created by Store Mixer Settings.
|
||||||
|
|
||||||
Allows for some room to change Source
|
Allows for some room to change Source
|
||||||
@ -11,15 +11,25 @@ ardour {
|
|||||||
]]
|
]]
|
||||||
}
|
}
|
||||||
|
|
||||||
function factory ()
|
function factory (params)
|
||||||
|
|
||||||
local acoraida_monicas_last_used_recall_file
|
|
||||||
|
|
||||||
return function ()
|
return function ()
|
||||||
|
|
||||||
local user_cfg = ARDOUR.user_config_directory(-1)
|
local user_cfg = ARDOUR.user_config_directory(-1)
|
||||||
local local_path = ARDOUR.LuaAPI.build_filename(Session:path(), 'mixer_settings')
|
local folder_path = ARDOUR.LuaAPI.build_filename(Session:path(), 'mixer_settings')
|
||||||
local global_path = ARDOUR.LuaAPI.build_filename(user_cfg, 'mixer_settings')
|
|
||||||
|
local p = params or {}
|
||||||
|
local args = p[1] or ""
|
||||||
|
if args=="global_path" then
|
||||||
|
folder_path = ARDOUR.LuaAPI.build_filename(user_cfg, 'mixer_settings')
|
||||||
|
end
|
||||||
|
|
||||||
|
local snap_num = 0
|
||||||
|
for test = 0, 12, 1 do
|
||||||
|
if string.find(args, string.format("Scene_%d", test)) then
|
||||||
|
snap_num = test
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local invalidate = {}
|
local invalidate = {}
|
||||||
|
|
||||||
@ -370,27 +380,27 @@ function factory ()
|
|||||||
if do_route then
|
if do_route then
|
||||||
local route_id = instance["route_id"]
|
local route_id = instance["route_id"]
|
||||||
local route_name = instance["route_name"]
|
local route_name = instance["route_name"]
|
||||||
local dlg_title = ""
|
local src_name = string.format("%s", route_name)
|
||||||
|
|
||||||
local route_ptr = Session:route_by_id(PBD.ID(route_id))
|
local route_ptr = Session:route_by_id(PBD.ID(route_id))
|
||||||
|
|
||||||
if route_ptr:isnil() then
|
-- if route_ptr:isnil() then
|
||||||
route_ptr = Session:route_by_name(route_name)
|
-- route_ptr = Session:route_by_name(route_name)
|
||||||
if not(route_ptr:isnil()) then
|
-- if not(route_ptr:isnil()) then
|
||||||
dlg_title = string.format("%s", route_ptr:name())
|
-- dlg_title = string.format("%s", route_ptr:name())
|
||||||
|
-- --action_title = "will use route settings"
|
||||||
|
-- else
|
||||||
|
-- dlg_title = string.format("%s", route_name)
|
||||||
|
-- --action_title = "will be ignored"
|
||||||
|
-- end
|
||||||
|
-- else
|
||||||
|
-- dlg_title = string.format("%s", route_ptr:name())
|
||||||
--action_title = "will use route settings"
|
--action_title = "will use route settings"
|
||||||
else
|
-- end
|
||||||
dlg_title = string.format("%s", route_name)
|
|
||||||
--action_title = "will be ignored"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
dlg_title = string.format("%s", route_ptr:name())
|
|
||||||
--action_title = "will use route settings"
|
|
||||||
end
|
|
||||||
if route_ptr:isnil() then name = route_name else name = route_ptr:name() end
|
if route_ptr:isnil() then name = route_name else name = route_ptr:name() end
|
||||||
|
|
||||||
table.insert(dry_table, {
|
table.insert(dry_table, {
|
||||||
order=instance['pi_order']+pad, type = "label", align="right", key = "route-"..i , col = 0, colspan = 1, title = dlg_title
|
order=instance['pi_order']+pad, type = "label", align="right", key = "route-"..i , col = 0, colspan = 1, title = src_name
|
||||||
})
|
})
|
||||||
table.insert(dry_table, {
|
table.insert(dry_table, {
|
||||||
type = "dropdown", align="left", key = "destination-"..i, col = 1, colspan = 1, title = "", values = route_values, default = name or "----"
|
type = "dropdown", align="left", key = "destination-"..i, col = 1, colspan = 1, title = "", values = route_values, default = name or "----"
|
||||||
@ -398,93 +408,48 @@ function factory ()
|
|||||||
end
|
end
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
if (snap_num==0) then
|
||||||
table.insert(dry_table, {
|
table.insert(dry_table, {
|
||||||
type = "checkbox", col=0, colspan=2, align="left", key = "create_groups", default = true, title = "Create Groups if necessary?"
|
type = "checkbox", col=0, colspan=2, align="left", key = "create_groups", default = true, title = "Create Groups if necessary?"
|
||||||
})
|
})
|
||||||
|
end
|
||||||
return dry_table
|
return dry_table
|
||||||
end
|
end
|
||||||
|
|
||||||
local global_vs_local_dlg = {
|
|
||||||
{ type = "label", col=0, colspan=20, align="left", title = "" },
|
|
||||||
{
|
|
||||||
type = "radio", col=0, colspan=20, align="left", key = "recall-dir", title = "", values =
|
|
||||||
{
|
|
||||||
['Pick from Global Settings'] = 1, ['Pick from Local Settings'] = 2, ['Last Used Recall File'] = 3,
|
|
||||||
},
|
|
||||||
default = 'Last Used Recall File'
|
|
||||||
},
|
|
||||||
{ type = "label", col=0, colspan=20, align="left", title = ""},
|
|
||||||
}
|
|
||||||
|
|
||||||
local recall_options = {
|
local recall_options = {
|
||||||
{ type = "label", col=0, colspan=10, align="left", title = "" },
|
{ type = "label", col=0, colspan=10, align="left", title = "" },
|
||||||
{ type = "file", col=0, colspan=15, align="left", key = "file", title = "Select a Settings File", path = ARDOUR.LuaAPI.build_filename(Session:path(), "export", "params.lua") },
|
{ type = "file", col=0, colspan=15, align="left", key = "file", title = "Select a Settings File", path = ARDOUR.LuaAPI.build_filename(Session:path(), "export", "params.lua") },
|
||||||
{ type = "label", col=0, colspan=10, align="left", title = "" },
|
{ type = "label", col=0, colspan=10, align="left", title = "" },
|
||||||
}
|
}
|
||||||
|
|
||||||
local gvld = LuaDialog.Dialog("Recall Mixer Settings:", global_vs_local_dlg):run()
|
local default_path = ARDOUR.LuaAPI.build_filename(folder_path, 'asdf')
|
||||||
|
local file_name = "Scene_" .. snap_num
|
||||||
if not(gvld) then
|
local file_path = ARDOUR.LuaAPI.build_filename(folder_path, string.format("%s-%s.lua", file_name, whoami()))
|
||||||
return
|
if exists(folder_path) then
|
||||||
else
|
recall_options[2]['path'] = default_path
|
||||||
if gvld['recall-dir'] == 1 then
|
if (snap_num==0) then
|
||||||
local global_ok = isdir(global_path)
|
|
||||||
local global_default_path = ARDOUR.LuaAPI.build_filename(global_path, string.format("FactoryDefault-%s.lua", whoami()))
|
|
||||||
print(global_default_path)
|
|
||||||
if global_ok then
|
|
||||||
recall_options[2]['path'] = global_default_path
|
|
||||||
local rv = LuaDialog.Dialog("Recall Mixer Settings:", recall_options):run()
|
local rv = LuaDialog.Dialog("Recall Mixer Settings:", recall_options):run()
|
||||||
if not(rv) then return end
|
if not(rv) then return end
|
||||||
local dry_return = LuaDialog.Dialog("Recall Mixer Settings:", dry_run(false, rv['file'])):run()
|
file_name = rv['file']
|
||||||
|
file_path = rv['file']
|
||||||
|
print("About to load path " .. file_path)
|
||||||
|
end
|
||||||
|
local dry_return = LuaDialog.Dialog("Recall Mixer Settings:", dry_run(false, file_path)):run()
|
||||||
if dry_return then
|
if dry_return then
|
||||||
acoraida_monicas_last_used_recall_file = rv['file']
|
recall(false, file_path, dry_return) --set first arg TRUE for debug
|
||||||
recall(false, rv['file'], dry_return)
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
else
|
|
||||||
LuaDialog.Message ("Recall Mixer Settings:",
|
|
||||||
global_path .. ' does not exist!\nPlease run Store Mixer Settings first.',
|
|
||||||
LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if gvld['recall-dir'] == 2 then
|
|
||||||
local local_ok = isdir(local_path)
|
|
||||||
local local_default_path = ARDOUR.LuaAPI.build_filename(local_path, 'asdf')
|
|
||||||
print(local_default_path)
|
|
||||||
if local_ok then
|
|
||||||
recall_options[2]['path'] = local_default_path
|
|
||||||
local rv = LuaDialog.Dialog("Recall Mixer Settings:", recall_options):run()
|
|
||||||
if not(rv) then return end
|
|
||||||
local dry_return = LuaDialog.Dialog("Recall Mixer Settings:", dry_run(false, rv['file'])):run()
|
|
||||||
if dry_return then
|
|
||||||
acoraida_monicas_last_used_recall_file = rv['file']
|
|
||||||
recall(true, rv['file'], dry_return)
|
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
if (snap_num==0) then
|
||||||
LuaDialog.Message ("Recall Mixer Settings:",
|
LuaDialog.Message ("Recall Mixer Settings:",
|
||||||
local_path .. 'does not exist!\nPlease run Store Mixer Settings first.',
|
local_path .. 'does not exist!\nPlease run Store Mixer Settings first.',
|
||||||
LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
|
LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if gvld['recall-dir'] == 3 then
|
|
||||||
if acoraida_monicas_last_used_recall_file then
|
|
||||||
local dry_return = LuaDialog.Dialog("Recall Mixer Settings:", dry_run(false, acoraida_monicas_last_used_recall_file)):run()
|
|
||||||
if dry_return then
|
|
||||||
recall(true, acoraida_monicas_last_used_recall_file, dry_return)
|
|
||||||
else
|
else
|
||||||
return
|
LuaDialog.Message ("Recall Mixer Settings:",
|
||||||
end
|
"Mixer Snap " .. snap_num .. " does not exist yet.",
|
||||||
else
|
|
||||||
LuaDialog.Message ("Script has no record of last used file:",
|
|
||||||
'Please pick a recall file and then this option will be available',
|
|
||||||
LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
|
LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end end
|
end end
|
||||||
|
@ -5,7 +5,7 @@ ardour {
|
|||||||
description = [[
|
description = [[
|
||||||
Stores the current Mixer state as a file
|
Stores the current Mixer state as a file
|
||||||
that can be read and recalled arbitrarily
|
that can be read and recalled arbitrarily
|
||||||
by it's companion script, Recall Mixer Settings.
|
by its companion script, Recall Mixer Settings.
|
||||||
|
|
||||||
Supports: processor settings, grouping,
|
Supports: processor settings, grouping,
|
||||||
mute, solo, gain, trim, pan and processor ordering,
|
mute, solo, gain, trim, pan and processor ordering,
|
||||||
@ -13,11 +13,18 @@ ardour {
|
|||||||
]]
|
]]
|
||||||
}
|
}
|
||||||
|
|
||||||
function factory () return function ()
|
function factory (params)
|
||||||
|
|
||||||
|
return function ()
|
||||||
|
|
||||||
local user_cfg = ARDOUR.user_config_directory(-1)
|
local user_cfg = ARDOUR.user_config_directory(-1)
|
||||||
local local_path = ARDOUR.LuaAPI.build_filename(Session:path(), 'mixer_settings')
|
local folder_path = ARDOUR.LuaAPI.build_filename(Session:path(), 'mixer_settings')
|
||||||
local global_path = ARDOUR.LuaAPI.build_filename(user_cfg, 'mixer_settings')
|
|
||||||
|
local p = params or {}
|
||||||
|
local args = p[1] or ""
|
||||||
|
if args=="global_path" then
|
||||||
|
folder_path = ARDOUR.LuaAPI.build_filename(user_cfg, 'mixer_settings')
|
||||||
|
end
|
||||||
|
|
||||||
function exists(file)
|
function exists(file)
|
||||||
local ok, err, code = os.rename(file, file)
|
local ok, err, code = os.rename(file, file)
|
||||||
@ -46,25 +53,17 @@ function factory () return function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function setup_paths()
|
function setup_paths()
|
||||||
local global_ok, local_ok = false, false
|
local local_ok = false
|
||||||
|
|
||||||
if not(isdir(global_path)) then
|
if not(isdir(folder_path)) then
|
||||||
global_ok, _, _ = os.execute('mkdir '.. global_path)
|
local_ok, _, _ = os.execute('mkdir '.. folder_path)
|
||||||
if global_ok == 0 then
|
|
||||||
global_ok = true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
global_ok = true
|
|
||||||
end
|
|
||||||
if not(isdir(local_path)) then
|
|
||||||
local_ok, _, _ = os.execute('mkdir '.. local_path)
|
|
||||||
if local_ok == 0 then
|
if local_ok == 0 then
|
||||||
local_ok = true
|
local_ok = true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local_ok = true
|
local_ok = true
|
||||||
end
|
end
|
||||||
return global_ok, local_ok
|
return local_ok
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_processor_by_name(track, name)
|
function get_processor_by_name(track, name)
|
||||||
@ -351,41 +350,37 @@ function factory () return function ()
|
|||||||
local store_options = {
|
local store_options = {
|
||||||
{ type = "label", col=0, colspan=1, align="right", title = "Name:" },
|
{ type = "label", col=0, colspan=1, align="right", title = "Name:" },
|
||||||
{ type = "entry", col=1, colspan=1, align="left" , key = "filename", default = Session:name(), title=""},
|
{ type = "entry", col=1, colspan=1, align="left" , key = "filename", default = Session:name(), title=""},
|
||||||
{ type = "label", col=0, colspan=1, align="right", title = "Location:" },
|
|
||||||
{
|
|
||||||
type = "radio", col=1, colspan=3, align="left", key = "store-dir", title = "", values =
|
|
||||||
{
|
|
||||||
['Global (accessible from any session)'] = 1, ['Local (this session only)'] = 2
|
|
||||||
},
|
|
||||||
default = 'Locally (this session only)'
|
|
||||||
},
|
|
||||||
{ type = "hseparator", title="", col=0, colspan = 3},
|
{ type = "hseparator", title="", col=0, colspan = 3},
|
||||||
{ type = "label", col=0, colspan=1, align="right", title = "Selected Tracks Only:" },
|
{ type = "label", col=0, colspan=1, align="right", title = "Selected Tracks Only:" },
|
||||||
{ type = "checkbox", col=1, colspan=1, align="left", key = "selected", default = false, title = ""},
|
{ type = "checkbox", col=1, colspan=1, align="left", key = "selected", default = false, title = ""},
|
||||||
--{ type = "label", col=0, colspan=2, align="left", title = ''},
|
--{ type = "label", col=0, colspan=2, align="left", title = ''},
|
||||||
--{ type = "label", col=0, colspan=2, align="left", title = "Global Path: " .. global_path},
|
--{ type = "label", col=0, colspan=2, align="left", title = "Global Path: " .. global_path},
|
||||||
--{ type = "label", col=0, colspan=2, align="left", title = "Local Path: " .. local_path},
|
--{ type = "label", col=0, colspan=2, align="left", title = "Local Path: " .. folder_path},
|
||||||
}
|
}
|
||||||
|
|
||||||
local global_ok, local_ok = setup_paths()
|
local snap_num = 0
|
||||||
|
for test = 0, 12, 1 do
|
||||||
if global_ok and local_ok then
|
if string.find(args, string.format("Scene_%d", test)) then
|
||||||
local rv = LuaDialog.Dialog("Store Mixer Settings:", store_options):run()
|
snap_num = test
|
||||||
|
end
|
||||||
if not(rv) then return end
|
|
||||||
|
|
||||||
local filename = rv['filename']
|
|
||||||
if rv['store-dir'] == 1 then
|
|
||||||
local store_path = ARDOUR.LuaAPI.build_filename(global_path, string.format("%s-%s.lua", filename, whoami()))
|
|
||||||
local selected = rv['selected']
|
|
||||||
mark_tracks(selected, store_path)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if rv['store-dir'] == 2 then
|
local paths_ok = setup_paths()
|
||||||
local store_path = ARDOUR.LuaAPI.build_filename(local_path, string.format("%s-%s.lua", filename, whoami()))
|
local filename = "Scene_" .. snap_num
|
||||||
print(store_path)
|
local selected = false --we store 'all' routes and let the user pick what to recall later
|
||||||
local selected = rv['selected']
|
if paths_ok then
|
||||||
|
if (snap_num==0) then
|
||||||
|
local rv = LuaDialog.Dialog("Store Mixer Settings:", store_options):run()
|
||||||
|
if not(rv) then return end
|
||||||
|
filename = rv['filename']
|
||||||
|
selected = rv['selected']
|
||||||
|
end
|
||||||
|
|
||||||
|
local store_path = ARDOUR.LuaAPI.build_filename(folder_path, string.format("%s-%s.lua", filename, whoami()))
|
||||||
mark_tracks(selected, store_path)
|
mark_tracks(selected, store_path)
|
||||||
|
if (snap_num ~= 0) then
|
||||||
|
LuaDialog.Message ("Mixer Scenes: Store", "Stored mixer settings to: " .. store_path,
|
||||||
|
LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user