From 86a45e3cac26fd02fe49b5ef7ebe7259a1aad979 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 10 Apr 2016 17:35:02 +0200 Subject: add lua bindings for Automation Events --- libs/ardour/lua_api.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'libs/ardour/lua_api.cc') diff --git a/libs/ardour/lua_api.cc b/libs/ardour/lua_api.cc index 02a4de4658..e24902999d 100644 --- a/libs/ardour/lua_api.cc +++ b/libs/ardour/lua_api.cc @@ -183,6 +183,51 @@ ARDOUR::LuaAPI::set_processor_param (boost::shared_ptr proc, uint32_t return set_plugin_insert_param (pi, which, val); } +int +ARDOUR::LuaAPI::plugin_automation (lua_State *L) +{ + typedef boost::shared_ptr T; + + int top = lua_gettop(L); + if (top < 2) { + return luaL_argerror (L, 1, "invalid number of arguments, :plugin_automation (plugin, parameter_number)"); + } + T* const p = luabridge::Userdata::get(L, 1, false); + uint32_t which = luabridge::Stack::get (L, 2); + if (!p) { + return luaL_error (L, "Invalid pointer to Ardour:Processor"); + } + boost::shared_ptr pi = boost::dynamic_pointer_cast (*p); + if (!pi) { + return luaL_error (L, "Given Processor is not a Plugin Insert"); + } + boost::shared_ptr plugin = pi->plugin(); + if (!plugin) { + return luaL_error (L, "Given Processor is not a Plugin"); + } + + bool ok=false; + uint32_t controlid = plugin->nth_parameter (which, ok); + if (!ok) { + return luaL_error (L, "Invalid Parameter"); + } + if (!plugin->parameter_is_input (controlid)) { + return luaL_error (L, "Given Parameter is not an input"); + } + + ParameterDescriptor pd; + if (plugin->get_parameter_descriptor (controlid, pd) != 0) { + return luaL_error (L, "Cannot describe parameter"); + } + + boost::shared_ptr c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid)); + + luabridge::Stack >::push (L, c->alist()); + luabridge::Stack >::push (L, c->list()); + luabridge::Stack::push (L, pd); + return 3; +} + int ARDOUR::LuaOSC::Address::send (lua_State *L) { -- cgit v1.2.3