summaryrefslogtreecommitdiff
path: root/scripts/s_plugin_automation.lua
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-04-10 20:57:24 +0200
committerRobin Gareus <robin@gareus.org>2016-04-10 20:57:24 +0200
commitc76ef648703128e0b1dbcbc0790daa25254a1ce4 (patch)
tree8858cf422cd30b84097467c5ef9d37ed5f068080 /scripts/s_plugin_automation.lua
parent2b943ea36c128819d808087f853977fdd8e5c09d (diff)
some more example lua scripts
Diffstat (limited to 'scripts/s_plugin_automation.lua')
-rw-r--r--scripts/s_plugin_automation.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/s_plugin_automation.lua b/scripts/s_plugin_automation.lua
new file mode 100644
index 0000000000..e69de6662a
--- /dev/null
+++ b/scripts/s_plugin_automation.lua
@@ -0,0 +1,35 @@
+ardour { ["type"] = "Snippet", name = "plugin automation2" }
+
+function factory () return function ()
+ local playhead = Session:transport_frame ()
+ local samplerate = Session:nominal_frame_rate ()
+
+ local r = Session:route_by_remote_id(3)
+ -- get AutomationControList, ControlList and ParameterDescriptor
+ local acl, cl, pd = ARDOUR.LuaAPI.plugin_automation (r:nth_plugin (0), 0)
+
+ if not acl:isnil() then
+ print ("Parameter Range", pd.lower, pd.upper)
+ print ("Current value", cl:eval(playhead))
+
+ -- prepare undo operation
+ Session:begin_reversible_command ("Automatix")
+ local before = acl:get_state()
+
+ -- remove future automation
+ cl:truncate_end (playhead)
+
+ -- add new data points after the playhead 1 sec min..max
+ -- without guard-points, but with initial (..., false, true)
+ for i=0,10 do
+ cl:add (playhead + i * samplerate / 10,
+ pd.lower + math.sqrt (i / 10) * (pd.upper - pd.lower),
+ false, true)
+ end
+
+ -- save undo
+ local after = acl:get_state()
+ Session:add_command (acl:memento_command(before, after))
+ Session:commit_reversible_command (nil)
+ end
+end end