Mercurial > hg > svcore
changeset 166:702fc936e6a6
* Pull transforms out of Layer menu (again) and into a separate Transforms
menu
* Add Recent Transforms submenu
* Add effects and generators to the transforms menu (not yet implemented)
as well as analysis plugins and data-from-effects (control output ports)
* Add a nice dictionary-volume-style alphabetic subdivision of plugin names
in plugins By Name menus
author | Chris Cannam |
---|---|
date | Fri, 22 Sep 2006 16:12:23 +0000 |
parents | 5ae5885d6ce3 |
children | 665342c6ec57 |
files | base/RecentFiles.cpp base/RecentFiles.h plugin/DSSIPluginFactory.cpp plugin/LADSPAPluginFactory.cpp plugin/LADSPAPluginInstance.cpp plugin/RealTimePluginFactory.h |
diffstat | 6 files changed, 150 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
--- a/base/RecentFiles.cpp Thu Sep 21 16:43:50 2006 +0000 +++ b/base/RecentFiles.cpp Fri Sep 22 16:12:23 2006 +0000 @@ -15,27 +15,14 @@ #include "RecentFiles.h" -#include "Preferences.h" - #include <QFileInfo> #include <QSettings> -RecentFiles * -RecentFiles::m_instance = 0; - -RecentFiles * -RecentFiles::getInstance(int maxFileCount) +RecentFiles::RecentFiles(QString settingsGroup, size_t maxCount) : + m_settingsGroup(settingsGroup), + m_maxCount(maxCount) { - if (!m_instance) { - m_instance = new RecentFiles(maxFileCount); - } - return m_instance; -} - -RecentFiles::RecentFiles(int maxFileCount) : - m_maxFileCount(maxFileCount) -{ - readFiles(); + read(); } RecentFiles::~RecentFiles() @@ -44,17 +31,17 @@ } void -RecentFiles::readFiles() +RecentFiles::read() { - m_files.clear(); + m_names.clear(); QSettings settings; - settings.beginGroup("RecentFiles"); + settings.beginGroup(m_settingsGroup); - for (unsigned int i = 0; i < 100; ++i) { - QString key = QString("recent-file-%1").arg(i); - QString filename = settings.value(key, "").toString(); - if (filename == "") break; - if (i < m_maxFileCount) m_files.push_back(filename); + for (size_t i = 0; i < 100; ++i) { + QString key = QString("recent-%1").arg(i); + QString name = settings.value(key, "").toString(); + if (name == "") break; + if (i < m_maxCount) m_names.push_back(name); else settings.setValue(key, ""); } @@ -62,16 +49,16 @@ } void -RecentFiles::writeFiles() +RecentFiles::write() { QSettings settings; - settings.beginGroup("RecentFiles"); + settings.beginGroup(m_settingsGroup); - for (unsigned int i = 0; i < m_maxFileCount; ++i) { - QString key = QString("recent-file-%1").arg(i); - QString filename = ""; - if (i < m_files.size()) filename = m_files[i]; - settings.setValue(key, filename); + for (size_t i = 0; i < m_maxCount; ++i) { + QString key = QString("recent-%1").arg(i); + QString name = ""; + if (i < m_names.size()) name = m_names[i]; + settings.setValue(key, name); } settings.endGroup(); @@ -80,50 +67,54 @@ void RecentFiles::truncateAndWrite() { - while (m_files.size() > m_maxFileCount) { - m_files.pop_back(); + while (m_names.size() > m_maxCount) { + m_names.pop_back(); } - writeFiles(); + write(); } std::vector<QString> -RecentFiles::getRecentFiles() const +RecentFiles::getRecent() const { - std::vector<QString> files; - for (unsigned int i = 0; i < m_maxFileCount; ++i) { - if (i < m_files.size()) { - files.push_back(m_files[i]); + std::vector<QString> names; + for (size_t i = 0; i < m_maxCount; ++i) { + if (i < m_names.size()) { + names.push_back(m_names[i]); } } - return files; + return names; } void -RecentFiles::addFile(QString filename) +RecentFiles::add(QString name) { - filename = QFileInfo(filename).absoluteFilePath(); - bool have = false; - for (unsigned int i = 0; i < m_files.size(); ++i) { - if (m_files[i] == filename) { + for (size_t i = 0; i < m_names.size(); ++i) { + if (m_names[i] == name) { have = true; break; } } if (!have) { - m_files.push_front(filename); + m_names.push_front(name); } else { - std::deque<QString> newfiles; - newfiles.push_back(filename); - for (unsigned int i = 0; i < m_files.size(); ++i) { - if (m_files[i] == filename) continue; - newfiles.push_back(m_files[i]); + std::deque<QString> newnames; + newnames.push_back(name); + for (size_t i = 0; i < m_names.size(); ++i) { + if (m_names[i] == name) continue; + newnames.push_back(m_names[i]); } } truncateAndWrite(); - emit recentFilesChanged(); + emit recentChanged(); } +void +RecentFiles::addFile(QString name) +{ + add(QFileInfo(name).absoluteFilePath()); +} +
--- a/base/RecentFiles.h Thu Sep 21 16:43:50 2006 +0000 +++ b/base/RecentFiles.h Fri Sep 22 16:12:23 2006 +0000 @@ -21,36 +21,55 @@ #include <vector> #include <deque> +/** + * RecentFiles manages a list of the names of recently-used objects, + * saving and restoring that list via QSettings. The names do not + * actually have to refer to files. + */ + class RecentFiles : public QObject { Q_OBJECT public: - // The maxFileCount argument will only be used the first time this is called - static RecentFiles *getInstance(int maxFileCount = 10); + /** + * Construct a RecentFiles object that saves and restores in the + * given QSettings group and truncates when the given count of + * strings is reached. + */ + RecentFiles(QString settingsGroup = "RecentFiles", size_t maxCount = 10); virtual ~RecentFiles(); - int getMaxFileCount() const { return m_maxFileCount; } + QString getSettingsGroup() const { return m_settingsGroup; } - std::vector<QString> getRecentFiles() const; + int getMaxCount() const { return m_maxCount; } + + std::vector<QString> getRecent() const; + + /** + * Add a name that should be treated as a literal string. + */ + void add(QString name); - void addFile(QString filename); + /** + * Add a name that should be treated as a file path and + * canonicalised appropriately. + */ + void addFile(QString name); signals: - void recentFilesChanged(); + void recentChanged(); protected: - RecentFiles(int maxFileCount); + QString m_settingsGroup; + size_t m_maxCount; - int m_maxFileCount; - std::deque<QString> m_files; + std::deque<QString> m_names; - void readFiles(); - void writeFiles(); + void read(); + void write(); void truncateAndWrite(); - - static RecentFiles *m_instance; }; #endif
--- a/plugin/DSSIPluginFactory.cpp Thu Sep 21 16:43:50 2006 +0000 +++ b/plugin/DSSIPluginFactory.cpp Fri Sep 22 16:12:23 2006 +0000 @@ -299,6 +299,7 @@ descriptor->run_multiple_synths); rtd->parameterCount = 0; rtd->audioInputPortCount = 0; + rtd->audioOutputPortCount = 0; rtd->controlOutputPortCount = 0; QString identifier = PluginIdentifier::createIdentifier @@ -310,8 +311,8 @@ QString category = m_taxonomy[identifier]; - if (category == "" && m_lrdfTaxonomy[descriptor->LADSPA_Plugin->UniqueID] != "") { - m_taxonomy[identifier] = m_lrdfTaxonomy[descriptor->LADSPA_Plugin->UniqueID]; + if (category == "" && m_lrdfTaxonomy[ladspaDescriptor->UniqueID] != "") { + m_taxonomy[identifier] = m_lrdfTaxonomy[ladspaDescriptor->UniqueID]; category = m_taxonomy[identifier]; } @@ -330,11 +331,12 @@ rtd->category = category.toStdString(); -// std::cerr << "Plugin id is " << ladspaDescriptor->UniqueID -// << ", category is \"" << (category ? category : QString("(none)")) -// << "\", name is " << ladspaDescriptor->Name -// << ", label is " << ladspaDescriptor->Label -// << std::endl; + std::cerr << "Plugin id is " << ladspaDescriptor->UniqueID + << ", identifier is \"" << identifier.toStdString() + << "\", category is \"" << category.toStdString() + << "\", name is " << ladspaDescriptor->Name + << ", label is " << ladspaDescriptor->Label + << std::endl; def_uri = lrdf_get_default_uri(ladspaDescriptor->UniqueID); if (def_uri) { @@ -378,6 +380,8 @@ } else { if (LADSPA_IS_PORT_INPUT(ladspaDescriptor->PortDescriptors[i])) { ++rtd->audioInputPortCount; + } else if (LADSPA_IS_PORT_OUTPUT(ladspaDescriptor->PortDescriptors[i])) { + ++rtd->audioOutputPortCount; } } }
--- a/plugin/LADSPAPluginFactory.cpp Thu Sep 21 16:43:50 2006 +0000 +++ b/plugin/LADSPAPluginFactory.cpp Fri Sep 22 16:12:23 2006 +0000 @@ -40,6 +40,9 @@ LADSPAPluginFactory::LADSPAPluginFactory() { +#ifdef HAVE_LRDF + lrdf_init(); +#endif } LADSPAPluginFactory::~LADSPAPluginFactory() @@ -51,6 +54,10 @@ } m_instances.clear(); unloadUnusedLibraries(); + +#ifdef HAVE_LRDF + lrdf_cleanup(); +#endif // HAVE_LRDF } const std::vector<QString> & @@ -437,8 +444,10 @@ if (QFileInfo(dir.filePath(fileName)).exists()) { std::cerr << "Loading: " << fileName.toStdString() << std::endl; libraryHandle = DLOPEN(dir.filePath(fileName), RTLD_NOW); - if (libraryHandle) m_libraryHandles[soName] = libraryHandle; - return; + if (libraryHandle) { + m_libraryHandles[soName] = libraryHandle; + return; + } } for (unsigned int j = 0; j < dir.count(); ++j) { @@ -446,8 +455,10 @@ if (QFileInfo(file).baseName() == base) { std::cerr << "Loading: " << file.toStdString() << std::endl; libraryHandle = DLOPEN(file, RTLD_NOW); - if (libraryHandle) m_libraryHandles[soName] = libraryHandle; - return; + if (libraryHandle) { + m_libraryHandles[soName] = libraryHandle; + return; + } } } } @@ -571,10 +582,8 @@ std::cerr << std::endl; #ifdef HAVE_LRDF - // Initialise liblrdf and read the description files + // read the description files // - lrdf_init(); - QString baseUri; std::vector<QString> lrdfPaths = getLRDFPath(baseUri); @@ -606,12 +615,6 @@ discoverPlugins(QString("%1/%2").arg(*i).arg(pluginDir[j])); } } - -#ifdef HAVE_LRDF - // Cleanup after the RDF library - // - lrdf_cleanup(); -#endif // HAVE_LRDF } void @@ -647,6 +650,7 @@ rtd->isSynth = false; rtd->parameterCount = 0; rtd->audioInputPortCount = 0; + rtd->audioOutputPortCount = 0; rtd->controlOutputPortCount = 0; QString identifier = PluginIdentifier::createIdentifier @@ -722,6 +726,8 @@ } else { if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { ++rtd->audioInputPortCount; + } else if (LADSPA_IS_PORT_OUTPUT(descriptor->PortDescriptors[i])) { + ++rtd->audioOutputPortCount; } } }
--- a/plugin/LADSPAPluginInstance.cpp Thu Sep 21 16:43:50 2006 +0000 +++ b/plugin/LADSPAPluginInstance.cpp Fri Sep 22 16:12:23 2006 +0000 @@ -24,6 +24,10 @@ #include "LADSPAPluginInstance.h" #include "LADSPAPluginFactory.h" +#ifdef HAVE_LRDF +#include "lrdf.h" +#endif // HAVE_LRDF + //#define DEBUG_LADSPA 1 @@ -122,6 +126,45 @@ pd.quantizeStep = q; } + bool haveLabels = false; + +#ifdef HAVE_LRDF + if (pd.isQuantized && pd.quantizeStep == 1.0) { + + lrdf_defaults *defaults = + lrdf_get_scale_values(m_descriptor->UniqueID, pn); + + if (defaults) { + if (defaults->count > 0) { + std::map<int, std::string> values; + int v = 0; + for (size_t i = 0; i < defaults->count; ++i) { + v = defaults->items[i].value; + values[v] = defaults->items[i].label; + } + for (size_t i = 0; i <= v; ++i) { + pd.valueNames.push_back(values[i]); + } + haveLabels = true; + } + lrdf_free_setting_values(defaults); + } + } +#endif + + if (haveLabels) { + pd.description = QString(pd.description.c_str()) + .replace(QRegExp("\\([^\\(\\)]+=[^\\(\\)]+\\)$"), "") + .toStdString(); + } else { + static QRegExp unitRE("[\\[\\(]([A-Za-z0-9/]+)[\\)\\]]$"); + if (unitRE.indexIn(pd.name.c_str()) >= 0) { + pd.unit = unitRE.cap(1).toStdString(); + pd.description = QString(pd.description.c_str()) + .replace(unitRE, "").toStdString(); + } + } + list.push_back(pd); }
--- a/plugin/RealTimePluginFactory.h Thu Sep 21 16:43:50 2006 +0000 +++ b/plugin/RealTimePluginFactory.h Fri Sep 22 16:12:23 2006 +0000 @@ -38,6 +38,7 @@ bool isSynth; unsigned int parameterCount; unsigned int audioInputPortCount; + unsigned int audioOutputPortCount; unsigned int controlOutputPortCount; std::vector<std::string> controlOutputPortNames; };