add convenience lua API for looking up Plugins

This commit is contained in:
Robin Gareus 2016-03-20 21:16:18 +01:00
parent 6ecc8e9b3d
commit 6741679a98
3 changed files with 17 additions and 10 deletions

View file

@ -31,6 +31,7 @@
namespace ARDOUR { namespace LuaAPI { namespace ARDOUR { namespace LuaAPI {
boost::shared_ptr<ARDOUR::Processor> new_luaproc (ARDOUR::Session *s, const std::string&); boost::shared_ptr<ARDOUR::Processor> new_luaproc (ARDOUR::Session *s, const std::string&);
boost::shared_ptr<ARDOUR::PluginInfo> new_plugin_info (const std::string&, ARDOUR::PluginType);
boost::shared_ptr<ARDOUR::Processor> new_plugin (ARDOUR::Session *s, const std::string&, ARDOUR::PluginType, const std::string& preset = ""); boost::shared_ptr<ARDOUR::Processor> new_plugin (ARDOUR::Session *s, const std::string&, ARDOUR::PluginType, const std::string& preset = "");
bool set_processor_param (boost::shared_ptr<Processor> proc, uint32_t which, float val); bool set_processor_param (boost::shared_ptr<Processor> proc, uint32_t which, float val);
bool set_plugin_insert_param (boost::shared_ptr<PluginInsert> pi, uint32_t which, float val); bool set_plugin_insert_param (boost::shared_ptr<PluginInsert> pi, uint32_t which, float val);

View file

@ -67,14 +67,9 @@ ARDOUR::LuaAPI::new_luaproc (Session *s, const string& name)
return boost::shared_ptr<Processor> (new PluginInsert (*s, p)); return boost::shared_ptr<Processor> (new PluginInsert (*s, p));
} }
PluginInfoPtr
boost::shared_ptr<Processor> ARDOUR::LuaAPI::new_plugin_info (const string& name, ARDOUR::PluginType type)
ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType type, const string& preset)
{ {
if (!s) {
return boost::shared_ptr<Processor> ();
}
PluginManager& manager = PluginManager::instance(); PluginManager& manager = PluginManager::instance();
PluginInfoList all_plugs; PluginInfoList all_plugs;
all_plugs.insert(all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end()); all_plugs.insert(all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
@ -91,13 +86,23 @@ ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType t
all_plugs.insert(all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end()); all_plugs.insert(all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end());
#endif #endif
PluginInfoPtr pip;
for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) { for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
if (((*i)->name == name || (*i)->unique_id == name) && (*i)->type == type) { if (((*i)->name == name || (*i)->unique_id == name) && (*i)->type == type) {
pip = *i; return *i;
break;
} }
} }
return PluginInfoPtr ();
}
boost::shared_ptr<Processor>
ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType type, const string& preset)
{
if (!s) {
return boost::shared_ptr<Processor> ();
}
PluginInfoPtr pip = new_plugin_info (name, type);
if (!pip) { if (!pip) {
return boost::shared_ptr<Processor> (); return boost::shared_ptr<Processor> ();
} }

View file

@ -587,6 +587,7 @@ LuaBindings::common (lua_State* L)
.beginNamespace ("LuaAPI") .beginNamespace ("LuaAPI")
.addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc) .addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc)
.addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info)
.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)