summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNikolaus Gullotta <nik@harrisonconsoles.com>2020-01-09 13:54:23 -0600
committerNikolaus Gullotta <nik@harrisonconsoles.com>2020-01-09 13:54:43 -0600
commitdac127c8972b08996d89d73738939240b4eba9f2 (patch)
treecb21edba7a7af6ca5e5337a23c2f7d24daac50cb /scripts
parent0771717dd53a8495683821963cb9189679a64a24 (diff)
Update reset_mixer script to use new well-known controls
Diffstat (limited to 'scripts')
-rw-r--r--scripts/reset_mixer.lua294
1 files changed, 180 insertions, 114 deletions
diff --git a/scripts/reset_mixer.lua b/scripts/reset_mixer.lua
index 56c2d75605..d3b3717d4d 100644
--- a/scripts/reset_mixer.lua
+++ b/scripts/reset_mixer.lua
@@ -1,139 +1,205 @@
ardour {
- ["type"] = "EditorAction",
- name = "Reset Mixer",
- author = "Ben Loftis, Nikolaus Gullotta, Maxime Lecoq",
+ ["type"] = "EditorAction",
+ name = "Reset Mixer",
+ license = "MIT",
+ author = "Ben Loftis, Nikolaus Gullotta, Maxime Lecoq",
description = [[Resets key Mixer settings after user-prompt (warning: this cannot be undone)]]
}
function factory() return function()
-
- local sp_radio_buttons = { Unreset="unreset", Bypass="bypass", Remove="remove" }
-
+ local sp_radio_buttons = {Bypass="bypass", Remove="remove", Nothing=false}
local dlg = {
- { type = "label", align ="left", colspan="3", title = "Please select below the items you want to reset:" },
- { type = "label", align ="left", colspan="3", title = "(Warning: this cannot be undone!)\n" },
-
- { type = "label", align ="left", colspan="3", title = "Levels:" },
- { type = "checkbox", key = "fader", default = false, title = "Fader" },
- { type = "checkbox", key = "mute", default = false, title = "Mute" },
- { type = "checkbox", key = "solo", default = false, title = "Solo" },
- { type = "checkbox", key = "trim", default = false, title = "Trim + Phase" },
-
- { type = "label", align ="left", colspan="3", title = "\nPan:" },
- { type = "checkbox", key = "pan", default = false, title = "Pan" },
- { type = "checkbox", key = "panwidth", default = false, title = "Pan width" },
-
- { type = "label", align ="left", colspan="3", title = "\nSignal processors:" },
- { type = "radio", key = "sends", title = "Sends", values=sp_radio_buttons, default="Unreset" },
- { type = "radio", key = "inserts", title = "Inserts", values=sp_radio_buttons, default="Unreset" },
- { type = "radio", key = "plug-ins", title = "Plug-ins", values=sp_radio_buttons, default="Unreset" },
-
- { type = "label", align ="left", colspan="3", title = "\nAutomation (switch to manual mode):" },
- { type = "checkbox", key = "autogain", default = false, title = "Gain" },
- { type = "checkbox", key = "autopan", default = false, title = "Pan" },
- { type = "checkbox", key = "autopanwidth", default = false, title = "Pan width" },
-
- { type = "label", align ="left", colspan="3", title = "" },
- }
+ {type="label", align="left", colspan="3", title="Please select below the items you want to reset:" },
+ {type="label", align="left", colspan="3", title="(Warning: this cannot be undone!)\n" },
- local pref = LuaDialog.Dialog("Reset Mixer", dlg):run()
-
- if not(pref) then goto pass_script end
- assert(pref, 'Dialog box was cancelled or is ' .. type(pref))
-
- -- Manage signal processors state or removal according
- -- to the user prompt settings and log trace.
- function handle_processor(effect_type_name, track, proc)
- local action_name = pref[effect_type_name]
- local proc_name = proc:display_name()
- local track_name = track:name()
- local proc_handled = false
+ {type="heading", align ="center", colspan="3", title = "Common Controls:" },
+ {type="checkbox", key="fader", default=true, title="Fader" },
+ {type="checkbox", key="mute", default=true, title="Mute" },
+ {type="checkbox", key="solo", default=true, title="Solo" },
+ {type="checkbox", key="trim", default=true, title="Trim" },
+ {type="checkbox", key="pan", default=true, title="Pan (All)" },
+ {type="checkbox", key="phase", default=true, title="Phase" },
+ {type="checkbox", key="sends", default=true, title="Sends" },
+ {type="checkbox", key="eq", default=true, title="EQ" },
+ {type="checkbox", key="comp", default=true, title="Compressor" },
+
+ {type="heading", align="center", colspan="3", title="Processors:" },
+ {type="radio", key="plugins", title="Plug-ins", values=sp_radio_buttons, default="Bypass" },
+ {type="radio", key="io", title="Sends/Inserts", values=sp_radio_buttons, default="Bypass" },
+
+ {type="hseparator", title=""},
- if(action_name == "bypass") then
- if(proc:active()) then
- proc:deactivate()
- proc_handled = true
+ {type="heading", align="center", colspan="3", title="Misc." },
+ {type="checkbox", key="auto", colspan="3", title = "Automation (switch to manual mode)" },
+ {type="checkbox", key="groups", colspan="3", title = "Groups" },
+ }
+
+ function reset(ctrl, disp, auto)
+ local disp = disp or PBD.GroupControlDisposition.NoGroup
+
+ if not(ctrl:isnil()) then
+ local pd = ctrl:desc()
+ ctrl:set_value(pd.normal, disp)
+
+ if auto then
+ ctrl:set_automation_state(auto)
end
- elseif(action_name == "remove") then
- track:remove_processor(proc, nil, true)
- proc_handled = true
end
-
- if(proc_handled) then print(action_name, effect_type_name, proc_name, "on track", track_name) end
end
-
- -- solo
- -- (could be handled in track loop but it's simplier to do it on the session)
- if pref["solo"] then Session:cancel_all_solo() end
-
- -- loop over all tracks
- for t in Session:get_routes():iter() do
+
+ function reset_eq_controls(route, disp, auto)
+ if route:isnil() then
+ return
+ end
- if not t:is_monitor() and not t:is_auditioner() then
-
- -- automation first
- if pref["autogain"] then t:gain_control():set_automation_state(ARDOUR.AutoState.Off) end
- if pref["autopan"] then t:pan_azimuth_control():set_automation_state(ARDOUR.AutoState.Off) end
- if pref["autopanwidth"] then
- local pwc = t:pan_width_control()
- if(not pwc:isnil()) then -- careful stereo track
- pwc:set_automation_state(ARDOUR.AutoState.Off)
- end
- end
-
- -- levels
- if pref["fader"] then t:gain_control():set_value(1, 1) end
- if pref["trim"] then
- t:trim_control():set_value(1, 1)
- t:phase_control():set_value(0, 1)
- end
- if pref["mute"] then t:mute_control():set_value(0, 1) end
-
- -- pan
- if not(t:pan_azimuth_control():isnil()) then
- if pref["pan"] then t:pan_azimuth_control():set_value(0.5, 1) end
+ local disp = disp or PBD.GroupControlDisposition.NoGroup
+
+ reset(route:eq_enable_controllable(), disp, auto)
+
+ local i = 0
+ repeat
+ for _,ctrl in pairs({
+ route:eq_freq_controllable(i),
+ route:eq_gain_controllable(i),
+ route:eq_q_controllable(i),
+ }) do
+ reset(ctrl, disp, auto)
end
- if not(t:pan_width_control():isnil()) then
- if pref["panwidth"] then t:pan_width_control():set_value(1, 1) end
+ i = i + 1
+ until route:eq_freq_controllable(i):isnil()
+ end
+
+ function reset_comp_controls(route, disp, auto)
+ if route:isnil() then
+ return
+ end
+
+ local disp = disp or PBD.GroupControlDisposition.NoGroup
+
+ for _,ctrl in pairs({
+ route:comp_enable_controllable(),
+ route:comp_makeup_controllable(),
+ route:comp_mode_controllable(),
+ route:comp_speed_controllable(),
+ route:comp_threshold_controllable(),
+ }) do
+ reset(ctrl, disp, auto)
+ end
+ end
+
+ function reset_send_controls(route, disp, auto)
+ if route:isnil() then
+ return
+ end
+
+ local disp = disp or PBD.GroupControlDisposition.NoGroup
+
+ local i = 0
+ repeat
+ for _,ctrl in pairs({
+ route:send_level_controllable(i),
+ route:send_enable_controllable(i),
+ route:send_pan_azimuth_controllable(i),
+ route:send_pan_azimuth_enable_controllable(i),
+ }) do
+ reset(ctrl, disp, auto)
end
+ i = i + 1
+ until route:send_enable_controllable(i):isnil()
+ end
+
+ function reset_plugins(route, prefs)
+ if route:isnil() then
+ return
+ end
- -- signal processors management
- i = 0
- local proc = t:nth_processor (i)
-
- -- collect user procs
- repeat -- loop over the track procs
-
- -- send
- if not(proc:to_ioprocessor():isnil()) then
- --check if processor is a send or insert
- if proc:to_ioprocessor():display_to_user() then
- handle_processor("sends", t, proc)
+ local i = 0
+ repeat
+ local proc = route:nth_processor(i)
+ if not(proc:isnil()) then
+
+ if prefs["plugins"] then
+ local insert = proc:to_insert()
+ if not(insert:isnil()) then
+ if insert:is_channelstrip() or not(insert:display_to_user()) then
+ ARDOUR.LuaAPI.reset_processor_to_default(insert)
+ else
+ if prefs["plugins"] == "remove" then
+ route:remove_processor(proc, nil, true)
+ else
+ insert:deactivate()
+ end
+ end
end
end
- -- insert
- if not(proc:to_insert():isnil()) then
- --check if processor is foreign to us
- if not(proc:to_insert():display_to_user()) then
- handle_processor("inserts", t, proc)
+ if prefs["io"] then
+ local io_proc = proc:to_ioprocessor()
+ if not(io_proc:isnil()) then
+ if prefs["io"] == "remove" then
+ route:remove_processor(proc, nil, true)
+ else
+ io_proc:deactivate()
+ end
end
end
-
- -- regular user plug-in
- if not(proc:to_plugininsert():isnil()) then
- handle_processor("plug-ins", t, proc)
- end
+ end
+ i = i + 1
+ until proc:isnil()
+ end
- -- prepare the next proc to be inspected
- i = i + 1
- proc = t:nth_processor(i)
-
- until proc:isnil() -- end repeat track procs
-
- end -- if monitor or auditioner
+ local pref = LuaDialog.Dialog("Reset Mixer", dlg):run()
+
+ if not(pref) then goto pass_script end
+ assert(pref, "Dialog box was cancelled or is nil")
+
+ for route in Session:get_routes():iter() do
+ local disp = PBD.GroupControlDisposition.NoGroup
+ local auto = nil
+
+ if pref["auto"] then
+ auto = ARDOUR.AutoState.Off
+ end
- end -- loop over all tracks
+ if pref["eq"] then reset_eq_controls(route, disp, auto) end
+ if pref["comp"] then reset_comp_controls(route, disp, auto) end
+ if pref["sends"] then reset_send_controls(route, disp, auto) end
+ reset_plugins(route, pref)
+
+ if pref["fader"] then
+ reset(route:gain_control(), disp, auto)
+ end
+
+ if pref["phase"] then
+ reset(route:phase_control(), disp, auto)
+ end
+
+ if pref["trim"] then
+ reset(route:trim_control(), disp, auto)
+ end
+
+ if pref["mute"] then
+ reset(route:mute_control(), disp, auto)
+ end
+
+ if pref["solo"] then
+ reset(route:solo_control(), disp, auto)
+ end
+
+ if pref["pan"] then
+ reset(route:pan_azimuth_control(), disp, auto)
+ reset(route:pan_elevation_control(), disp, auto)
+ reset(route:pan_frontback_control(), disp, auto)
+ reset(route:pan_lfe_control(), disp, auto)
+ reset(route:pan_width_control(), disp, auto)
+ end
+ end
+
+ if pref["groups"] then
+ for group in Session:route_groups():iter() do
+ Session:remove_route_group(group)
+ end
+ end
::pass_script::
collectgarbage()
end end \ No newline at end of file