add more lua examples/doc
authorRobin Gareus <robin@gareus.org>
Sat, 19 Mar 2016 15:40:02 +0000 (16:40 +0100)
committerRobin Gareus <robin@gareus.org>
Sat, 19 Mar 2016 15:41:59 +0000 (16:41 +0100)
doc/lua_scratch.lua [new file with mode: 0644]
scripts/addscopes.lua

diff --git a/doc/lua_scratch.lua b/doc/lua_scratch.lua
new file mode 100644 (file)
index 0000000..25c5101
--- /dev/null
@@ -0,0 +1,42 @@
+-------------------------------------------------------------------------------
+-- collection of snippets for testing and upcoming doc
+-------------------------------------------------------------------------------
+
+
+-------------------------------------------------------------------------------
+-- replace a plugin
+route = Session:route_by_remote_id(1)
+old = route:nth_plugin(0)
+new = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/fil4#stereo", ARDOUR.PluginType.LV2, "");
+route:replace_processor (old, new, nil)
+old = nil new = nil -- explicitly drop references (unless they're local vars)
+
+
+-------------------------------------------------------------------------------
+-- add a LuaProcessor (here "Scope") to all tracks
+for t in Session:get_tracks():iter() do
+       local pos = 0 -- insert at the top
+       local proc = ARDOUR.LuaAPI.new_luaproc(Session, "Inline Scope");
+       t:add_processor_by_index(proc, pos, nil, true)
+       -- optionally set some parameters
+       ARDOUR.LuaAPI.set_processor_param (proc, 0, 5) -- timescale 5sec
+end
+
+-------------------------------------------------------------------------------
+-- add a Plugin (here LV2) to all mono tracks that contain the pattern "dru"
+-- and load a plugin-preset (if it exists)
+for r in Session:get_routes():iter() do
+       if (string.match (r:name(), "dru") and r:n_inputs():n_audio() == 1) then
+       local proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/fil4#mono", ARDOUR.PluginType.LV2, "cutbass");
+       r:add_processor_by_index(proc, 0, nil, true)
+       end
+end
+
+-------------------------------------------------------------------------------
+-- load a plugin preset
+route = Session:route_by_remote_id(2)
+-- to 4th plugin (from top), ardour starts counting at zero
+plugin = route:nth_plugin(3):to_insert():plugin(0)
+ps = plugin:preset_by_label("cutbass") -- get preset by name
+print (ps.uri)
+plugin:load_preset (ps)
index 341773483c93da8554a066f9eca055006cbb86ec..b71d703e9b7314867290423ae039e2a37ad312f5 100644 (file)
@@ -47,7 +47,10 @@ function factory (params)
                                local a = ARDOUR.LuaAPI.new_luaproc(Session, "Inline Scope");
                                if (not a:isnil()) then
                                        t:add_processor_by_index(a, pos, nil, true)
-                                       a = nil
+                                       ARDOUR.LuaAPI.set_processor_param (a, 0, 5) -- timescale 5sec
+                                       -- ARDOUR.LuaAPI.set_processor_param (a, 1, 1) -- logscale on
+                                       -- ARDOUR.LuaAPI.set_processor_param (a, 2, 3) -- "Max" height
+                                       a = nil -- explicitly drop shared-ptr reference
                                end
                        end
                end