Do not try to restore Route solo state after clearing all solo state
[ardour.git] / scripts / addscopes.lua
1 ardour {
2         ["type"]    = "EditorAction",
3         name        = "Add Scopes",
4         license     = "MIT",
5         author      = "Ardour Team",
6         description = [[Add 'Inline Scope' Lua Processor to all Tracks]]
7 }
8
9 function action_params ()
10         return
11         {
12                 ["unique"]   = { title = "Only add Scope if non is present already (yes/no)", default = "yes"},
13                 ["position"] = { title = "Insert Position from top (0,..)",                   default = "0"},
14         }
15 end
16
17
18 function factory (params)
19         return function ()
20                 -- get configuration
21                 local p = params or {}
22                 local uniq = p["unique"] or "yes"
23                 local pos = p["position"] or 0
24
25                 -- loop over all tracks
26                 for t in Session:get_tracks():iter() do
27                         local insert = true;
28
29                         -- check if a scope is already present
30                         if uniq ~= "no" then
31                                 local proc;
32                                 local i = 0;
33                                 repeat
34                                         -- get Nth Ardour::Processor
35                                         proc = t:nth_plugin (i)
36                                         -- check if it's a scope
37                                         if (not proc:isnil() and proc:display_name () == "a-Inline Scope") then
38                                                 insert = false;
39                                         end
40                                         i = i + 1
41                                 until proc:isnil() or insert == false
42                         end
43
44                         -- create a new processor and insert it
45                         if insert then
46                                 local a = ARDOUR.LuaAPI.new_luaproc(Session, "a-Inline Scope");
47                                 if (not a:isnil()) then
48                                         t:add_processor_by_index(a, pos, nil, true)
49                                         ARDOUR.LuaAPI.set_processor_param (a, 0, 5) -- timescale 5sec
50                                         -- ARDOUR.LuaAPI.set_processor_param (a, 1, 1) -- logscale on
51                                         -- ARDOUR.LuaAPI.set_processor_param (a, 2, 3) -- "Max" height
52                                         a = nil -- explicitly drop shared-ptr reference
53                                 end
54                         end
55                 end
56         end
57 end