diff options
Diffstat (limited to 'scripts/s_plugin_automation.lua')
-rw-r--r-- | scripts/s_plugin_automation.lua | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/scripts/s_plugin_automation.lua b/scripts/s_plugin_automation.lua index e69de6662a..daec46aa0c 100644 --- a/scripts/s_plugin_automation.lua +++ b/scripts/s_plugin_automation.lua @@ -1,25 +1,33 @@ -ardour { ["type"] = "Snippet", name = "plugin automation2" } +ardour { ["type"] = "Snippet", name = "Plugin automation" } function factory () return function () + -- query playhead position and session sample-rate local playhead = Session:transport_frame () local samplerate = Session:nominal_frame_rate () + -- get Track/Bus with RID 3 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) + -- make sure the track object exists + assert (not r:isnil ()) - if not acl:isnil() then + -- get AutomationList, ControlList and ParameterDescriptor + -- of the first plugin's first parameter + -- see http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:LuaAPI + local al, cl, pd = ARDOUR.LuaAPI.plugin_automation (r:nth_plugin (0), 0) + + if not al:isnil () then print ("Parameter Range", pd.lower, pd.upper) - print ("Current value", cl:eval(playhead)) + print ("Current value", cl:eval (playhead)) -- prepare undo operation Session:begin_reversible_command ("Automatix") - local before = acl:get_state() + -- remember current AutomationList state + local before = al:get_state() -- remove future automation cl:truncate_end (playhead) - -- add new data points after the playhead 1 sec min..max + -- 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, @@ -28,8 +36,8 @@ function factory () return function () end -- save undo - local after = acl:get_state() - Session:add_command (acl:memento_command(before, after)) + local after = al:get_state() + Session:add_command (al:memento_command(before, after)) Session:commit_reversible_command (nil) end end end |