ardour {\r
["type"] = "EditorAction",\r
name = "Reset Mixer",\r
- author = "Ben Loftis, Nikolaus Gullotta",\r
+ author = "Ben Loftis, Nikolaus Gullotta, Maxime Lecoq",\r
description = [[Resets key Mixer settings after user-prompt (warning: this cannot be undone)]]\r
}\r
\r
function factory() return function()\r
+ \r
+ local sp_radio_buttons = { Unreset="unreset", Bypass="bypass", Remove="remove" }\r
\r
local dlg = {\r
- { type = "label", align ="left", colspan="3", title = "Select the items to reset:" },\r
- { type = "checkbox", key = "fader", default = true, title = "Fader" },\r
- { type = "checkbox", key = "mute", default = true, title = "Mute" },\r
- { type = "checkbox", key = "trim", default = true, title = "Trim + Phase" },\r
- { type = "checkbox", key = "plug", default = true, title = "Plug-ins" },\r
- { type = "checkbox", key = "sends", default = true, title = "Sends and inserts" },\r
- { type = "checkbox", key = "dest", default = false, title = "Remove plug-ins instead of bypassing?" },\r
+ { type = "label", align ="left", colspan="3", title = "Please select below the items you want to reset:" },\r
+ { type = "label", align ="left", colspan="3", title = "(Warning: this cannot be undone!)\n" },\r
+\r
+ { type = "label", align ="left", colspan="3", title = "Levels:" },\r
+ { type = "checkbox", key = "fader", default = false, title = "Fader" },\r
+ { type = "checkbox", key = "mute", default = false, title = "Mute" },\r
+ { type = "checkbox", key = "solo", default = false, title = "Solo" },\r
+ { type = "checkbox", key = "trim", default = false, title = "Trim + Phase" },\r
+\r
+ { type = "label", align ="left", colspan="3", title = "\nPan:" },\r
+ { type = "checkbox", key = "pan", default = false, title = "Pan" },\r
+ { type = "checkbox", key = "panwidth", default = false, title = "Pan width" },\r
+\r
+ { type = "label", align ="left", colspan="3", title = "\nSignal processors:" },\r
+ { type = "radio", key = "sends", title = "Sends", values=sp_radio_buttons, default="Unreset" },\r
+ { type = "radio", key = "inserts", title = "Inserts", values=sp_radio_buttons, default="Unreset" },\r
+ { type = "radio", key = "plug-ins", title = "Plug-ins", values=sp_radio_buttons, default="Unreset" },\r
+\r
+ { type = "label", align ="left", colspan="3", title = "\nAutomation (switch to manual mode):" },\r
+ { type = "checkbox", key = "autogain", default = false, title = "Gain" },\r
+ { type = "checkbox", key = "autopan", default = false, title = "Pan" },\r
+ { type = "checkbox", key = "autopanwidth", default = false, title = "Pan width" },\r
+\r
+ { type = "label", align ="left", colspan="3", title = "" },\r
}\r
\r
local pref = LuaDialog.Dialog("Reset Mixer", dlg):run()\r
- if not(pref) then goto end_script end\r
+ \r
+ if not(pref) then goto pass_script end\r
assert(pref, 'Dialog box was cancelled or is ' .. type(pref))\r
-\r
- Session:cancel_all_solo()\r
+ \r
+ -- Manage signal processors state or removal according\r
+ -- to the user prompt settings and log trace.\r
+ function handle_processor(effect_type_name, track, proc)\r
+ local action_name = pref[effect_type_name]\r
+ local proc_name = proc:display_name()\r
+ local track_name = track:name()\r
+ local proc_handled = false\r
+ \r
+ if(action_name == "bypass") then\r
+ if(proc:active()) then \r
+ proc:deactivate()\r
+ proc_handled = true\r
+ end\r
+ elseif(action_name == "remove") then\r
+ track:remove_processor(proc, nil, true)\r
+ proc_handled = true\r
+ end\r
+ \r
+ if(proc_handled) then print(action_name, effect_type_name, proc_name, "on track", track_name) end\r
+ end\r
+ \r
+ -- solo\r
+ -- (could be handled in track loop but it's simplier to do it on the session)\r
+ if pref["solo"] then Session:cancel_all_solo() end\r
+ \r
-- loop over all tracks\r
for t in Session:get_routes():iter() do\r
+ \r
if not t:is_monitor() and not t:is_auditioner() then\r
- --zero the fader and input trim\r
+ \r
+ -- automation first\r
+ if pref["autogain"] then t:gain_control():set_automation_state(ARDOUR.AutoState.Off) end\r
+ if pref["autopan"] then t:pan_azimuth_control():set_automation_state(ARDOUR.AutoState.Off) end\r
+ if pref["autopanwidth"] then \r
+ local pwc = t:pan_width_control()\r
+ if(not pwc:isnil()) then -- careful stereo track\r
+ pwc:set_automation_state(ARDOUR.AutoState.Off)\r
+ end\r
+ end\r
+ \r
+ -- levels\r
if pref["fader"] then t:gain_control():set_value(1, 1) end\r
if pref["trim"] then\r
t:trim_control():set_value(1, 1)\r
t:phase_control():set_value(0, 1)\r
end\r
- if pref["mute"] then t:mute_control():set_value(0, 1) end\r
+ if pref["mute"] then t:mute_control():set_value(0, 1) end\r
+ \r
+ -- pan\r
if not(t:pan_azimuth_control():isnil()) then\r
- if pref["pan"] then\r
- t:pan_azimuth_control():set_value(0.5, 1)\r
- end\r
+ if pref["pan"] then t:pan_azimuth_control():set_value(0.5, 1) end\r
+ end\r
+ if not(t:pan_width_control():isnil()) then\r
+ if pref["panwidth"] then t:pan_width_control():set_value(1, 1) end\r
end\r
\r
+ -- signal processors management\r
i = 0\r
local proc = t:nth_processor (i)\r
- local queue = {}\r
-\r
- repeat\r
+ \r
+ -- collect user procs\r
+ repeat -- loop over the track procs\r
\r
+ -- send\r
if not(proc:to_ioprocessor():isnil()) then\r
--check if processor is a send or insert\r
if proc:to_ioprocessor():display_to_user() then\r
- queue[#queue + 1] = proc\r
+ handle_processor("sends", t, proc)\r
end\r
end\r
\r
+ -- insert\r
if not(proc:to_insert():isnil()) then\r
--check if processor is foreign to us\r
- if not(proc:to_insert():is_channelstrip()) and proc:display_to_user() and not(proc:to_insert():is_nonbypassable()) then\r
- --if it is, queue it for later\r
- queue[#queue + 1] = proc\r
+ if not(proc:to_insert():display_to_user()) then\r
+ handle_processor("inserts", t, proc)\r
end\r
end\r
+ \r
+ -- regular user plug-in\r
+ if not(proc:to_plugininsert():isnil()) then\r
+ handle_processor("plug-ins", t, proc)\r
+ end\r
\r
+ -- prepare the next proc to be inspected\r
i = i + 1\r
proc = t:nth_processor(i)\r
- until proc:isnil()\r
-\r
- for p = 1, #queue do\r
- if pref['sends'] then\r
- if not(queue[p]:to_ioprocessor():isnil()) then\r
- if not(pref["dest"]) then\r
- queue[p]:deactivate()\r
- else\r
- t:remove_processor(queue[p], nil, true)\r
- end\r
- end\r
- end\r
- if pref['plug'] then\r
- print(queue[p]:display_name())\r
- if not(pref["dest"]) then\r
- queue[p]:deactivate()\r
- else\r
- t:remove_processor(queue[p], nil, true)\r
- end\r
- end\r
- end\r
- end\r
- end\r
- ::end_script::\r
+ \r
+ until proc:isnil() -- end repeat track procs\r
+ \r
+ end -- if monitor or auditioner\r
+ \r
+ end -- loop over all tracks\r
+ ::pass_script::\r
collectgarbage()\r
-end end\r
+end end
\ No newline at end of file