quick checks on empty control lists, to avoid unnecessary work
[ardour.git] / scripts / s_pluginutils.lua
1 ardour { ["type"] = "Snippet", name = "Plugin Utils" }
2
3 function factory () return function ()
4
5         -------------------------------------------------------------------------------
6         -- add a Plugin (here LV2) to all mono tracks that contain the pattern "dru"
7         -- and load a plugin-preset (if it exists)
8         for r in Session:get_routes():iter() do
9                 if (string.match (r:name(), "dru") and r:n_inputs():n_audio() == 1) then
10                         local proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/fil4#mono", ARDOUR.PluginType.LV2, "cutbass");
11                         r:add_processor_by_index(proc, 0, nil, true)
12                 end
13         end
14
15
16         -------------------------------------------------------------------------------
17         -- load a plugin preset
18         route = Session:get_remote_nth_route(2)
19         -- to 4th plugin (from top), ardour starts counting at zero
20         plugin = route:nth_plugin(3):to_insert():plugin(0)
21         ps = plugin:preset_by_label("cutbass") -- get preset by name
22         print (ps.uri)
23         plugin:load_preset (ps)
24
25
26         -------------------------------------------------------------------------------
27         -- add a LuaProcessor (here "Scope") to all tracks
28         for t in Session:get_tracks():iter() do
29                 local pos = 0 -- insert at the top
30                 local proc = ARDOUR.LuaAPI.new_luaproc(Session, "Inline Scope");
31                 t:add_processor_by_index(proc, pos, nil, true)
32                 -- optionally set some parameters
33                 ARDOUR.LuaAPI.set_processor_param (proc, 0, 5) -- timescale 5sec
34         end
35
36 end end