Add Lua binding to query plugin-presets and scalepoints
This commit is contained in:
parent
270b043e8f
commit
e91fd1fce6
@ -175,6 +175,13 @@ namespace ARDOUR { namespace LuaAPI {
|
||||
*/
|
||||
int plugin_automation (lua_State *lua);
|
||||
|
||||
/*
|
||||
* A convenience function to get a scale-points from a ParamaterDescriptor
|
||||
* @param p a ParameterDescriptor
|
||||
* @returns Lua Table with "name" -> value pairs
|
||||
*/
|
||||
int desc_scale_points (lua_State* p);
|
||||
|
||||
/**
|
||||
* A convenience function for colorspace HSL to RGB conversion.
|
||||
* All ranges are 0..1
|
||||
|
@ -338,6 +338,28 @@ ARDOUR::LuaAPI::plugin_automation (lua_State *L)
|
||||
return 3;
|
||||
}
|
||||
|
||||
int
|
||||
ARDOUR::LuaAPI::desc_scale_points (lua_State *L)
|
||||
{
|
||||
typedef ParameterDescriptor T;
|
||||
|
||||
int top = lua_gettop (L);
|
||||
if (top < 1) {
|
||||
return luaL_argerror (L, 1, "invalid number of arguments, :plugin_scale_points (ParameterDescriptor)");
|
||||
}
|
||||
|
||||
T* const pd = luabridge::Userdata::get<T> (L, 1, false);
|
||||
luabridge::LuaRef tbl (luabridge::newTable (L));
|
||||
|
||||
if (pd && pd->scale_points) {
|
||||
for (ARDOUR::ScalePoints::const_iterator i = pd->scale_points->begin(); i != pd->scale_points->end(); ++i) {
|
||||
tbl[i->first] = i->second;
|
||||
}
|
||||
}
|
||||
luabridge::push (L, tbl);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ARDOUR::LuaAPI::sample_to_timecode (lua_State *L)
|
||||
{
|
||||
|
@ -1571,6 +1571,7 @@ LuaBindings::common (lua_State* L)
|
||||
.addFunction ("preset_by_label", &Plugin::preset_by_label)
|
||||
.addFunction ("preset_by_uri", &Plugin::preset_by_uri)
|
||||
.addFunction ("load_preset", &Plugin::load_preset)
|
||||
.addFunction ("last_preset", &Plugin::last_preset)
|
||||
.addFunction ("parameter_is_input", &Plugin::parameter_is_input)
|
||||
.addFunction ("parameter_is_output", &Plugin::parameter_is_output)
|
||||
.addFunction ("parameter_is_control", &Plugin::parameter_is_control)
|
||||
@ -2627,6 +2628,7 @@ LuaBindings::common (lua_State* L)
|
||||
.addFunction ("reset_processor_to_default", ARDOUR::LuaAPI::reset_processor_to_default)
|
||||
.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)
|
||||
.addCFunction ("plugin_automation", ARDOUR::LuaAPI::plugin_automation)
|
||||
.addCFunction ("hsla_to_rgba", ARDOUR::LuaAPI::hsla_to_rgba)
|
||||
.addCFunction ("color_to_rgba", ARDOUR::LuaAPI::color_to_rgba)
|
||||
|
@ -7,7 +7,7 @@ function factory () return function ()
|
||||
for p in ARDOUR.LuaAPI.list_plugins():iter() do
|
||||
print (p.name, p.unique_id, p.type)
|
||||
local psets = p:get_presets()
|
||||
if not empty:empty() then
|
||||
if not psets:empty() then
|
||||
for pset in psets:iter() do
|
||||
print (" - ", pset.label)
|
||||
end
|
||||
@ -25,19 +25,36 @@ function factory () return function ()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- load a plugin preset
|
||||
route = Session:get_remote_nth_route(2)
|
||||
local route = Session:get_remote_nth_route(2)
|
||||
assert (route)
|
||||
-- to 4th plugin (from top), ardour starts counting at zero
|
||||
plugin = route:nth_plugin(3):to_insert():plugin(0)
|
||||
local plugin = route:nth_plugin(3):to_insert():plugin(0)
|
||||
assert (not plugin:isnil())
|
||||
ps = plugin:preset_by_label("cutbass") -- get preset by name
|
||||
assert (ps)
|
||||
local ps = plugin:preset_by_label("cutbass") -- get preset by name
|
||||
if ps and ps.valid then
|
||||
print (ps.uri)
|
||||
plugin:load_preset (ps)
|
||||
end
|
||||
|
||||
-- query preset
|
||||
local lp = plugin:last_preset ()
|
||||
print ("valid?", lp.valid, "Preset ID:", lp.uri, "Preset Name:", lp.label, "User Preset (not factory):", lp.user)
|
||||
|
||||
-- list preset of given plugin
|
||||
if not psets:empty() then
|
||||
for pset in psets:iter() do
|
||||
print (" - ", pset.label, pset.uri)
|
||||
end
|
||||
end
|
||||
|
||||
-- print scale-points of a given plugin-parameter
|
||||
local _, pd = plugin:get_parameter_descriptor (3, ARDOUR.ParameterDescriptor())
|
||||
local sp = ARDOUR.LuaAPI.desc_scale_points (pd[2]);
|
||||
for k, v in pairs(sp) do
|
||||
print (k, v)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- add a LuaProcessor (here "Scope") to all tracks
|
||||
|
Loading…
Reference in New Issue
Block a user