Only show user-presets in favorite sidebar
[ardour.git] / scripts / s_pluginutils.lua
1 ardour { ["type"] = "Snippet", name = "Plugin Utils" }
2
3 function factory () return function ()
4
5         -------------------------------------------------------------------------------
6         -- List all Plugins
7         for p in ARDOUR.LuaAPI.list_plugins():iter() do
8                 print (p.name, p.unique_id, p.type)
9                 local psets = p:get_presets()
10                 if not empty:empty() then
11                         for pset in psets:iter() do
12                                 print (" - ", pset.label)
13                         end
14                 end
15         end
16
17         -------------------------------------------------------------------------------
18         -- add a Plugin (here LV2) to all mono tracks that contain the pattern "dru"
19         -- and load a plugin-preset (if it exists)
20         for r in Session:get_routes():iter() do
21                 if (string.match (r:name(), "dru") and r:n_inputs():n_audio() == 1) then
22                         local proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/fil4#mono", ARDOUR.PluginType.LV2, "cutbass");
23                         assert (not proc:isnil())
24                         r:add_processor_by_index(proc, 0, nil, true)
25                 end
26         end
27
28
29         -------------------------------------------------------------------------------
30         -- load a plugin preset
31         route = Session:get_remote_nth_route(2)
32         assert (route)
33         -- to 4th plugin (from top), ardour starts counting at zero
34         plugin = route:nth_plugin(3):to_insert():plugin(0)
35         assert (not plugin:isnil())
36         ps = plugin:preset_by_label("cutbass") -- get preset by name
37         assert (ps)
38         print (ps.uri)
39         plugin:load_preset (ps)
40
41
42         -------------------------------------------------------------------------------
43         -- add a LuaProcessor (here "Scope") to all tracks
44         for t in Session:get_tracks():iter() do
45                 local pos = 0 -- insert at the top
46
47                 -- the following two lines are equivalent
48                 --local proc = ARDOUR.LuaAPI.new_luaproc(Session, "a-Inline Scope");
49                 local proc = ARDOUR.LuaAPI.new_plugin (Session, "a-Inline Scope", ARDOUR.PluginType.Lua, "");
50                 assert (not proc:isnil())
51
52                 t:add_processor_by_index(proc, pos, nil, true)
53                 -- optionally set some parameters
54                 ARDOUR.LuaAPI.set_processor_param (proc, 0, 5) -- timescale 5sec
55         end
56
57 end end