Add Lua API to conveniently set automation data
This commit is contained in:
parent
8b0b316565
commit
7dc1fbab5a
|
@ -191,6 +191,14 @@ namespace ARDOUR { namespace LuaAPI {
|
|||
*/
|
||||
int desc_scale_points (lua_State* p);
|
||||
|
||||
/* Replace all automation data for an AutomationContol from a Lua table
|
||||
* @param ac an AutomationControl
|
||||
* @param tbl Lua Table {[sample-time] = value}
|
||||
* @param thin thinning factor (-1; use default, 0: no thinning)
|
||||
* @returns true on success
|
||||
*/
|
||||
bool set_automation_data (std::shared_ptr<ARDOUR::AutomationControl> ac, luabridge::LuaRef tbl, double thin = -1);
|
||||
|
||||
/**
|
||||
* A convenience function for colorspace HSL to RGB conversion.
|
||||
* All ranges are 0..1
|
||||
|
|
|
@ -353,6 +353,36 @@ ARDOUR::LuaAPI::plugin_automation (lua_State *L)
|
|||
return 3;
|
||||
}
|
||||
|
||||
bool
|
||||
ARDOUR::LuaAPI::set_automation_data (std::shared_ptr<AutomationControl> ac, luabridge::LuaRef tbl, double thin)
|
||||
{
|
||||
if (!tbl.isTable () || !ac) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<ARDOUR::AutomationList> alist = ac->alist ();
|
||||
ParameterDescriptor const& desc = ac->desc ();
|
||||
|
||||
alist->freeze ();
|
||||
alist->clear ();
|
||||
for (luabridge::Iterator i (tbl); !i.isNil (); ++i) {
|
||||
if (!i.key ().isNumber () || !i.value ().isNumber ()) {
|
||||
continue;
|
||||
}
|
||||
samplecnt_t tme = i.key ().cast<int> ();
|
||||
double val = i.value ().cast<double> ();
|
||||
val = std::min<double> (desc.upper, std::max<double> (desc.lower, val));
|
||||
alist->fast_simple_add (timepos_t (tme), val);
|
||||
}
|
||||
alist->thaw ();
|
||||
if (thin < 0) {
|
||||
alist->thin (Config->get_automation_thinning_factor ());
|
||||
} else {
|
||||
alist->thin (thin);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
ARDOUR::LuaAPI::desc_scale_points (lua_State *L)
|
||||
{
|
||||
|
@ -1085,7 +1115,7 @@ LuaAPI::Rubberband::set_mapping (luabridge::LuaRef tbl)
|
|||
}
|
||||
size_t ss = i.key ().cast<double> ();
|
||||
size_t ds = i.value ().cast<double> ();
|
||||
printf ("ADD %ld %ld\n", ss, ds);
|
||||
//printf ("ADD %ld %ld\n", ss, ds);
|
||||
_mapping[ss] = ds;
|
||||
}
|
||||
return !_mapping.empty ();
|
||||
|
|
|
@ -3105,6 +3105,7 @@ LuaBindings::common (lua_State* L)
|
|||
.addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param)
|
||||
.addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param)
|
||||
.addFunction ("reset_processor_to_default", ARDOUR::LuaAPI::reset_processor_to_default)
|
||||
.addFunction ("set_automation_data", ARDOUR::LuaAPI::set_automation_data)
|
||||
.addRefFunction ("get_processor_param", ARDOUR::LuaAPI::get_processor_param)
|
||||
.addRefFunction ("get_plugin_insert_param", ARDOUR::LuaAPI::get_plugin_insert_param)
|
||||
.addCFunction ("desc_scale_points", ARDOUR::LuaAPI::desc_scale_points)
|
||||
|
|
Loading…
Reference in New Issue