more dialog formatting changes
[ardour.git] / scripts / reset_mixer.lua
1 ardour {\r
2         ["type"] = "EditorAction",\r
3         name = "Reset Mixer",\r
4         author = "Ben Loftis, Nikolaus Gullotta",\r
5         description = [[Resets key Mixer settings after user-prompt (warning: this cannot be undone)]]\r
6 }\r
7 \r
8 function factory() return function()\r
9 \r
10         local dlg = {\r
11                 { type = "label", align ="left", colspan="3", title = "Select the items to reset:" },\r
12                 { type = "checkbox", key = "fader", default = true,  title = "Fader" },\r
13                 { type = "checkbox", key = "mute",  default = true,  title = "Mute" },\r
14                 { type = "checkbox", key = "trim",  default = true,  title = "Trim + Phase" },\r
15                 { type = "checkbox", key = "plug",  default = true,  title = "Plug-ins" },\r
16                 { type = "checkbox", key = "sends", default = true,  title = "Sends and inserts" },\r
17                 { type = "checkbox", key = "dest",  default = false, title = "Remove plug-ins instead of bypassing?" },\r
18                 { type = "label", colspan="3", title = "" },\r
19                 { type = "label", colspan="3", title = "Note that this is a script which can be user-edited to match your needs." },\r
20                 { type = "label", colspan="3", title = "" },\r
21         }\r
22 \r
23         local pref = LuaDialog.Dialog("Reset Mixer", dlg):run()\r
24         if not(pref) then goto end_script end\r
25     assert(pref, 'Dialog box was cancelled or is ' .. type(pref))\r
26 \r
27         Session:cancel_all_solo()\r
28         -- loop over all tracks\r
29         for t in Session:get_routes():iter() do\r
30                 if not t:is_monitor() and not t:is_auditioner() then\r
31                         --zero the fader and input trim\r
32                         if pref["fader"] then t:gain_control():set_value(1, 1) end\r
33                         if pref["trim"]  then\r
34                                 t:trim_control():set_value(1, 1)\r
35                                 t:phase_control():set_value(0, 1)\r
36                         end\r
37                         if pref["mute"]  then t:mute_control():set_value(0, 1) end\r
38                         if not(t:pan_azimuth_control():isnil()) then\r
39                                 if pref["pan"] then\r
40                                         t:pan_azimuth_control():set_value(0.5, 1)\r
41                                 end\r
42                         end\r
43 \r
44                         i = 0\r
45                         local proc = t:nth_processor (i)\r
46                         local queue = {}\r
47 \r
48                         repeat\r
49 \r
50                                 if not(proc:to_ioprocessor():isnil()) then\r
51                                         --check if processor is a send or insert\r
52                                         if proc:to_ioprocessor():display_to_user() then\r
53                                                 queue[#queue + 1] = proc\r
54                                         end\r
55                                 end\r
56 \r
57                                 if not(proc:to_insert():isnil()) then\r
58                                         --check if processor is foreign to us\r
59                                         if not(proc:to_insert():is_channelstrip()) and proc:display_to_user() and not(proc:to_insert():is_nonbypassable()) then\r
60                                                 --if it is, queue it for later\r
61                                                 queue[#queue + 1] = proc\r
62                                         end\r
63                                 end\r
64 \r
65                                 i = i + 1\r
66                                 proc = t:nth_processor(i)\r
67                         until proc:isnil()\r
68 \r
69                         for p = 1, #queue do\r
70                                 if pref['sends'] then\r
71                                         if not(queue[p]:to_ioprocessor():isnil()) then\r
72                                                 if not(pref["dest"]) then\r
73                                                         queue[p]:deactivate()\r
74                                                 else\r
75                                                         t:remove_processor(queue[p], nil, true)\r
76                                                 end\r
77                                         end\r
78                                 end\r
79                                 if pref['plug'] then\r
80                                         print(queue[p]:display_name())\r
81                                         if not(pref["dest"]) then\r
82                                                 queue[p]:deactivate()\r
83                                         else\r
84                                                 t:remove_processor(queue[p], nil, true)\r
85                                         end\r
86                                 end\r
87                         end\r
88                 end\r
89         end\r
90         ::end_script::\r
91         collectgarbage()\r
92 end end\r