add convenience lua API for looking up Plugins
authorRobin Gareus <robin@gareus.org>
Sun, 20 Mar 2016 20:16:18 +0000 (21:16 +0100)
committerRobin Gareus <robin@gareus.org>
Sun, 20 Mar 2016 20:16:18 +0000 (21:16 +0100)
libs/ardour/ardour/lua_api.h
libs/ardour/lua_api.cc
libs/ardour/luabindings.cc

index 690957f47a05c6f47ce665a465e57a64c77f0050..997e0036df9d74e4e4771dbbfc77c63418c00d50 100644 (file)
@@ -31,6 +31,7 @@
 namespace ARDOUR { namespace LuaAPI {
 
        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 = "");
        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);
index 176a62005245e86f4360a2eb2f2e4402c332dade..c8c1217bc207e310192edcf02aa4c1d0b737b92d 100644 (file)
@@ -67,14 +67,9 @@ ARDOUR::LuaAPI::new_luaproc (Session *s, const string& name)
        return boost::shared_ptr<Processor> (new PluginInsert (*s, p));
 }
 
-
-boost::shared_ptr<Processor>
-ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType type, const string& preset)
+PluginInfoPtr
+ARDOUR::LuaAPI::new_plugin_info (const string& name, ARDOUR::PluginType type)
 {
-       if (!s) {
-               return boost::shared_ptr<Processor> ();
-       }
-
        PluginManager& manager = PluginManager::instance();
        PluginInfoList all_plugs;
        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());
 #endif
 
-       PluginInfoPtr pip;
        for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
                if (((*i)->name == name || (*i)->unique_id == name) && (*i)->type == type) {
-                       pip = *i;
-                       break;
+                       return *i;
                }
        }
+       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) {
                return boost::shared_ptr<Processor> ();
        }
index 0ad43ddad3afe64fa81683ebd9193d7aee9ddc4b..92a05dc4070274d6ec8ba159b09b3b31ecce69e7 100644 (file)
@@ -587,6 +587,7 @@ LuaBindings::common (lua_State* L)
 
                .beginNamespace ("LuaAPI")
                .addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc)
+               .addFunction ("new_plugin_info", ARDOUR::LuaAPI::new_plugin_info)
                .addFunction ("new_plugin", ARDOUR::LuaAPI::new_plugin)
                .addFunction ("set_processor_param", ARDOUR::LuaAPI::set_processor_param)
                .addFunction ("set_plugin_insert_param", ARDOUR::LuaAPI::set_plugin_insert_param)