# HG changeset patch # User Chris Cannam # Date 1158857030 0 # Node ID 5ae5885d6ce3e18048b1de472facc90c47005eec # Parent da3701a3953ed75d9dc8e14dab01b42ff2f4d006 * Add support for plugin classification using category files. Add separate menus listing plugins by category, maker, and plugin name. diff -r da3701a3953e -r 5ae5885d6ce3 base/Preferences.cpp --- a/base/Preferences.cpp Thu Sep 21 11:17:19 2006 +0000 +++ b/base/Preferences.cpp Thu Sep 21 16:43:50 2006 +0000 @@ -85,7 +85,7 @@ return tr("Spectral analysis window shape"); } if (name == "Resample Quality") { - return tr("Resampler quality"); + return tr("Playback resampler type"); } return name; } @@ -168,7 +168,7 @@ if (name == "Resample Quality") { switch (value) { case 0: return tr("Fastest"); - case 1: return tr("Medium quality"); + case 1: return tr("Standard"); case 2: return tr("Highest quality"); } } diff -r da3701a3953e -r 5ae5885d6ce3 plugin/DSSIPluginFactory.cpp --- a/plugin/DSSIPluginFactory.cpp Thu Sep 21 11:17:19 2006 +0000 +++ b/plugin/DSSIPluginFactory.cpp Thu Sep 21 16:43:50 2006 +0000 @@ -73,7 +73,7 @@ list.push_back(descriptor->Copyright); list.push_back((ddesc->run_synth || ddesc->run_multiple_synths) ? "true" : "false"); list.push_back(ddesc->run_multiple_synths ? "true" : "false"); - list.push_back(m_taxonomy[descriptor->UniqueID]); + list.push_back(m_taxonomy[*i]); list.push_back(QString("%1").arg(descriptor->PortCount)); for (unsigned long p = 0; p < descriptor->PortCount; ++p) { @@ -301,11 +301,19 @@ rtd->audioInputPortCount = 0; rtd->controlOutputPortCount = 0; + QString identifier = PluginIdentifier::createIdentifier + ("dssi", soname, ladspaDescriptor->Label); + #ifdef HAVE_LRDF char *def_uri = 0; lrdf_defaults *defs = 0; - QString category = m_taxonomy[ladspaDescriptor->UniqueID]; + QString category = m_taxonomy[identifier]; + + if (category == "" && m_lrdfTaxonomy[descriptor->LADSPA_Plugin->UniqueID] != "") { + m_taxonomy[identifier] = m_lrdfTaxonomy[descriptor->LADSPA_Plugin->UniqueID]; + category = m_taxonomy[identifier]; + } if (category == "" && ladspaDescriptor->Name != 0) { std::string name = ladspaDescriptor->Name; @@ -316,7 +324,7 @@ } else { category = "VST effects"; } - m_taxonomy[ladspaDescriptor->UniqueID] = category; + m_taxonomy[identifier] = category; } } @@ -374,8 +382,6 @@ } } - QString identifier = PluginIdentifier::createIdentifier - ("dssi", soname, ladspaDescriptor->Label); m_identifiers.push_back(identifier); m_rtDescriptors[identifier] = rtd; diff -r da3701a3953e -r 5ae5885d6ce3 plugin/FeatureExtractionPluginFactory.cpp --- a/plugin/FeatureExtractionPluginFactory.cpp Thu Sep 21 11:17:19 2006 +0000 +++ b/plugin/FeatureExtractionPluginFactory.cpp Thu Sep 21 16:43:50 2006 +0000 @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -171,6 +172,8 @@ } } + generateTaxonomy(); + return rv; } @@ -294,3 +297,54 @@ return rv; } +QString +FeatureExtractionPluginFactory::getPluginCategory(QString identifier) +{ + return m_taxonomy[identifier]; +} + +void +FeatureExtractionPluginFactory::generateTaxonomy() +{ + std::vector pluginPath = getPluginPath(); + std::vector path; + + for (size_t i = 0; i < pluginPath.size(); ++i) { + if (pluginPath[i].contains("/lib/")) { + QString p(pluginPath[i]); + path.push_back(p); + p.replace("/lib/", "/share/"); + path.push_back(p); + } + path.push_back(pluginPath[i]); + } + + for (size_t i = 0; i < path.size(); ++i) { + + QDir dir(path[i], "*.cat"); + +// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i].toStdString() << " has " << dir.count() << " .cat files" << std::endl; + for (unsigned int j = 0; j < dir.count(); ++j) { + + QFile file(path[i] + "/" + dir[j]); + +// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i].toStdString() + "/" + dir[j].toStdString()) << std::endl; + + if (file.open(QIODevice::ReadOnly)) { +// std::cerr << "...opened" << std::endl; + QTextStream stream(&file); + QString line; + + while (!stream.atEnd()) { + line = stream.readLine(); +// std::cerr << "line is: \"" << line.toStdString() << "\"" << std::endl; + QString id = PluginIdentifier::canonicalise + (line.section("::", 0, 0)); + QString cat = line.section("::", 1, 1); + m_taxonomy[id] = cat; +// std::cerr << "FeatureExtractionPluginFactory: set id \"" << id.toStdString() << "\" to cat \"" << cat.toStdString() << "\"" << std::endl; + } + } + } + } +} diff -r da3701a3953e -r 5ae5885d6ce3 plugin/FeatureExtractionPluginFactory.h --- a/plugin/FeatureExtractionPluginFactory.h Thu Sep 21 11:17:19 2006 +0000 +++ b/plugin/FeatureExtractionPluginFactory.h Thu Sep 21 16:43:50 2006 +0000 @@ -18,6 +18,7 @@ #include #include +#include namespace Vamp { class Plugin; } @@ -41,8 +42,16 @@ virtual Vamp::Plugin *instantiatePlugin(QString identifier, float inputSampleRate); + /** + * Get category metadata about a plugin (without instantiating it). + */ + virtual QString getPluginCategory(QString identifier); + protected: std::vector m_pluginPath; + std::map m_taxonomy; + + void generateTaxonomy(); }; #endif diff -r da3701a3953e -r 5ae5885d6ce3 plugin/LADSPAPluginFactory.cpp --- a/plugin/LADSPAPluginFactory.cpp Thu Sep 21 11:17:19 2006 +0000 +++ b/plugin/LADSPAPluginFactory.cpp Thu Sep 21 16:43:50 2006 +0000 @@ -80,16 +80,10 @@ list.push_back(descriptor->Copyright); list.push_back("false"); // is synth list.push_back("false"); // is grouped - - if (m_taxonomy.find(descriptor->UniqueID) != m_taxonomy.end() && - m_taxonomy[descriptor->UniqueID] != "") { + + if (m_taxonomy.find(*i) != m_taxonomy.end() && m_taxonomy[*i] != "") { // std::cerr << "LADSPAPluginFactory: cat for " << i->toStdString()<< " found in taxonomy as " << m_taxonomy[descriptor->UniqueID] << std::endl; - list.push_back(m_taxonomy[descriptor->UniqueID]); - - } else if (m_fallbackCategories.find(*i) != - m_fallbackCategories.end()) { - list.push_back(m_fallbackCategories[*i]); -// std::cerr << "LADSPAPluginFactory: cat for " << i->toStdString() <<" found in fallbacks as " << m_fallbackCategories[*i] << std::endl; + list.push_back(m_taxonomy[*i]); } else { list.push_back(""); @@ -655,18 +649,26 @@ rtd->audioInputPortCount = 0; rtd->controlOutputPortCount = 0; + QString identifier = PluginIdentifier::createIdentifier + ("ladspa", soname, descriptor->Label); + #ifdef HAVE_LRDF char *def_uri = 0; lrdf_defaults *defs = 0; - QString category = m_taxonomy[descriptor->UniqueID]; + if (m_lrdfTaxonomy[descriptor->UniqueID] != "") { + m_taxonomy[identifier] = m_lrdfTaxonomy[descriptor->UniqueID]; +// std::cerr << "set id \"" << identifier.toStdString() << "\" to cat \"" << m_taxonomy[identifier].toStdString() << "\" from LRDF" << std::endl; + } + + QString category = m_taxonomy[identifier]; if (category == "" && descriptor->Name != 0) { std::string name = descriptor->Name; if (name.length() > 4 && name.substr(name.length() - 4) == " VST") { category = "VST effects"; - m_taxonomy[descriptor->UniqueID] = category; + m_taxonomy[identifier] = category; } } @@ -724,8 +726,6 @@ } } - QString identifier = PluginIdentifier::createIdentifier - ("ladspa", soname, descriptor->Label); m_identifiers.push_back(identifier); m_rtDescriptors[identifier] = rtd; @@ -748,24 +748,25 @@ for (size_t i = 0; i < pluginPath.size(); ++i) { if (pluginPath[i].contains("/lib/")) { QString p(pluginPath[i]); + path.push_back(p); p.replace("/lib/", "/share/"); path.push_back(p); -// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << p << std::endl; +// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << p.toStdString() << std::endl; } path.push_back(pluginPath[i]); -// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i] << std::endl; +// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: path element " << pluginPath[i].toStdString() << std::endl; } for (size_t i = 0; i < path.size(); ++i) { QDir dir(path[i], "*.cat"); -// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i] << " has " << dir.count() << " .cat files" << std::endl; +// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i].toStdString() << " has " << dir.count() << " .cat files" << std::endl; for (unsigned int j = 0; j < dir.count(); ++j) { QFile file(path[i] + "/" + dir[j]); -// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i] + "/" + dir[j]) << std::endl; +// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i].toStdString() + "/" + dir[j].toStdString()) << std::endl; if (file.open(QIODevice::ReadOnly)) { // std::cerr << "...opened" << std::endl; @@ -774,11 +775,12 @@ while (!stream.atEnd()) { line = stream.readLine(); -// std::cerr << "line is: \"" << line << "\"" << std::endl; - QString id = line.section("::", 0, 0); +// std::cerr << "line is: \"" << line.toStdString() << "\"" << std::endl; + QString id = PluginIdentifier::canonicalise + (line.section("::", 0, 0)); QString cat = line.section("::", 1, 1); - m_fallbackCategories[id] = cat; -// std::cerr << "set id \"" << id << "\" to cat \"" << cat << "\"" << std::endl; + m_taxonomy[id] = cat; +// std::cerr << "set id \"" << id.toStdString() << "\" to cat \"" << cat.toStdString() << "\"" << std::endl; } } } @@ -793,7 +795,7 @@ if (uris != NULL) { for (int i = 0; i < uris->count; ++i) { - m_taxonomy[lrdf_get_uid(uris->items[i])] = base; + m_lrdfTaxonomy[lrdf_get_uid(uris->items[i])] = base; } lrdf_free_uris(uris); } @@ -811,4 +813,9 @@ #endif } +QString +LADSPAPluginFactory::getPluginCategory(QString identifier) +{ + return m_taxonomy[identifier]; +} diff -r da3701a3953e -r 5ae5885d6ce3 plugin/LADSPAPluginFactory.h --- a/plugin/LADSPAPluginFactory.h Thu Sep 21 11:17:19 2006 +0000 +++ b/plugin/LADSPAPluginFactory.h Thu Sep 21 16:43:50 2006 +0000 @@ -51,6 +51,8 @@ unsigned int blockSize, unsigned int channels); + virtual QString getPluginCategory(QString identifier); + float getPortMinimum(const LADSPA_Descriptor *, int port); float getPortMaximum(const LADSPA_Descriptor *, int port); float getPortDefault(const LADSPA_Descriptor *, int port); @@ -80,8 +82,8 @@ std::vector m_identifiers; std::map m_rtDescriptors; - std::map m_taxonomy; - std::map m_fallbackCategories; + std::map m_taxonomy; + std::map m_lrdfTaxonomy; std::map > m_portDefaults; std::set m_instances; diff -r da3701a3953e -r 5ae5885d6ce3 plugin/PluginIdentifier.cpp --- a/plugin/PluginIdentifier.cpp Thu Sep 21 11:17:19 2006 +0000 +++ b/plugin/PluginIdentifier.cpp Thu Sep 21 16:43:50 2006 +0000 @@ -31,6 +31,14 @@ return identifier; } +QString +PluginIdentifier::canonicalise(QString identifier) +{ + QString type, soName, label; + parseIdentifier(identifier, type, soName, label); + return createIdentifier(type, soName, label); +} + void PluginIdentifier::parseIdentifier(QString identifier, QString &type, diff -r da3701a3953e -r 5ae5885d6ce3 plugin/PluginIdentifier.h --- a/plugin/PluginIdentifier.h Thu Sep 21 11:17:19 2006 +0000 +++ b/plugin/PluginIdentifier.h Thu Sep 21 16:43:50 2006 +0000 @@ -33,6 +33,8 @@ static QString createIdentifier(QString type, QString soName, QString label); + static QString canonicalise(QString identifier); + static void parseIdentifier(QString identifier, QString &type, QString &soName, QString &label); diff -r da3701a3953e -r 5ae5885d6ce3 plugin/RealTimePluginFactory.h --- a/plugin/RealTimePluginFactory.h Thu Sep 21 11:17:19 2006 +0000 +++ b/plugin/RealTimePluginFactory.h Thu Sep 21 16:43:50 2006 +0000 @@ -86,6 +86,11 @@ unsigned int blockSize, unsigned int channels) = 0; + /** + * Get category metadata about a plugin (without instantiating it). + */ + virtual QString getPluginCategory(QString identifier) = 0; + protected: RealTimePluginFactory() { }