Create ardour-friendly version of reset_mb4_mixer Lua script
authorNikolaus Gullotta <nikolaus.gullotta@gmail.com>
Tue, 17 Jul 2018 17:55:43 +0000 (12:55 -0500)
committerNikolaus Gullotta <nikolaus.gullotta@gmail.com>
Tue, 17 Jul 2018 17:55:43 +0000 (12:55 -0500)
scripts/reset_mixer.lua [new file with mode: 0644]

diff --git a/scripts/reset_mixer.lua b/scripts/reset_mixer.lua
new file mode 100644 (file)
index 0000000..d4e0521
--- /dev/null
@@ -0,0 +1,85 @@
+ardour {\r
+       ["type"] = "EditorAction",\r
+       name = "Reset Mixer",\r
+       author = "Ben Loftis, Nikolaus Gullotta",\r
+       description = [[Resets key Mixer settings after user-prompt (warning: this cannot be undone)]]\r
+}\r
+\r
+function factory() return function()\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 = "dest",  default = false, title = "Remove plug-ins instead of bypassing?" },\r
+               { type = "label", colspan="3", title = "" },\r
+               { type = "label", colspan="3", title = "Note that this is a script which can be user-edited to match your needs." },\r
+               { type = "label", colspan="3", title = "" },\r
+       }\r
+\r
+       local pref = LuaDialog.Dialog("Reset Mixer", dlg):run()\r
+       if not(pref) then goto end_script end\r
+    assert(pref, 'Dialog box was cancelled or is ' .. type(pref))\r
+\r
+       Session:cancel_all_solo()\r
+       -- loop over all tracks\r
+       for t in Session:get_routes():iter() do\r
+               if not t:is_monitor() and not t:is_auditioner() then\r
+                       --zero the fader and input trim\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 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
+                       end\r
+\r
+                       i = 0\r
+                       local proc = t:nth_processor (i)\r
+                       local queue = {}\r
+\r
+                       local protected = {\r
+                       "recorder", "latcomp-", "player",\r
+                       "Polarity", "Trim", "Fader",\r
+                       "meter-", "main outs", "Monitor",\r
+                       }\r
+\r
+                       repeat\r
+                               local name = proc:display_name()\r
+                               --check if processor is foreign to us\r
+                               protected_proc = false\r
+                               for _, v in pairs(protected) do\r
+                                       if string.find(name, v) then\r
+                                               --processor is not foreign to us\r
+                                               protected_proc = true\r
+                                       end\r
+                               end\r
+\r
+                               if not(protected_proc) and proc:display_to_user() then\r
+                                       print(name)\r
+                                       queue[#queue + 1] = proc\r
+                               end\r
+\r
+                               i = i + 1\r
+                               proc = t:nth_processor(i)\r
+                       until proc:isnil()\r
+\r
+                       for p = 1, #queue do\r
+                               if pref['plug'] 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
+               end\r
+       end\r
+       ::end_script::\r
+end end\r