2 ["type"] = "EditorAction",
3 name = "Engage Automation",
4 author = "Ardour Team",
5 description = [[Set automation mode of various controls (fader, trim, mute, pan), for all selected tracks.]]
8 function factory() return function()
9 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR.AutoState
10 local auto_state = ARDOUR.AutoState.Touch
11 local with_plugins = true
13 -- Ask user which mode to use, and whether to include plugins
14 local dialog_options = {
15 { type = "label", align="left", title = "Select automation state to apply all selected tracks:" },
17 type = "dropdown", key = "as", title="", values =
19 ["Manual"] = ARDOUR.AutoState.Off,
20 ["Touch"] = ARDOUR.AutoState.Touch,
21 ["Write"] = ARDOUR.AutoState.Write,
22 ["Play"] = ARDOUR.AutoState.Play,
26 { type = "checkbox", key = "plug", default = true, title = "Also set plugin controls" }
28 local rv = LuaDialog.Dialog ("Select Automation State", dialog_options):run()
29 if not rv then return end
31 with_plugins = rv['plug']
33 -- helper function to check if given ARDOUR:AutomationControl exists
34 function maybe_set_automation_state (ac)
35 if not ac:isnil() then
36 ac:set_automation_state (auto_state)
40 -- helper function to iterate over all automatable parameters of a plugin
41 function set_plugin_control_mode (pi)
42 local pc = pi:plugin (0):parameter_count()
44 local ac = pi:to_automatable():automation_control (Evoral.Parameter (ARDOUR.AutomationType.PluginAutomation, 0, c), false)
45 if not ac:isnil () then
46 ac:set_automation_state (auto_state)
51 -- get selected tracks
52 -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:Selection
53 local sel = Editor:get_selection ()
55 if sel.tracks:routelist ():empty() then
56 LuaDialog.Message ("Select Automation State", "No Tracks are selected.", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run ()
60 -- iterate over selected tracks
61 -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:TrackSelection
62 for r in sel.tracks:routelist ():iter () do
63 -- r is-a http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Route
64 -- which interhits from ARDOUR:Stripable
66 -- set route's direct control
67 r:gain_control ():set_automation_state (auto_state)
68 maybe_set_automation_state (r:trim_control ())
69 maybe_set_automation_state (r:mute_control ())
70 maybe_set_automation_state (r:pan_azimuth_control ())
71 maybe_set_automation_state (r:pan_width_control ())
76 local proc = r:nth_plugin (i)
77 if proc:isnil () then break end
78 set_plugin_control_mode (proc:to_insert ())