2 ["type"] = "EditorAction",
3 name = "Rob's 16 MIDI Trick Pony",
4 description = [[clearly broken approach to go about things]]
7 function route_setup ()
9 ['Insert_at'] = ARDOUR.PresentationInfo.max_order,
11 ['group'] = false, -- return value will be a RouteGroup* or nil
15 function factory (p) return function ()
16 local name = "Sweet16"
17 local insert_at = ARDOUR.PresentationInfo.max_order
20 -- check for "MIDI Channel Map" LV2 from x42 midifilters.lv2
21 if ARDOUR.LuaAPI.new_plugin_info ("http://gareus.org/oss/lv2/midifilter#channelmap", ARDOUR.PluginType.LV2):isnil () then
22 LuaDialog.Message ("16 MIDI Tracks", "Error: Plugin 'MIDI Simple Channel Map' was not found.", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run ()
26 if type (p) == 'table' and p['how_many'] ~= nil then
27 -- used from the AddRouteDialog (or w/action_params)
28 name = p["name"] or 'Sweet16'
29 insert_at = p["insert_at"] or ARDOUR.PresentationInfo.max_order;
30 group = p["group"] or nil
32 -- used standalone, prompt for name and insert position
33 local dialog_options = {
34 { type = "entry", key = "name", default = 'Sweet16', title = "Name Prefix" },
35 { type = "entry", key = "group", default = '', title = "Group (empty for none)" },
36 { type = "dropdown", key = "insertpos", title = "Position", default = "Last", values =
38 ["First"] = ArdourUI.InsertAt.First,
39 ["Before Selection"] = ArdourUI.InsertAt.BeforeSelection,
40 ["After Selection"] = ArdourUI.InsertAt.AfterSelection,
41 ["Last"] = ArdourUI.InsertAt.Last
46 local od = LuaDialog.Dialog ("16 MIDI Tracks", dialog_options)
48 if (not rv) then return end
49 name = rv['name'] or 'Sweet16'
50 if rv['insertpos'] then
51 insert_at = ArdourUI.translate_order (rv['insertpos'])
53 if rv['group'] and rv['group'] ~= '' then
54 group = Session:new_route_group (rv['group'])
61 local tl = Session:new_midi_track (
62 ARDOUR.ChanCount(ARDOUR.DataType ("midi"), 1),
63 ARDOUR.ChanCount(ARDOUR.DataType ("midi"), 1),
65 ARDOUR.PluginInfo(), nil, -- no instrument, no instrument preset
68 name, insert_at, ARDOUR.TrackMode.Normal)
71 for track in tl:iter() do
72 local p = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/midifilter#channelmap", ARDOUR.PluginType.LV2, "")
73 assert (not p:isnil ())
74 track:add_processor_by_index(p, 0, nil, true)
76 ARDOUR.LuaAPI.set_processor_param (p, j, i)
80 collectgarbage () -- drop references to tracks.