static void gst_ladspa_base_init (gpointer g_class) { GstLADSPAClass *klass = (GstLADSPAClass *) g_class; GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstSignalProcessorClass *gsp_class = GST_SIGNAL_PROCESSOR_CLASS (g_class); LADSPA_Descriptor *desc; guint j, audio_in_count, audio_out_count, control_in_count, control_out_count; const gchar *klass_tags; gchar *longname, *author; #ifdef HAVE_LRDF gchar *uri; #endif gchar *extra_klass_tags = NULL; GST_DEBUG ("base_init %p", g_class); desc = (LADSPA_Descriptor *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), descriptor_quark); g_assert (desc); klass->descriptor = desc; /* pad templates */ gsp_class->num_audio_in = 0; gsp_class->num_audio_out = 0; /* properties */ gsp_class->num_control_in = 0; gsp_class->num_control_out = 0; for (j = 0; j < desc->PortCount; j++) { LADSPA_PortDescriptor p = desc->PortDescriptors[j]; if (LADSPA_IS_PORT_AUDIO (p)) { gchar *name = g_strdup ((gchar *) desc->PortNames[j]); /* FIXME: group stereo pairs into a stereo pad * ladspa-fx have "XXX (Left)" and "XXX (Right)" * where XXX={In,Input,Out,Output} */ GST_DEBUG ("LADSPA port name: \"%s\"", name); /* replaces all spaces with underscores, and then remaining special chars * with '-' * FIXME: why, pads can have any name */ g_strdelimit (name, " ", '_'); g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "_-><=", '-'); GST_DEBUG ("GStreamer pad name: \"%s\"", name); if (LADSPA_IS_PORT_INPUT (p)) gst_signal_processor_class_add_pad_template (gsp_class, name, GST_PAD_SINK, gsp_class->num_audio_in++, 1); else gst_signal_processor_class_add_pad_template (gsp_class, name, GST_PAD_SRC, gsp_class->num_audio_out++, 1); g_free (name); } else if (LADSPA_IS_PORT_CONTROL (p)) { if (LADSPA_IS_PORT_INPUT (p)) gsp_class->num_control_in++; else gsp_class->num_control_out++; } } longname = g_locale_to_utf8 (desc->Name, -1, NULL, NULL, NULL); if (!longname) longname = g_strdup ("no description available"); author = g_locale_to_utf8 (desc->Maker, -1, NULL, NULL, NULL); if (!author) author = g_strdup ("no author available"); #ifdef HAVE_LRDF /* libldrf support, we want to get extra class information here */ uri = g_strdup_printf (LADSPA_BASE "%ld", desc->UniqueID); if (uri) { lrdf_statement query = { 0, }; lrdf_uris *uris; gchar *str, *base_type = NULL; GST_DEBUG ("uri (id=%d) : %s", desc->UniqueID, uri); /* we can take this directly from 'desc', keep this example for future attributes. if ((str = lrdf_get_setting_metadata (uri, "title"))) { GST_DEBUG ("title : %s", str); } if ((str = lrdf_get_setting_metadata (uri, "creator"))) { GST_DEBUG ("creator : %s", str); } */ /* get the rdf:type for this plugin */ query.subject = uri; query.predicate = (char *) RDF_BASE "type"; query.object = (char *) "?"; query.next = NULL; uris = lrdf_match_multi (&query); if (uris) { if (uris->count == 1) { base_type = g_strdup (uris->items[0]); GST_DEBUG ("base_type : %s", base_type); } lrdf_free_uris (uris); } /* query taxonomy */ if (base_type) { uris = lrdf_get_all_superclasses (base_type); if (uris) { guint32 j; for (j = 0; j < uris->count; j++) { GST_LOG ("parent_type_uri : %s", uris->items[j]); if ((str = lrdf_get_label (uris->items[j]))) { GST_DEBUG ("parent_type_label : %s", str); if (extra_klass_tags) { gchar *old_tags = extra_klass_tags; extra_klass_tags = g_strconcat (extra_klass_tags, "/", str, NULL); g_free (old_tags); } else { extra_klass_tags = g_strconcat ("/", str, NULL); } } } lrdf_free_uris (uris); } g_free (base_type); } /* we can use this for the presets uris = lrdf_get_setting_uris (desc->UniqueID); if (uris) { guint32 j; for (j = 0; j < uris->count; j++) { GST_INFO ("setting_uri : %s", uris->items[j]); if ((str = lrdf_get_label (uris->items[j]))) { GST_INFO ("setting_label : %s", str); } } lrdf_free_uris (uris); } */ } g_free (uri); #endif if (gsp_class->num_audio_in == 0) klass_tags = "Source/Audio/LADSPA"; else if (gsp_class->num_audio_out == 0) { if (gsp_class->num_control_out == 0) klass_tags = "Sink/Audio/LADSPA"; else klass_tags = "Sink/Analyzer/Audio/LADSPA"; } else klass_tags = "Filter/Effect/Audio/LADSPA"; #ifdef HAVE_LRDF if (extra_klass_tags) { char *s = g_strconcat (klass_tags, extra_klass_tags, NULL); g_free (extra_klass_tags); extra_klass_tags = s; } #endif GST_INFO ("tags : %s", klass_tags); gst_element_class_set_metadata (element_class, longname, extra_klass_tags ? extra_klass_tags : klass_tags, longname, author); g_free (longname); g_free (author); g_free (extra_klass_tags); klass->audio_in_portnums = g_new0 (gint, gsp_class->num_audio_in); klass->audio_out_portnums = g_new0 (gint, gsp_class->num_audio_out); klass->control_in_portnums = g_new0 (gint, gsp_class->num_control_in); klass->control_out_portnums = g_new0 (gint, gsp_class->num_control_out); audio_in_count = audio_out_count = control_in_count = control_out_count = 0; for (j = 0; j < desc->PortCount; j++) { LADSPA_PortDescriptor p = desc->PortDescriptors[j]; if (LADSPA_IS_PORT_AUDIO (p)) { if (LADSPA_IS_PORT_INPUT (p)) klass->audio_in_portnums[audio_in_count++] = j; else klass->audio_out_portnums[audio_out_count++] = j; } else if (LADSPA_IS_PORT_CONTROL (p)) { if (LADSPA_IS_PORT_INPUT (p)) klass->control_in_portnums[control_in_count++] = j; else klass->control_out_portnums[control_out_count++] = j; } } g_assert (audio_in_count == gsp_class->num_audio_in); g_assert (audio_out_count == gsp_class->num_audio_out); g_assert (control_in_count == gsp_class->num_control_in); g_assert (control_out_count == gsp_class->num_control_out); if (!LADSPA_IS_INPLACE_BROKEN (desc->Properties)) GST_SIGNAL_PROCESSOR_CLASS_SET_CAN_PROCESS_IN_PLACE (klass); klass->descriptor = desc; }
void LoadLadspaPlugins() { wxArrayString audacityPathList = wxGetApp().audacityPathList; wxArrayString pathList; wxArrayString files; wxSortedArrayString uniq; wxString pathVar; unsigned int i; #if defined(USE_LIBLRDF) && defined(EFFECT_CATEGORIES) EffectManager& em = EffectManager::Get(); wxArrayString rdfPathList; wxString rdfPathVar; wxArrayString rdfFiles; InitCategoryMap(); lrdf_init(); rdfPathVar = wxGetenv(wxT("LADSPA_RDF_PATH")); if (rdfPathVar != wxT("")) wxGetApp().AddMultiPathsToPathList(rdfPathVar, rdfPathList); #ifdef __WXGTK__ wxGetApp().AddUniquePathToPathList(wxT("/usr/share/ladspa/rdf"), rdfPathList); wxGetApp().AddUniquePathToPathList(wxT("/usr/local/share/ladspa/rdf"), rdfPathList); #endif #ifdef __WXMAC__ wxGetApp().AddUniquePathToPathList(wxT("/usr/share/ladspa/rdf"), rdfPathList); // XXX Maybe other Mac paths here? #endif #ifdef __WXMSW__ //wxGetApp().AddUniquePathToPathList(wxT("WINDOWS LRDF PATH"), // rdfPathList); // XXX Other Windows paths here. #endif // Add the Audacity paths so we get ladspa.rdfs if we are using a local // liblrdf for(i=0; i<audacityPathList.GetCount(); i++) { wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH; wxGetApp().AddUniquePathToPathList(prefix + wxT("rdf"), rdfPathList); } wxGetApp().FindFilesInPathList(wxT("*.rdf"), rdfPathList, rdfFiles); wxGetApp().FindFilesInPathList(wxT("*.rdfs"), rdfPathList, rdfFiles); for(size_t i = 0; i < rdfFiles.GetCount(); ++i) { wxString fileUri(wxT("file://")); fileUri += rdfFiles[i]; lrdf_read_file(fileUri.mb_str(wxConvUTF8)); } // Add all plugin categories found by LRDF lrdf_uris* cats = lrdf_get_all_subclasses("http://ladspa.org/ontology#Plugin"); if (cats) { // Add the categories and find the plugins belonging to them for (size_t i = 0; i < cats->count; ++i) { char* label = lrdf_get_label(cats->items[i]); if (!label) continue; wxString uri = MapCategoryUri(wxString::FromAscii(cats->items[i])); em.AddCategory(uri, wxString::FromUTF8(label)); std::free(label); lrdf_uris* plugs = lrdf_get_instances(cats->items[i]); if (plugs) { for (size_t j = 0; j < plugs->count; ++j) { unsigned long uid = lrdf_get_uid(plugs->items[j]); gPluginCategories.insert(std::make_pair(uid, uri)); } lrdf_free_uris(plugs); } } // And their relationships for (size_t i = 0; i < cats->count; ++i) { EffectCategory* p = em.LookupCategory(MapCategoryUri(wxString::FromAscii(cats-> items[i]))); if (!p) continue; lrdf_uris* subs = lrdf_get_subclasses(cats->items[i]); if (subs) { for (size_t j = 0; j < subs->count; ++j) { EffectCategory* c = em.LookupCategory(MapCategoryUri(wxString::FromAscii(subs->items[j]))); if (c) em.AddCategoryParent(c, p); } lrdf_free_uris(subs); } } lrdf_free_uris(cats); } #endif pathVar = wxGetenv(wxT("LADSPA_PATH")); if (pathVar != wxT("")) wxGetApp().AddMultiPathsToPathList(pathVar, pathList); #ifdef __WXGTK__ wxGetApp().AddUniquePathToPathList(wxT(INSTALL_PREFIX) wxT("/ladspa"), pathList); wxGetApp().AddUniquePathToPathList(wxT("/usr/local/lib/ladspa"), pathList); wxGetApp().AddUniquePathToPathList(wxT(LIBDIR) wxT("/ladspa"), pathList); #endif #ifdef __WXMAC__ wxGetApp().AddUniquePathToPathList(wxT("~/Library/Audio/Plug-Ins/LADSPA"), pathList); wxGetApp().AddUniquePathToPathList(wxT("/Library/Audio/Plug-Ins/LADSPA"), pathList); #endif for(i=0; i<audacityPathList.GetCount(); i++) { wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH; wxGetApp().AddUniquePathToPathList(prefix + wxT("ladspa"), pathList); wxGetApp().AddUniquePathToPathList(prefix + wxT("plugins"), pathList); wxGetApp().AddUniquePathToPathList(prefix + wxT("plug-ins"), pathList); } #ifdef __WXMSW__ wxGetApp().FindFilesInPathList(wxT("*.dll"), pathList, files); #else wxGetApp().FindFilesInPathList(wxT("*.so"), pathList, files); #endif for(i=0; i<files.GetCount(); i++) LoadLadspaEffect(uniq, files[i], ladspa_dls); }
wxArrayString LadspaEffectsModule::FindPlugins(PluginManagerInterface & pm) { #if defined(USE_LIBLRDF) && defined(EFFECT_CATEGORIES) EffectManager& em = EffectManager::Get(); wxArrayString rdfPathList; wxString rdfPathVar; wxArrayString rdfFiles; InitCategoryMap(); lrdf_init(); rdfPathVar = wxGetenv(wxT("LADSPA_RDF_PATH")); if (rdfPathVar != wxT("")) wxGetApp().AddMultiPathsToPathList(rdfPathVar, rdfPathList); #ifdef __WXGTK__ wxGetApp().AddUniquePathToPathList(wxT("/usr/share/ladspa/rdf"), rdfPathList); wxGetApp().AddUniquePathToPathList(wxT("/usr/local/share/ladspa/rdf"), rdfPathList); #endif #ifdef __WXMAC__ wxGetApp().AddUniquePathToPathList(wxT("/usr/share/ladspa/rdf"), rdfPathList); // XXX Maybe other Mac paths here? #endif #ifdef __WXMSW__ //wxGetApp().AddUniquePathToPathList(wxT("WINDOWS LRDF PATH"), // rdfPathList); // XXX Other Windows paths here. #endif // Add the Audacity paths so we get ladspa.rdfs if we are using a local // liblrdf for(i=0; i<audacityPathList.GetCount(); i++) { wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH; wxGetApp().AddUniquePathToPathList(prefix + wxT("rdf"), rdfPathList); } wxGetApp().FindFilesInPathList(wxT("*.rdf"), rdfPathList, rdfFiles); wxGetApp().FindFilesInPathList(wxT("*.rdfs"), rdfPathList, rdfFiles); for(size_t i = 0; i < rdfFiles.GetCount(); ++i) { wxString fileUri(wxT("file://")); fileUri += rdfFiles[i]; lrdf_read_file(fileUri.mb_str(wxConvUTF8)); } // Add all plugin categories found by LRDF lrdf_uris* cats = lrdf_get_all_subclasses("http://ladspa.org/ontology#Plugin"); if (cats) { // Add the categories and find the plugins belonging to them for (size_t i = 0; i < cats->count; ++i) { char* label = lrdf_get_label(cats->items[i]); if (!label) continue; wxString uri = MapCategoryUri(wxString::FromAscii(cats->items[i])); em.AddCategory(uri, wxString::FromUTF8(label)); std::free(label); lrdf_uris* plugs = lrdf_get_instances(cats->items[i]); if (plugs) { for (size_t j = 0; j < plugs->count; ++j) { unsigned long uid = lrdf_get_uid(plugs->items[j]); gPluginCategories.insert(std::make_pair(uid, uri)); } lrdf_free_uris(plugs); } } // And their relationships for (size_t i = 0; i < cats->count; ++i) { EffectCategory* p = em.LookupCategory(MapCategoryUri(wxString::FromAscii(cats-> items[i]))); if (!p) continue; lrdf_uris* subs = lrdf_get_subclasses(cats->items[i]); if (subs) { for (size_t j = 0; j < subs->count; ++j) { EffectCategory* c = em.LookupCategory(MapCategoryUri(wxString::FromAscii(subs->items[j]))); if (c) em.AddCategoryParent(c, p); } lrdf_free_uris(subs); } } lrdf_free_uris(cats); } #endif wxArrayString pathList; wxArrayString files; wxString pathVar; // Check for the LADSPA_PATH environment variable pathVar = wxString::FromUTF8(getenv("LADSPA_PATH")); if (!pathVar.empty()) { wxStringTokenizer tok(pathVar); while (tok.HasMoreTokens()) { pathList.Add(tok.GetNextToken()); } } #if defined(__WXMAC__) #define LADSPAPATH wxT("/Library/Audio/Plug-Ins/LADSPA") // Look in ~/Library/Audio/Plug-Ins/LADSPA and /Library/Audio/Plug-Ins/LADSPA pathList.Add(wxGetHomeDir() + wxFILE_SEP_PATH + LADSPAPATH); pathList.Add(LADSPAPATH); // Recursively scan for all shared objects pm.FindFilesInPathList(wxT("*.so"), pathList, files, true); #elif defined(__WXMSW__) // Recursively scan for all DLLs pm.FindFilesInPathList(wxT("*.dll"), pathList, files, true); #else pathList.Add(wxGetHomeDir() + wxFILE_SEP_PATH + wxT(".ladspa")); pathList.Add(wxT("/usr/local/lib/ladspa")); pathList.Add(wxT("/usr/lib/ladspa")); pathList.Add(wxT(LIBDIR) wxT("/ladspa")); // Recursively scan for all shared objects pm.FindFilesInPathList(wxT("*.so"), pathList, files, true); #endif return files; }