Add Lua API to set plugin properties
This commit is contained in:
parent
4d5175e32e
commit
cfa45be99f
|
@ -158,6 +158,15 @@ namespace ARDOUR { namespace LuaAPI {
|
|||
*/
|
||||
float get_plugin_insert_param (std::shared_ptr<ARDOUR::PluginInsert> pi, uint32_t which, bool &ok);
|
||||
|
||||
/** set a plugin property (LV2 plugins only)
|
||||
*
|
||||
* @param pi Plugin-Insert
|
||||
* @param uri the identifier of the parameter
|
||||
* @param value the value to set (boolean, integer, float, string/path)
|
||||
* @returns true on success, false if the given plugin has no property with the given URI
|
||||
*/
|
||||
bool set_plugin_insert_property (std::shared_ptr<ARDOUR::PluginInsert> pi, std::string const& uri, luabridge::LuaRef value);
|
||||
|
||||
/**
|
||||
* A convenience function to get a Automation Lists and ParameterDescriptor
|
||||
* for a given plugin control.
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "ardour/region_factory.h"
|
||||
#include "ardour/simple_export.h"
|
||||
#include "ardour/source_factory.h"
|
||||
#include "ardour/uri_map.h"
|
||||
|
||||
#include "LuaBridge/LuaBridge.h"
|
||||
|
||||
|
@ -280,6 +281,45 @@ ARDOUR::LuaAPI::get_plugin_insert_param (std::shared_ptr<PluginInsert> pi, uint3
|
|||
return plugin->get_parameter ( controlid );
|
||||
}
|
||||
|
||||
bool
|
||||
ARDOUR::LuaAPI::set_plugin_insert_property (std::shared_ptr<PluginInsert> pi, std::string const& uri, luabridge::LuaRef value)
|
||||
{
|
||||
std::shared_ptr<Plugin> plugin = pi->plugin ();
|
||||
if (!plugin) { return false; }
|
||||
uint32_t key = URIMap::instance ().uri_to_id (uri.c_str ());
|
||||
const ParameterDescriptor& desc = plugin->get_property_descriptor (key);
|
||||
switch (desc.datatype) {
|
||||
case Variant::PATH:
|
||||
plugin->set_property(desc.key, Variant(Variant::PATH, value.cast<string> ()));
|
||||
return true;
|
||||
case Variant::STRING:
|
||||
plugin->set_property(desc.key, Variant(Variant::STRING, value.cast<string> ()));
|
||||
return true;
|
||||
case Variant::URI:
|
||||
plugin->set_property(desc.key, Variant(Variant::URI, value.cast<string> ()));
|
||||
return true;
|
||||
case Variant::BOOL:
|
||||
plugin->set_property(desc.key, Variant(Variant::BOOL, value.cast<bool> ()));
|
||||
return true;
|
||||
case Variant::DOUBLE:
|
||||
plugin->set_property(desc.key, Variant(Variant::DOUBLE, value.cast<double> ()));
|
||||
return true;
|
||||
case Variant::FLOAT:
|
||||
plugin->set_property(desc.key, Variant(Variant::FLOAT, value.cast<float> ()));
|
||||
return true;
|
||||
case Variant::INT:
|
||||
plugin->set_property(desc.key, Variant(Variant::INT, value.cast<int> ()));
|
||||
return true;
|
||||
case Variant::LONG:
|
||||
plugin->set_property(desc.key, Variant(Variant::LONG, value.cast<long> ()));
|
||||
return true;
|
||||
default:
|
||||
printf ("NO VARIANT\n");
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ARDOUR::LuaAPI::set_processor_param (std::shared_ptr<Processor> proc, uint32_t which, float val)
|
||||
{
|
||||
|
|
|
@ -3132,6 +3132,7 @@ LuaBindings::common (lua_State* L)
|
|||
.addFunction ("new_plugin_with_time_domain", ARDOUR::LuaAPI::new_plugin_with_time_domain)
|
||||
.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)
|
||||
.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