# HG changeset patch # User Chris Cannam # Date 1172513587 0 # Node ID dd11619b73bac7d46a68fe0e0b4f0adf5d152280 # Parent f8e362511b2f0a400eba09d64fb178ea9b04b654 * Update along with latest Vamp API change. This has not yet been tested. diff -r f8e362511b2f -r dd11619b73ba document/Document.cpp --- a/document/Document.cpp Mon Feb 26 16:32:37 2007 +0000 +++ b/document/Document.cpp Mon Feb 26 18:13:07 2007 +0000 @@ -149,7 +149,7 @@ Layer * Document::createDerivedLayer(LayerFactory::LayerType type, - TransformName transform) + TransformId transform) { Layer *newLayer = createLayer(type); if (!newLayer) return 0; @@ -162,7 +162,7 @@ } Layer * -Document::createDerivedLayer(TransformName transform, +Document::createDerivedLayer(TransformId transform, Model *inputModel, const PluginTransform::ExecutionContext &context, QString configurationXml) @@ -261,7 +261,7 @@ // This model was derived from the previous main // model: regenerate it. - TransformName transform = m_models[model].transform; + TransformId transform = m_models[model].transform; PluginTransform::ExecutionContext context = m_models[model].context; Model *replacementModel = @@ -309,7 +309,7 @@ } void -Document::addDerivedModel(TransformName transform, +Document::addDerivedModel(TransformId transform, Model *inputModel, const PluginTransform::ExecutionContext &context, Model *outputModelToAdd, @@ -356,7 +356,7 @@ } Model * -Document::addDerivedModel(TransformName transform, +Document::addDerivedModel(TransformId transform, Model *inputModel, const PluginTransform::ExecutionContext &context, QString configurationXml) diff -r f8e362511b2f -r dd11619b73ba document/Document.h --- a/document/Document.h Mon Feb 26 16:32:37 2007 +0000 +++ b/document/Document.h Mon Feb 26 18:13:07 2007 +0000 @@ -105,14 +105,14 @@ * by a transform layer _must_ be registered with the document * using addDerivedModel below. */ - Layer *createDerivedLayer(LayerFactory::LayerType, TransformName); + Layer *createDerivedLayer(LayerFactory::LayerType, TransformId); /** * Create and return a suitable layer for the given transform, * running the transform and associating the resulting model with * the new layer. */ - Layer *createDerivedLayer(TransformName, + Layer *createDerivedLayer(TransformId, Model *inputModel, const PluginTransform::ExecutionContext &context, QString configurationXml); @@ -135,7 +135,7 @@ * Add a derived model associated with the given transform, * running the transform and returning the resulting model. */ - Model *addDerivedModel(TransformName transform, + Model *addDerivedModel(TransformId transform, Model *inputModel, const PluginTransform::ExecutionContext &context, QString configurationXml); @@ -145,7 +145,7 @@ * is necessary to register any derived model that was not created * by the document using createDerivedModel or createDerivedLayer. */ - void addDerivedModel(TransformName, + void addDerivedModel(TransformId, Model *inputModel, const PluginTransform::ExecutionContext &context, Model *outputModelToAdd, @@ -236,7 +236,7 @@ // transform involved but the (target) model has been modified // since being generated from it. const Model *source; - TransformName transform; + TransformId transform; PluginTransform::ExecutionContext context; QString configurationXml; diff -r f8e362511b2f -r dd11619b73ba main/MainWindow.cpp --- a/main/MainWindow.cpp Mon Feb 26 16:32:37 2007 +0000 +++ b/main/MainWindow.cpp Mon Feb 26 18:13:07 2007 +0000 @@ -1219,10 +1219,10 @@ for (unsigned int i = 0; i < transforms.size(); ++i) { - QString description = transforms[i].description; - if (description == "") description = transforms[i].name; - -// std::cerr << "Plugin Description: " << description.toStdString() << std::endl; + QString name = transforms[i].name; + if (name == "") name = transforms[i].identifier; + +// std::cerr << "Plugin Name: " << name.toStdString() << std::endl; QString type = transforms[i].type; @@ -1233,13 +1233,13 @@ if (maker == "") maker = tr("Unknown"); maker.replace(QRegExp(tr(" [\\(<].*$")), ""); - QString pluginName = description.section(": ", 0, 0); - QString output = description.section(": ", 1); - - QAction *action = new QAction(tr("%1...").arg(description), this); + QString pluginName = name.section(": ", 0, 0); + QString output = name.section(": ", 1); + + QAction *action = new QAction(tr("%1...").arg(name), this); connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); - m_transformActions[action] = transforms[i].name; - m_transformActionsReverse[transforms[i].name] = action; + m_transformActions[action] = transforms[i].identifier; + m_transformActionsReverse[transforms[i].identifier] = action; connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); QString tip; @@ -1255,7 +1255,7 @@ if (categoryMenus[type].find(category) == categoryMenus[type].end()) { std::cerr << "WARNING: MainWindow::setupMenus: Internal error: " << "No category menu for transform \"" - << description.toStdString() << "\" (category = \"" + << name.toStdString() << "\" (category = \"" << category.toStdString() << "\")" << std::endl; } else { categoryMenus[type][category]->addAction(action); @@ -1264,7 +1264,7 @@ if (makerMenus[type].find(maker) == makerMenus[type].end()) { std::cerr << "WARNING: MainWindow::setupMenus: Internal error: " << "No maker menu for transform \"" - << description.toStdString() << "\" (maker = \"" + << name.toStdString() << "\" (maker = \"" << maker.toStdString() << "\")" << std::endl; } else { makerMenus[type][maker]->addAction(action); @@ -1272,7 +1272,7 @@ action = new QAction(tr("%1...").arg(output == "" ? pluginName : output), this); connect(action, SIGNAL(triggered()), this, SLOT(addLayer())); - m_transformActions[action] = transforms[i].name; + m_transformActions[action] = transforms[i].identifier; connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool))); action->setStatusTip(tip); @@ -3458,7 +3458,7 @@ return; } - TransformName transform = i->second; + TransformId transform = i->second; TransformFactory *factory = TransformFactory::getInstance(); QString configurationXml; @@ -4263,7 +4263,7 @@ message.getArgCount() == 1 && message.getArg(0).canConvert(QVariant::String)) { - TransformName transform = message.getArg(0).toString(); + TransformId transform = message.getArg(0).toString(); Layer *newLayer = m_document->createDerivedLayer (transform, diff -r f8e362511b2f -r dd11619b73ba main/MainWindow.h --- a/main/MainWindow.h Mon Feb 26 16:32:37 2007 +0000 +++ b/main/MainWindow.h Mon Feb 26 18:13:07 2007 +0000 @@ -287,10 +287,10 @@ typedef std::map PaneActionMap; PaneActionMap m_paneActions; - typedef std::map TransformActionMap; + typedef std::map TransformActionMap; TransformActionMap m_transformActions; - typedef std::map TransformActionReverseMap; + typedef std::map TransformActionReverseMap; TransformActionReverseMap m_transformActionsReverse; typedef std::map LayerActionMap; diff -r f8e362511b2f -r dd11619b73ba transform/FeatureExtractionPluginTransform.cpp --- a/transform/FeatureExtractionPluginTransform.cpp Mon Feb 26 16:32:37 2007 +0000 +++ b/transform/FeatureExtractionPluginTransform.cpp Mon Feb 26 18:13:07 2007 +0000 @@ -90,7 +90,7 @@ m_context.stepSize, m_context.blockSize)) { std::cerr << "FeatureExtractionPluginTransform: Plugin " - << m_plugin->getName() << " failed to initialise!" << std::endl; + << m_plugin->getIdentifier() << " failed to initialise!" << std::endl; return; } @@ -103,7 +103,7 @@ } for (size_t i = 0; i < outputs.size(); ++i) { - if (outputName == "" || outputs[i].name == outputName.toStdString()) { + if (outputName == "" || outputs[i].identifier == outputName.toStdString()) { m_outputFeatureNo = i; m_descriptor = new Vamp::Plugin::OutputDescriptor (outputs[i]); diff -r f8e362511b2f -r dd11619b73ba transform/Transform.h --- a/transform/Transform.h Mon Feb 26 16:32:37 2007 +0000 +++ b/transform/Transform.h Mon Feb 26 18:13:07 2007 +0000 @@ -20,7 +20,7 @@ #include "data/model/Model.h" -typedef QString TransformName; +typedef QString TransformId; /** * A Transform turns one data model into another. diff -r f8e362511b2f -r dd11619b73ba transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Mon Feb 26 16:32:37 2007 +0000 +++ b/transform/TransformFactory.cpp Mon Feb 26 18:13:07 2007 +0000 @@ -151,7 +151,7 @@ // disambiguate plugins with similar names - std::map descriptions; + std::map names; std::map pluginSources; std::map pluginMakers; @@ -160,16 +160,16 @@ TransformDesc desc = i->second; - QString td = desc.description; + QString td = desc.name; QString tn = td.section(": ", 0, 0); - QString pn = desc.name.section(":", 1, 1); + QString pn = desc.identifier.section(":", 1, 1); if (pluginSources.find(tn) != pluginSources.end()) { if (pluginSources[tn] != pn && pluginMakers[tn] != desc.maker) { - ++descriptions[tn]; + ++names[tn]; } } else { - ++descriptions[tn]; + ++names[tn]; pluginSources[tn] = pn; pluginMakers[tn] = desc.maker; } @@ -182,25 +182,25 @@ i != transforms.end(); ++i) { TransformDesc desc = i->second; - QString name = desc.name; + QString identifier = desc.identifier; QString maker = desc.maker; - QString td = desc.description; + QString td = desc.name; QString tn = td.section(": ", 0, 0); QString to = td.section(": ", 1); - if (descriptions[tn] > 1) { + if (names[tn] > 1) { maker.replace(QRegExp(tr(" [\\(<].*$")), ""); tn = QString("%1 [%2]").arg(tn).arg(maker); } if (to != "") { - desc.description = QString("%1: %2").arg(tn).arg(to); + desc.name = QString("%1: %2").arg(tn).arg(to); } else { - desc.description = tn; + desc.name = tn; } - m_transforms[name] = desc; + m_transforms[identifier] = desc; } } @@ -230,7 +230,7 @@ continue; } - QString pluginDescription = plugin->getDescription().c_str(); + QString pluginName = plugin->getName().c_str(); QString category = factory->getPluginCategory(pluginId); Vamp::Plugin::OutputList outputs = @@ -238,31 +238,33 @@ for (size_t j = 0; j < outputs.size(); ++j) { - QString transformName = QString("%1:%2") - .arg(pluginId).arg(outputs[j].name.c_str()); + QString transformId = QString("%1:%2") + .arg(pluginId).arg(outputs[j].identifier.c_str()); - QString userDescription; + QString userName; QString friendlyName; QString units = outputs[j].unit.c_str(); if (outputs.size() == 1) { - userDescription = pluginDescription; - friendlyName = pluginDescription; + userName = pluginName; + friendlyName = pluginName; } else { - userDescription = QString("%1: %2") - .arg(pluginDescription) - .arg(outputs[j].description.c_str()); - friendlyName = outputs[j].description.c_str(); + userName = QString("%1: %2") + .arg(pluginName) + .arg(outputs[j].name.c_str()); + friendlyName = outputs[j].name.c_str(); } bool configurable = (!plugin->getPrograms().empty() || !plugin->getParameterDescriptors().empty()); - transforms[transformName] = + std::cerr << "Adding feature extraction plugin transform: id = " << transformId.toStdString() << std::endl; + + transforms[transformId] = TransformDesc(tr("Analysis"), category, - transformName, - userDescription, + transformId, + userName, friendlyName, plugin->getMaker().c_str(), units, @@ -304,7 +306,7 @@ // std::cout << "TransformFactory::populateRealTimePlugins: plugin " << pluginId.toStdString() << " has " << descriptor->controlOutputPortCount << " control output ports, " << descriptor->audioOutputPortCount << " audio outputs, " << descriptor->audioInputPortCount << " audio inputs" << std::endl; - QString pluginDescription = descriptor->name.c_str(); + QString pluginName = descriptor->name.c_str(); QString category = factory->getPluginCategory(pluginId); bool configurable = (descriptor->parameterCount > 0); @@ -312,8 +314,8 @@ for (size_t j = 0; j < descriptor->controlOutputPortCount; ++j) { - QString transformName = QString("%1:%2").arg(pluginId).arg(j); - QString userDescription; + QString transformId = QString("%1:%2").arg(pluginId).arg(j); + QString userName; QString units; if (j < descriptor->controlOutputPortNames.size() && @@ -321,8 +323,8 @@ QString portName = descriptor->controlOutputPortNames[j].c_str(); - userDescription = tr("%1: %2") - .arg(pluginDescription) + userName = tr("%1: %2") + .arg(pluginName) .arg(portName); if (unitRE.indexIn(portName) >= 0) { @@ -331,22 +333,22 @@ } else if (descriptor->controlOutputPortCount > 1) { - userDescription = tr("%1: Output %2") - .arg(pluginDescription) + userName = tr("%1: Output %2") + .arg(pluginName) .arg(j + 1); } else { - userDescription = pluginDescription; + userName = pluginName; } - transforms[transformName] = + transforms[transformId] = TransformDesc(tr("Effects Data"), category, - transformName, - userDescription, - userDescription, + transformId, + userName, + userName, descriptor->maker.c_str(), units, configurable); @@ -357,18 +359,18 @@ if (descriptor->audioOutputPortCount > 0) { - QString transformName = QString("%1:A").arg(pluginId); + QString transformId = QString("%1:A").arg(pluginId); QString type = tr("Effects"); if (descriptor->audioInputPortCount == 0) { type = tr("Generators"); } - transforms[transformName] = + transforms[transformId] = TransformDesc(type, category, - transformName, - pluginDescription, - pluginDescription, + transformId, + pluginName, + pluginName, descriptor->maker.c_str(), "", configurable); @@ -378,42 +380,42 @@ } QString -TransformFactory::getTransformDescription(TransformName name) +TransformFactory::getTransformName(TransformId identifier) { - if (m_transforms.find(name) != m_transforms.end()) { - return m_transforms[name].description; + if (m_transforms.find(identifier) != m_transforms.end()) { + return m_transforms[identifier].name; } else return ""; } QString -TransformFactory::getTransformFriendlyName(TransformName name) +TransformFactory::getTransformFriendlyName(TransformId identifier) { - if (m_transforms.find(name) != m_transforms.end()) { - return m_transforms[name].friendlyName; + if (m_transforms.find(identifier) != m_transforms.end()) { + return m_transforms[identifier].friendlyName; } else return ""; } QString -TransformFactory::getTransformUnits(TransformName name) +TransformFactory::getTransformUnits(TransformId identifier) { - if (m_transforms.find(name) != m_transforms.end()) { - return m_transforms[name].units; + if (m_transforms.find(identifier) != m_transforms.end()) { + return m_transforms[identifier].units; } else return ""; } bool -TransformFactory::isTransformConfigurable(TransformName name) +TransformFactory::isTransformConfigurable(TransformId identifier) { - if (m_transforms.find(name) != m_transforms.end()) { - return m_transforms[name].configurable; + if (m_transforms.find(identifier) != m_transforms.end()) { + return m_transforms[identifier].configurable; } else return false; } bool -TransformFactory::getTransformChannelRange(TransformName name, +TransformFactory::getTransformChannelRange(TransformId identifier, int &min, int &max) { - QString id = name.section(':', 0, 2); + QString id = identifier.section(':', 0, 2); if (FeatureExtractionPluginFactory::instanceFor(id)) { @@ -445,7 +447,7 @@ } bool -TransformFactory::getChannelRange(TransformName name, Vamp::PluginBase *plugin, +TransformFactory::getChannelRange(TransformId identifier, Vamp::PluginBase *plugin, int &minChannels, int &maxChannels) { Vamp::Plugin *vp = 0; @@ -455,12 +457,12 @@ maxChannels = vp->getMaxChannelCount(); return true; } else { - return getTransformChannelRange(name, minChannels, maxChannels); + return getTransformChannelRange(identifier, minChannels, maxChannels); } } Model * -TransformFactory::getConfigurationForTransform(TransformName name, +TransformFactory::getConfigurationForTransform(TransformId identifier, const std::vector &candidateInputModels, PluginTransform::ExecutionContext &context, QString &configurationXml, @@ -485,12 +487,12 @@ candidateModelNames.push_back(modelName); } - QString id = name.section(':', 0, 2); - QString output = name.section(':', 3); + QString id = identifier.section(':', 0, 2); + QString output = identifier.section(':', 3); QString outputLabel = ""; bool ok = false; - configurationXml = m_lastConfigurations[name]; + configurationXml = m_lastConfigurations[identifier]; // std::cerr << "last configuration: " << configurationXml.toStdString() << std::endl; @@ -515,8 +517,8 @@ vp->getOutputDescriptors(); if (od.size() > 1) { for (size_t i = 0; i < od.size(); ++i) { - if (od[i].name == output.toStdString()) { - outputLabel = od[i].description.c_str(); + if (od[i].identifier == output.toStdString()) { + outputLabel = od[i].name.c_str(); break; } } @@ -579,7 +581,7 @@ } int minChannels = 1, maxChannels = sourceChannels; - getChannelRange(name, plugin, minChannels, maxChannels); + getChannelRange(identifier, plugin, minChannels, maxChannels); int targetChannels = sourceChannels; if (!effect) { @@ -636,18 +638,18 @@ } } - if (ok) m_lastConfigurations[name] = configurationXml; + if (ok) m_lastConfigurations[identifier] = configurationXml; return ok ? inputModel : 0; } PluginTransform::ExecutionContext -TransformFactory::getDefaultContextForTransform(TransformName name, +TransformFactory::getDefaultContextForTransform(TransformId identifier, Model *inputModel) { PluginTransform::ExecutionContext context(-1); - QString id = name.section(':', 0, 2); + QString id = identifier.section(':', 0, 2); if (FeatureExtractionPluginFactory::instanceFor(id)) { @@ -663,14 +665,14 @@ } Transform * -TransformFactory::createTransform(TransformName name, Model *inputModel, +TransformFactory::createTransform(TransformId identifier, Model *inputModel, const PluginTransform::ExecutionContext &context, QString configurationXml, bool start) { Transform *transform = 0; - QString id = name.section(':', 0, 2); - QString output = name.section(':', 3); + QString id = identifier.section(':', 0, 2); + QString output = identifier.section(':', 3); if (FeatureExtractionPluginFactory::instanceFor(id)) { transform = new FeatureExtractionPluginTransform(inputModel, @@ -683,26 +685,26 @@ id, context, configurationXml, - getTransformUnits(name), + getTransformUnits(identifier), output == "A" ? -1 : output.toInt()); } else { std::cerr << "TransformFactory::createTransform: Unknown transform \"" - << name.toStdString() << "\"" << std::endl; + << identifier.toStdString() << "\"" << std::endl; return transform; } if (start && transform) transform->start(); - transform->setObjectName(name); + transform->setObjectName(identifier); return transform; } Model * -TransformFactory::transform(TransformName name, Model *inputModel, +TransformFactory::transform(TransformId identifier, Model *inputModel, const PluginTransform::ExecutionContext &context, QString configurationXml) { - Transform *t = createTransform(name, inputModel, context, + Transform *t = createTransform(identifier, inputModel, context, configurationXml, false); if (!t) return 0; @@ -714,7 +716,7 @@ if (model) { QString imn = inputModel->objectName(); - QString trn = getTransformFriendlyName(name); + QString trn = getTransformFriendlyName(identifier); if (imn != "") { if (trn != "") { model->setObjectName(tr("%1: %2").arg(imn).arg(trn)); diff -r f8e362511b2f -r dd11619b73ba transform/TransformFactory.h --- a/transform/TransformFactory.h Mon Feb 26 16:32:37 2007 +0000 +++ b/transform/TransformFactory.h Mon Feb 26 18:13:07 2007 +0000 @@ -34,37 +34,37 @@ static TransformFactory *getInstance(); - // The name is intended to be computer-referenceable, and unique - // within the application. The description is intended to be + // The identifier is intended to be computer-referenceable, and + // unique within the application. The name is intended to be // human readable. In principle it doesn't have to be unique, but // the factory will add suffixes to ensure that it is, all the // same (just to avoid user confusion). The friendly name is a - // shorter version of the description. The type is also intended - // to be user-readable, for use in menus. + // shorter version of the name. The type is also intended to be + // user-readable, for use in menus. struct TransformDesc { TransformDesc() { } TransformDesc(QString _type, QString _category, - TransformName _name, QString _description, + TransformId _identifier, QString _name, QString _friendlyName, QString _maker, QString _units, bool _configurable) : type(_type), category(_category), - name(_name), description(_description), + identifier(_identifier), name(_name), friendlyName(_friendlyName), maker(_maker), units(_units), configurable(_configurable) { } QString type; // e.g. feature extraction plugin QString category; // e.g. time > onsets - TransformName name; // e.g. vamp:vamp-aubio:aubioonset - QString description; // plugin's desc if 1 output, else "desc: output" + TransformId identifier; // e.g. vamp:vamp-aubio:aubioonset + QString name; // plugin's name if 1 output, else "name: output" QString friendlyName; // short text for layer name QString maker; QString units; bool configurable; bool operator<(const TransformDesc &od) const { - return (description < od.description); + return (name < od.name); }; }; typedef std::vector TransformList; @@ -83,7 +83,7 @@ * be cancelled. Audio callback play source may be used to * audition effects plugins, if provided. */ - Model *getConfigurationForTransform(TransformName name, + Model *getConfigurationForTransform(TransformId identifier, const std::vector &candidateInputModels, PluginTransform::ExecutionContext &context, QString &configurationXml, @@ -93,7 +93,7 @@ * Get the default execution context for the given transform * and input model (if known). */ - PluginTransform::ExecutionContext getDefaultContextForTransform(TransformName name, + PluginTransform::ExecutionContext getDefaultContextForTransform(TransformId identifier, Model *inputModel = 0); /** @@ -109,29 +109,29 @@ * The returned model is owned by the caller and must be deleted * when no longer needed. */ - Model *transform(TransformName name, Model *inputModel, + Model *transform(TransformId identifier, Model *inputModel, const PluginTransform::ExecutionContext &context, QString configurationXml = ""); /** - * Full description of a transform, suitable for putting on a menu. + * Full name of a transform, suitable for putting on a menu. */ - QString getTransformDescription(TransformName name); + QString getTransformName(TransformId identifier); /** - * Brief but friendly description of a transform, suitable for use + * Brief but friendly name of a transform, suitable for use * as the name of the output layer. */ - QString getTransformFriendlyName(TransformName name); + QString getTransformFriendlyName(TransformId identifier); - QString getTransformUnits(TransformName name); + QString getTransformUnits(TransformId identifier); /** * Return true if the transform has any configurable parameters, * i.e. if getConfigurationForTransform can ever return a non-trivial * (not equivalent to empty) configuration string. */ - bool isTransformConfigurable(TransformName name); + bool isTransformConfigurable(TransformId identifier); /** * If the transform has a prescribed number or range of channel @@ -139,7 +139,7 @@ * minimum and maximum number of channel inputs the transform can * accept. Return false if it doesn't care. */ - bool getTransformChannelRange(TransformName name, + bool getTransformChannelRange(TransformId identifier, int &minChannels, int &maxChannels); //!!! Need some way to indicate that the input model has changed / @@ -153,27 +153,27 @@ void transformFinished(); protected: - Transform *createTransform(TransformName name, Model *inputModel, + Transform *createTransform(TransformId identifier, Model *inputModel, const PluginTransform::ExecutionContext &context, QString configurationXml, bool start); struct TransformIdent { - TransformName name; + TransformId identifier; QString configurationXml; }; - typedef std::map TransformConfigurationMap; + typedef std::map TransformConfigurationMap; TransformConfigurationMap m_lastConfigurations; - typedef std::map TransformDescriptionMap; + typedef std::map TransformDescriptionMap; TransformDescriptionMap m_transforms; void populateTransforms(); void populateFeatureExtractionPlugins(TransformDescriptionMap &); void populateRealTimePlugins(TransformDescriptionMap &); - bool getChannelRange(TransformName name, + bool getChannelRange(TransformId identifier, Vamp::PluginBase *plugin, int &min, int &max); static TransformFactory *m_instance;