summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-03-23 23:45:39 +0100
committerRobin Gareus <robin@gareus.org>2016-03-23 23:45:39 +0100
commit9ed7793326e658af2edc6db059f6137713d8aa82 (patch)
tree68c40d105964993337874ea890f434889ab5163c
parentdafdf87b79293c212f4f52ae5faa44d11cb09e5e (diff)
add/update lua scripts
-rw-r--r--doc/lua_scratch.lua42
-rw-r--r--scripts/addscopes.lua5
-rw-r--r--scripts/s_pluginutils.lua36
-rw-r--r--scripts/s_replaceplugin.lua11
4 files changed, 50 insertions, 44 deletions
diff --git a/doc/lua_scratch.lua b/doc/lua_scratch.lua
deleted file mode 100644
index 25c5101012..0000000000
--- a/doc/lua_scratch.lua
+++ /dev/null
@@ -1,42 +0,0 @@
--------------------------------------------------------------------------------
--- 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)
diff --git a/scripts/addscopes.lua b/scripts/addscopes.lua
index b71d703e9b..8ac1519ee4 100644
--- a/scripts/addscopes.lua
+++ b/scripts/addscopes.lua
@@ -20,8 +20,9 @@ end
function factory (params)
return function ()
-- get configuration
- local uniq = params["unique"] or "yes"
- local pos = params["position"] or 0
+ local p = params or {}
+ local uniq = p["unique"] or "yes"
+ local pos = p["position"] or 0
-- loop over all tracks
for t in Session:get_tracks():iter() do
diff --git a/scripts/s_pluginutils.lua b/scripts/s_pluginutils.lua
new file mode 100644
index 0000000000..0ecf107e49
--- /dev/null
+++ b/scripts/s_pluginutils.lua
@@ -0,0 +1,36 @@
+ardour { ["type"] = "Snippet", name = "Plugin Utils" }
+
+function factory () return function ()
+
+ -------------------------------------------------------------------------------
+ -- 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)
+
+
+ -------------------------------------------------------------------------------
+ -- 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
+
+end end
diff --git a/scripts/s_replaceplugin.lua b/scripts/s_replaceplugin.lua
new file mode 100644
index 0000000000..6ec82768b7
--- /dev/null
+++ b/scripts/s_replaceplugin.lua
@@ -0,0 +1,11 @@
+ardour { ["type"] = "Snippet", name = "Replace Plugin" }
+
+function factory () return function ()
+
+ 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)
+
+end end