Add Lua API to query plugin properties
This commit is contained in:
parent
cfa45be99f
commit
980eb595cf
|
@ -167,6 +167,14 @@ namespace ARDOUR { namespace LuaAPI {
|
|||
*/
|
||||
bool set_plugin_insert_property (std::shared_ptr<ARDOUR::PluginInsert> pi, std::string const& uri, luabridge::LuaRef value);
|
||||
|
||||
/** get a plugin property (LV2 plugins only)
|
||||
*
|
||||
* @param p two arguments: Plugin-Inster, URI of the property
|
||||
* @param value the value to set (boolean, integer, float, string/path)
|
||||
* @returns value, depending on datatype or nil if property is not found
|
||||
*/
|
||||
int get_plugin_insert_property (lua_State *lua);
|
||||
|
||||
/**
|
||||
* A convenience function to get a Automation Lists and ParameterDescriptor
|
||||
* for a given plugin control.
|
||||
|
|
|
@ -358,6 +358,11 @@ public:
|
|||
*/
|
||||
virtual void set_property (uint32_t key, const Variant& value) {}
|
||||
|
||||
virtual Variant get_property_value (uint32_t) const
|
||||
{
|
||||
return Variant();
|
||||
}
|
||||
|
||||
/** Emit PropertyChanged for all current property values. */
|
||||
virtual void announce_property_values () {}
|
||||
|
||||
|
|
|
@ -320,6 +320,58 @@ ARDOUR::LuaAPI::set_plugin_insert_property (std::shared_ptr<PluginInsert> pi, st
|
|||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
ARDOUR::LuaAPI::get_plugin_insert_property (lua_State* L)
|
||||
{
|
||||
typedef std::shared_ptr<PluginInsert> T;
|
||||
int top = lua_gettop (L);
|
||||
if (top < 2) {
|
||||
return luaL_argerror (L, 1, "invalid number of arguments, :get_plugin_insert_property (plugin, uri)");
|
||||
}
|
||||
|
||||
T* const pi = luabridge::Userdata::get<T> (L, 1, false);
|
||||
std::string uri = luabridge::Stack<std::string>::get (L, 2);
|
||||
if (!pi) {
|
||||
return luaL_error (L, "Invalid pointer to Ardour:PluginInsert");
|
||||
}
|
||||
|
||||
std::shared_ptr<Plugin> plugin = (*pi)->plugin ();
|
||||
if (!plugin) { return 0; }
|
||||
uint32_t key = URIMap::instance ().uri_to_id (uri.c_str ());
|
||||
plugin->announce_property_values ();
|
||||
wait_for_process_callback (1, 0);
|
||||
Variant v = plugin->get_property_value (key);
|
||||
switch (v.type ()) {
|
||||
case Variant::PATH:
|
||||
luabridge::Stack<std::string>::push (L, v.get_path ());
|
||||
return 1;
|
||||
case Variant::STRING:
|
||||
luabridge::Stack<std::string>::push (L, v.get_string ());
|
||||
return 1;
|
||||
case Variant::URI:
|
||||
luabridge::Stack<std::string>::push (L, v.get_uri ());
|
||||
return 1;
|
||||
case Variant::BOOL:
|
||||
luabridge::Stack<bool>::push (L, v.get_bool ());
|
||||
return 1;
|
||||
case Variant::DOUBLE:
|
||||
luabridge::Stack<double>::push (L, v.get_double ());
|
||||
return 1;
|
||||
case Variant::FLOAT:
|
||||
luabridge::Stack<float>::push (L, v.get_float ());
|
||||
return 1;
|
||||
case Variant::INT:
|
||||
luabridge::Stack<int>::push (L, v.get_int ());
|
||||
return 1;
|
||||
case Variant::LONG:
|
||||
luabridge::Stack<long>::push (L, v.get_long ());
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
ARDOUR::LuaAPI::set_processor_param (std::shared_ptr<Processor> proc, uint32_t which, float val)
|
||||
{
|
||||
|
|
|
@ -3133,6 +3133,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 ("set_plugin_insert_property", ARDOUR::LuaAPI::set_plugin_insert_property)
|
||||
.addCFunction ("get_plugin_insert_property", ARDOUR::LuaAPI::get_plugin_insert_property)
|
||||
.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)
|
||||
|
|
Loading…
Reference in New Issue