Optimize automation-event process splitting
[ardour.git] / scripts / remove_unknown_procs.lua
1 ardour { ["type"] = "EditorAction", name = "Remove Unknown Plugins",
2         license     = "MIT",
3         author      = "Ardour Team",
4         description = [[Remove all unknown plugins/processors from all tracks and busses]]
5 }
6
7 function factory (params) return function ()
8         -- iterate over all tracks and busses (aka routes)
9         for route in Session:get_routes ():iter () do
10                 -- route is-a http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Route
11                 local i = 0;
12                 -- we need to iterate one-by one, removing a processor invalidates the list
13                 repeat
14                         proc = route:nth_processor (i)
15                         -- proc is a http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Processor
16                         -- try cast it to http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:UnknownProcessor
17                         if not proc:isnil () and not proc:to_unknownprocessor ():isnil () then
18                                 route:remove_processor (proc, nil, true)
19                         else
20                                 i = i + 1
21                         end
22                 until proc:isnil ()
23         end
24 end end
25
26
27 function icon (params) return function (ctx, width, height, fg)
28         local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil (math.min (width, height) * .5) .. "px")
29         txt:set_text ("Fx")
30         local tw, th = txt:get_pixel_size ()
31         ctx:move_to (.5 * (width - tw), .5 * (height - th))
32         txt:layout_cairo_path (ctx)
33
34         ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg))
35         ctx:set_line_width (3)
36         ctx:stroke_preserve ()
37
38         ctx:set_source_rgba (.8, .2, .2, 1)
39         ctx:set_line_width (2)
40         ctx:stroke_preserve ()
41
42         ctx:set_source_rgba (0, 0, 0, 1)
43         ctx:fill ()
44 end end