More consistent dialog window titles (Recall Mixer Settings).
[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         }\r
19 \r
20         local pref = LuaDialog.Dialog("Reset Mixer", dlg):run()\r
21         if not(pref) then goto end_script end\r
22     assert(pref, 'Dialog box was cancelled or is ' .. type(pref))\r
23 \r
24         Session:cancel_all_solo()\r
25         -- loop over all tracks\r
26         for t in Session:get_routes():iter() do\r
27                 if not t:is_monitor() and not t:is_auditioner() then\r
28                         --zero the fader and input trim\r
29                         if pref["fader"] then t:gain_control():set_value(1, 1) end\r
30                         if pref["trim"]  then\r
31                                 t:trim_control():set_value(1, 1)\r
32                                 t:phase_control():set_value(0, 1)\r
33                         end\r
34                         if pref["mute"]  then t:mute_control():set_value(0, 1) end\r
35                         if not(t:pan_azimuth_control():isnil()) then\r
36                                 if pref["pan"] then\r
37                                         t:pan_azimuth_control():set_value(0.5, 1)\r
38                                 end\r
39                         end\r
40 \r
41                         i = 0\r
42                         local proc = t:nth_processor (i)\r
43                         local queue = {}\r
44 \r
45                         repeat\r
46 \r
47                                 if not(proc:to_ioprocessor():isnil()) then\r
48                                         --check if processor is a send or insert\r
49                                         if proc:to_ioprocessor():display_to_user() then\r
50                                                 queue[#queue + 1] = proc\r
51                                         end\r
52                                 end\r
53 \r
54                                 if not(proc:to_insert():isnil()) then\r
55                                         --check if processor is foreign to us\r
56                                         if not(proc:to_insert():is_channelstrip()) and proc:display_to_user() and not(proc:to_insert():is_nonbypassable()) then\r
57                                                 --if it is, queue it for later\r
58                                                 queue[#queue + 1] = proc\r
59                                         end\r
60                                 end\r
61 \r
62                                 i = i + 1\r
63                                 proc = t:nth_processor(i)\r
64                         until proc:isnil()\r
65 \r
66                         for p = 1, #queue do\r
67                                 if pref['sends'] then\r
68                                         if not(queue[p]:to_ioprocessor():isnil()) then\r
69                                                 if not(pref["dest"]) then\r
70                                                         queue[p]:deactivate()\r
71                                                 else\r
72                                                         t:remove_processor(queue[p], nil, true)\r
73                                                 end\r
74                                         end\r
75                                 end\r
76                                 if pref['plug'] then\r
77                                         print(queue[p]:display_name())\r
78                                         if not(pref["dest"]) then\r
79                                                 queue[p]:deactivate()\r
80                                         else\r
81                                                 t:remove_processor(queue[p], nil, true)\r
82                                         end\r
83                                 end\r
84                         end\r
85                 end\r
86         end\r
87         ::end_script::\r
88         collectgarbage()\r
89 end end\r