13
0

add lua bindings for Automation Events

This commit is contained in:
Robin Gareus 2016-04-10 17:35:02 +02:00
parent 1c084d1e0e
commit 86a45e3cac
3 changed files with 113 additions and 0 deletions

View File

@ -93,6 +93,24 @@ namespace ARDOUR { namespace LuaAPI {
*/ */
bool set_plugin_insert_param (boost::shared_ptr<ARDOUR::PluginInsert> pi, uint32_t which, float val); bool set_plugin_insert_param (boost::shared_ptr<ARDOUR::PluginInsert> pi, uint32_t which, float val);
/**
* A convenience function to get a AutomationControList and ParamaterDescriptor
* for a given plugin control.
*
* This is equivalent to the following lua code
* <code>
* function (processor, param_id)
* local plugininsert = processor:to_insert ()
* local plugin = plugininsert:plugin(0)
* local _, t = plugin:get_parameter_descriptor(param_id, ARDOUR.ParameterDescriptor ())
* local ctrl = Evoral.Parameter (ARDOUR.AutomationType.PluginAutomation, 0, param_id)
* local ac = pi:automation_control (ctrl, false)
* local acl = ac:alist()
* return ac:alist(), ac:to_ctrl():list(), t[2]
* end
* </code>
*/
int plugin_automation (lua_State *lua);
} } /* namespace */ } } /* namespace */
namespace ARDOUR { namespace LuaOSC { namespace ARDOUR { namespace LuaOSC {

View File

@ -183,6 +183,51 @@ ARDOUR::LuaAPI::set_processor_param (boost::shared_ptr<Processor> proc, uint32_t
return set_plugin_insert_param (pi, which, val); return set_plugin_insert_param (pi, which, val);
} }
int
ARDOUR::LuaAPI::plugin_automation (lua_State *L)
{
typedef boost::shared_ptr<Processor> 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<T>(L, 1, false);
uint32_t which = luabridge::Stack<uint32_t>::get (L, 2);
if (!p) {
return luaL_error (L, "Invalid pointer to Ardour:Processor");
}
boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (*p);
if (!pi) {
return luaL_error (L, "Given Processor is not a Plugin Insert");
}
boost::shared_ptr<Plugin> 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<AutomationControl> c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid));
luabridge::Stack<boost::shared_ptr<AutomationList> >::push (L, c->alist());
luabridge::Stack<boost::shared_ptr<Evoral::ControlList> >::push (L, c->list());
luabridge::Stack<ParameterDescriptor>::push (L, pd);
return 3;
}
int int
ARDOUR::LuaOSC::Address::send (lua_State *L) ARDOUR::LuaOSC::Address::send (lua_State *L)
{ {

View File

@ -24,6 +24,7 @@
#include "evoral/ControlList.hpp" #include "evoral/ControlList.hpp"
#include "evoral/Range.hpp" #include "evoral/Range.hpp"
#include "ardour/amp.h"
#include "ardour/audioengine.h" #include "ardour/audioengine.h"
#include "ardour/audiosource.h" #include "ardour/audiosource.h"
#include "ardour/audio_backend.h" #include "ardour/audio_backend.h"
@ -108,6 +109,10 @@ LuaBindings::common (lua_State* L)
.addFunction ("to_s", &PBD::ID::to_s) // TODO special case LUA __tostring ? .addFunction ("to_s", &PBD::ID::to_s) // TODO special case LUA __tostring ?
.endClass () .endClass ()
.beginClass <XMLNode> ("XMLNode")
.addFunction ("name", &XMLNode::name)
.endClass ()
.beginClass <PBD::Stateful> ("Stateful") .beginClass <PBD::Stateful> ("Stateful")
.addFunction ("properties", &PBD::Stateful::properties) .addFunction ("properties", &PBD::Stateful::properties)
.addFunction ("clear_changes", &PBD::Stateful::clear_changes) .addFunction ("clear_changes", &PBD::Stateful::clear_changes)
@ -174,6 +179,15 @@ LuaBindings::common (lua_State* L)
.beginWSPtrClass <Evoral::ControlList> ("ControlList") .beginWSPtrClass <Evoral::ControlList> ("ControlList")
.addFunction ("add", &Evoral::ControlList::add) .addFunction ("add", &Evoral::ControlList::add)
.addFunction ("thin", &Evoral::ControlList::thin)
.addFunction ("eval", &Evoral::ControlList::eval)
.addRefFunction ("rt_safe_eval", &Evoral::ControlList::rt_safe_eval)
.addFunction ("interpolation", &Evoral::ControlList::interpolation)
.addFunction ("set_interpolation", &Evoral::ControlList::set_interpolation)
.addFunction ("truncate_end", &Evoral::ControlList::truncate_end)
.addFunction ("truncate_start", &Evoral::ControlList::truncate_start)
.addFunction ("clear", (void (Evoral::ControlList::*)(double, double))&Evoral::ControlList::clear)
.addFunction ("in_write_pass", &Evoral::ControlList::in_write_pass)
.endClass () .endClass ()
.beginWSPtrClass <Evoral::ControlSet> ("ControlSet") .beginWSPtrClass <Evoral::ControlSet> ("ControlSet")
@ -197,6 +211,13 @@ LuaBindings::common (lua_State* L)
.addData ("to", &Evoral::Range<framepos_t>::to) .addData ("to", &Evoral::Range<framepos_t>::to)
.endClass () .endClass ()
/* libevoral enums */
.beginNamespace ("InterpolationStyle")
.addConst ("Discrete", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Discrete))
.addConst ("Linear", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Linear))
.addConst ("Curved", Evoral::ControlList::InterpolationStyle(Evoral::ControlList::Curved))
.endNamespace ()
.endNamespace () // Evoral .endNamespace () // Evoral
.beginNamespace ("ARDOUR") .beginNamespace ("ARDOUR")
@ -263,6 +284,17 @@ LuaBindings::common (lua_State* L)
.deriveClass <PBD::OwnedPropertyList, PBD::PropertyList> ("OwnedPropertyList") .deriveClass <PBD::OwnedPropertyList, PBD::PropertyList> ("OwnedPropertyList")
.endClass () .endClass ()
.beginWSPtrClass <AutomationList> ("AutomationList")
.addCast<PBD::Stateful> ("to_stateful")
.addCast<PBD::StatefulDestructible> ("to_statefuldestructible")
.addCast<Evoral::ControlList> ("list")
.addFunction ("get_state", &AutomationList::get_state)
.addFunction ("memento_command", &AutomationList::memento_command)
.addFunction ("touching", &AutomationList::touching)
.addFunction ("writing", &AutomationList::writing)
.addFunction ("touch_enabled", &AutomationList::touch_enabled)
.endClass ()
.deriveClass <Location, PBD::StatefulDestructible> ("Location") .deriveClass <Location, PBD::StatefulDestructible> ("Location")
.addFunction ("locked", &Location::locked) .addFunction ("locked", &Location::locked)
.addFunction ("lock", &Location::lock) .addFunction ("lock", &Location::lock)
@ -322,6 +354,8 @@ LuaBindings::common (lua_State* L)
.addFunction ("main_outs", &Route::main_outs) .addFunction ("main_outs", &Route::main_outs)
.addFunction ("muted", &Route::muted) .addFunction ("muted", &Route::muted)
.addFunction ("soloed", &Route::soloed) .addFunction ("soloed", &Route::soloed)
.addFunction ("amp", &Route::amp)
.addFunction ("trim", &Route::trim)
.endClass () .endClass ()
.deriveWSPtrClass <Playlist, SessionObject> ("Playlist") .deriveWSPtrClass <Playlist, SessionObject> ("Playlist")
@ -338,6 +372,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("find_next_region", &Playlist::find_next_region) .addFunction ("find_next_region", &Playlist::find_next_region)
.addFunction ("find_next_region_boundary", &Playlist::find_next_region_boundary) .addFunction ("find_next_region_boundary", &Playlist::find_next_region_boundary)
.addFunction ("count_regions_at", &Playlist::count_regions_at) .addFunction ("count_regions_at", &Playlist::count_regions_at)
.addFunction ("regions_touched", &Playlist::regions_touched)
.addFunction ("regions_with_start_within", &Playlist::regions_with_start_within) .addFunction ("regions_with_start_within", &Playlist::regions_with_start_within)
.addFunction ("regions_with_end_within", &Playlist::regions_with_end_within) .addFunction ("regions_with_end_within", &Playlist::regions_with_end_within)
.addFunction ("raise_region", &Playlist::raise_region) .addFunction ("raise_region", &Playlist::raise_region)
@ -508,13 +543,24 @@ LuaBindings::common (lua_State* L)
.endClass () .endClass ()
.deriveWSPtrClass <AutomationControl, Evoral::Control> ("AutomationControl") .deriveWSPtrClass <AutomationControl, Evoral::Control> ("AutomationControl")
.addCast<Evoral::Control> ("to_ctrl")
.addFunction ("automation_state", &AutomationControl::automation_state) .addFunction ("automation_state", &AutomationControl::automation_state)
.addFunction ("automation_style", &AutomationControl::automation_style)
.addFunction ("set_automation_state", &AutomationControl::set_automation_state)
.addFunction ("set_automation_style", &AutomationControl::set_automation_style) .addFunction ("set_automation_style", &AutomationControl::set_automation_style)
.addFunction ("start_touch", &AutomationControl::start_touch) .addFunction ("start_touch", &AutomationControl::start_touch)
.addFunction ("stop_touch", &AutomationControl::stop_touch) .addFunction ("stop_touch", &AutomationControl::stop_touch)
.addFunction ("get_value", &AutomationControl::get_value) .addFunction ("get_value", &AutomationControl::get_value)
.addFunction ("set_value", &AutomationControl::set_value) .addFunction ("set_value", &AutomationControl::set_value)
.addFunction ("writable", &AutomationControl::writable) .addFunction ("writable", &AutomationControl::writable)
.addFunction ("alist", &AutomationControl::alist)
.endClass ()
.deriveWSPtrClass <GainControl, AutomationControl> ("GainControl")
.endClass ()
.deriveWSPtrClass <Amp, Processor> ("Amp")
.addFunction ("gain_control", (boost::shared_ptr<GainControl>(Amp::*)())&Amp::gain_control)
.endClass () .endClass ()
.deriveWSPtrClass <PluginInsert::PluginControl, AutomationControl> ("PluginControl") .deriveWSPtrClass <PluginInsert::PluginControl, AutomationControl> ("PluginControl")
@ -642,6 +688,8 @@ LuaBindings::common (lua_State* L)
.beginNamespace ("AutomationType") .beginNamespace ("AutomationType")
.addConst ("PluginAutomation", ARDOUR::AutomationType(PluginAutomation)) .addConst ("PluginAutomation", ARDOUR::AutomationType(PluginAutomation))
.addConst ("PluginAutomation", ARDOUR::AutomationType(GainAutomation))
.addConst ("PluginAutomation", ARDOUR::AutomationType(TrimAutomation))
.endNamespace () .endNamespace ()
.beginNamespace ("SrcQuality") .beginNamespace ("SrcQuality")
@ -759,6 +807,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("begin_reversible_command", (void (Session::*)(const std::string&))&Session::begin_reversible_command) .addFunction ("begin_reversible_command", (void (Session::*)(const std::string&))&Session::begin_reversible_command)
.addFunction ("commit_reversible_command", &Session::commit_reversible_command) .addFunction ("commit_reversible_command", &Session::commit_reversible_command)
.addFunction ("abort_reversible_command", &Session::abort_reversible_command) .addFunction ("abort_reversible_command", &Session::abort_reversible_command)
.addFunction ("add_command", &Session::add_command)
.addFunction ("add_stateful_diff_command", &Session::add_stateful_diff_command) .addFunction ("add_stateful_diff_command", &Session::add_stateful_diff_command)
.endClass () .endClass ()
@ -784,6 +833,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin) .addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin)
.addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param) .addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param)
.addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param) .addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param)
.addCFunction ("plugin_automation", ARDOUR::LuaAPI::plugin_automation)
.addFunction ("usleep", Glib::usleep) .addFunction ("usleep", Glib::usleep)
.endNamespace () .endNamespace ()