LV2 support.
[ardour.git] / libs / ardour / plugin_manager.cc
index 253c245fb7c0bed26744ec5ffe38e3f5524db1e8..183948f3733060dbdbe01223335c04f2ed59b097 100644 (file)
 #include <ardour/plugin.h>
 #include <ardour/ladspa_plugin.h>
 
+#ifdef HAVE_SLV2
+#include <slv2/slv2.h>
+#include <ardour/lv2_plugin.h>
+#endif
+
 #ifdef VST_SUPPORT
 #include <ardour/vst_plugin.h>
 #endif
@@ -101,6 +106,9 @@ PluginManager::PluginManager ()
                ladspa_plugin_whitelist.push_back (2150); // tap pitch shifter
        } 
 
+       _lv2_world = slv2_world_new();
+       slv2_world_load_all(_lv2_world);
+
        refresh ();
 }
 
@@ -108,6 +116,9 @@ void
 PluginManager::refresh ()
 {
        ladspa_refresh ();
+#ifdef HAVE_SLV2
+       lv2_refresh ();
+#endif
 #ifdef VST_SUPPORT
        if (Config->get_use_vst()) {
                vst_refresh ();
@@ -283,7 +294,7 @@ PluginManager::ladspa_discover (string path)
                info->type = ARDOUR::LADSPA;
                
                char buf[32];
-               snprintf (buf, sizeof (buf), "%u", descriptor->UniqueID);
+               snprintf (buf, sizeof (buf), "%lu", descriptor->UniqueID);
                info->unique_id = buf;
                
                for (uint32_t n=0; n < descriptor->PortCount; ++n) {
@@ -314,18 +325,18 @@ PluginManager::get_ladspa_category (uint32_t plugin_id)
 
        snprintf(buf, sizeof(buf), "%s%" PRIu32, LADSPA_BASE, plugin_id);
        pattern.subject = buf;
-       pattern.predicate = RDF_TYPE;
+       pattern.predicate = (char*)RDF_TYPE;
        pattern.object = 0;
        pattern.object_type = lrdf_uri;
 
        lrdf_statement* matches1 = lrdf_matches (&pattern);
 
        if (!matches1) {
-               return _("");
+               return "";
        }
 
        pattern.subject = matches1->object;
-       pattern.predicate = LADSPA_BASE "hasLabel";
+       pattern.predicate = (char*)(LADSPA_BASE "hasLabel");
        pattern.object = 0;
        pattern.object_type = lrdf_literal;
 
@@ -333,7 +344,7 @@ PluginManager::get_ladspa_category (uint32_t plugin_id)
        lrdf_free_statements(matches1);
 
        if (!matches2) {
-               return _("");
+               return ("");
        }
 
        string label = matches2->object;
@@ -342,6 +353,21 @@ PluginManager::get_ladspa_category (uint32_t plugin_id)
        return label;
 }
 
+#ifdef HAVE_SLV2
+void
+PluginManager::lv2_refresh ()
+{
+       lv2_discover();
+}
+
+int
+PluginManager::lv2_discover ()
+{
+       _lv2_plugin_info = LV2PluginInfo::discover(_lv2_world);
+       return 0;
+}
+#endif
+
 #ifdef HAVE_AUDIOUNITS
 void
 PluginManager::au_refresh ()
@@ -440,8 +466,8 @@ PluginManager::vst_discover (string path)
        }
 
        
-       snprintf (buf, sizeof (buf), "%d", finfo->uniqueID);
-       info->uniqueID = buf;
+       snprintf (buf, sizeof (buf), "%d", finfo->UniqueID);
+       info->unique_id = buf;
        info->category = "VST";
        info->path = path;
        // need to set info->creator but FST doesn't provide it