2 ["type"] = "EditorAction",
3 name = "Generic MIDI Track",
4 description = [[Example]]
7 -- If a route_setup function is present in an Editor Action Script
8 -- the script is also listed in the "add track/bus" dialog as meta-template
10 -- The function is expected to return a Lua table. The table may be empty.
11 function route_setup ()
14 -- keys control which AddRouteDialog controls are made sensitive.
15 -- The following keys accept a default value to pre-seed the dialog.
21 -- these keys just need to be set (to something other than nil)
22 -- in order to set the control sensitives
23 ['insert_at'] = ARDOUR.PresentationInfo.max_order,
24 ['group'] = false, -- return value will be a RouteGroup*
25 ['instrument'] = true, -- return value will be a PluginInfoPtr
29 -- The Script can be used as EditorAction in which case it can
30 -- optionally provide instantiation parmaters
31 function action_params ()
34 ['how_many'] = { title = "How Many tracks to add", default = "1" },
35 ["name"] = { title = "Track Name Prefix", default = "MIDI" },
36 ["instrument"] = { title = "Add Instrument", default = "true" },
41 function factory (params) return function ()
42 -- When called from the AddRouteDialog, 'params' will be a table with
43 -- keys as described in route_setup() above.
45 local p = params or route_setup ()
46 local name = p["name"] or 'Audio'
47 local how_many = p["how_many"] or 1
48 local insert_at = p["insert_at"] or ARDOUR.PresentationInfo.max_order;
49 local group = p["group"] or nil
50 local strict_io = p["strict_io"] or false
51 local instrument = p["instrument"] or nil
53 -- used in 'action-script mode'
54 if instrument == "true" then
55 instrument = ARDOUR.LuaAPI.new_plugin_info ("http://gareus.org/oss/lv2/gmsynth", ARDOUR.PluginType.LV2) -- general midi synth
56 if instrument:isnil () then
57 instrument = ARDOUR.LuaAPI.new_plugin_info ("https://community.ardour.org/node/7596", ARDOUR.PluginType.LV2) -- reasonable synth
59 if instrument:isnil () then
60 LuaDialog.Message ("MIDI track add", "Cannot find instrument plugin",
61 LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run ()
67 if type (instrument) ~= "userdata" then
68 instrument = ARDOUR.PluginInfo ()
71 Session:new_midi_track(
72 ARDOUR.ChanCount(ARDOUR.DataType ("midi"), 1),
73 ARDOUR.ChanCount(ARDOUR.DataType ("audio"), 2),
76 group, how_many, name, insert_at, ARDOUR.TrackMode.Normal)