fix drawing of zero-length notes
[ardour.git] / scripts / list_plugins.lua
1 ardour { ["type"] = "EditorAction", name = "List Plugins",
2         license     = "MIT",
3         author      = "Ardour Team",
4         description = [[List and count plugins used in this session]]
5 }
6
7 function factory () return function ()
8         local rv = "Plugins used in this session:\n<span face=\"mono\">CNT | TYPE | NAME</span>"
9         local all_plugs = {}
10
11         for r in Session:get_routes ():iter () do
12                 if r:is_monitor () or r:is_auditioner () then goto nextroute end -- skip special routes
13                 local i = 0
14                 while true do
15                         local proc = r:nth_plugin (i)
16                         if proc:isnil () then break end
17                         local pi = proc:to_insert () -- we know it's a plugin-insert (we asked for nth_plugin)
18                         local pp = pi:plugin (0)
19                         local id = pi:type() .. "-" .. pp:unique_id()
20                         local cnt = 0
21                         if all_plugs[id] then cnt = all_plugs[id]['cnt'] end
22                         all_plugs[id] = { name = proc:name(), ["type"] = pi:type(), id = pp:unique_id(), cnt = (cnt + 1) }
23                         i = i + 1
24                 end
25                 ::nextroute::
26         end
27
28         function plugintypestr (t)
29                 if (t == ARDOUR.PluginType.LADSPA) then  return "LADSPA" end
30                 if (t == ARDOUR.PluginType.LV2) then return "LV2" end
31                 if (t == ARDOUR.PluginType.AudioUnit) then return "AU" end
32                 if (t == ARDOUR.PluginType.Windows_VST) then return "VST" end
33                 if (t == ARDOUR.PluginType.LXVST) then return "VST" end
34                 if (t == ARDOUR.PluginType.MacVST) then return "VST" end
35                 if (t == ARDOUR.PluginType.Lua) then return "Lua" end
36                 return "??"
37         end
38
39         for k,v in pairs (all_plugs) do
40                 print (string.format ("%2d * %-6s %-30s (%s)", v['cnt'], plugintypestr(v['type']), v['name'], v['id']))
41                 rv = rv .. "\n" .. string.format ("%2d * %-6s %s", v['cnt'], plugintypestr(v['type']), v['name'])
42         end
43
44         LuaDialog.Message ("All Plugins", "<span face=\"mono\">" .. rv .. "</span>", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
45
46         all_plugs = nil
47         rv = ""
48         collectgarbage ();
49
50 end end