Mercurial > hg > vamp-plugin-sdk
changeset 49:aa64a46320d4
* Rename "name" and "description" to "identifier" and "name"; add new
"description" that actually contains a description
author | cannam |
---|---|
date | Mon, 26 Feb 2007 18:08:48 +0000 |
parents | f46bf5e0fa42 |
children | b907557b2fb9 |
files | examples/AmplitudeFollower.cpp examples/AmplitudeFollower.h examples/PercussionOnsetDetector.cpp examples/PercussionOnsetDetector.h examples/SpectralCentroid.cpp examples/SpectralCentroid.h examples/ZeroCrossing.cpp examples/ZeroCrossing.h host/vamp-simple-host.cpp vamp-sdk/Plugin.h vamp-sdk/PluginAdapter.cpp vamp-sdk/PluginBase.h vamp-sdk/PluginHostAdapter.cpp vamp-sdk/PluginHostAdapter.h vamp/vamp.h |
diffstat | 15 files changed, 179 insertions(+), 79 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/AmplitudeFollower.cpp Thu Jan 25 13:39:31 2007 +0000 +++ b/examples/AmplitudeFollower.cpp Mon Feb 26 18:08:48 2007 +0000 @@ -66,15 +66,21 @@ } string -AmplitudeFollower::getName() const +AmplitudeFollower::getIdentifier() const { return "amplitudefollower"; } string +AmplitudeFollower::getName() const +{ + return "Amplitude Follower"; +} + +string AmplitudeFollower::getDescription() const { - return "Amplitude Follower"; + return "Track the amplitude of the audio signal"; } string @@ -124,9 +130,10 @@ OutputList list; OutputDescriptor sca; - sca.name = "amplitude"; + sca.identifier = "amplitude"; + sca.name = "Amplitude"; + sca.description = ""; sca.unit = "V"; - sca.description = "Amplitude"; sca.hasFixedBinCount = true; sca.binCount = 1; sca.hasKnownExtents = false; @@ -143,8 +150,9 @@ ParameterList list; ParameterDescriptor att; - att.name = "attack"; - att.description = "Attack time"; + att.identifier = "attack"; + att.name = "Attack time"; + att.description = ""; att.unit = "s"; att.minValue = 0.0f; att.maxValue = 1.f; @@ -154,8 +162,9 @@ list.push_back(att); ParameterDescriptor dec; - dec.name = "release"; - dec.description = "Release time"; + dec.identifier = "release"; + dec.name = "Release time"; + dec.description = ""; dec.unit = "s"; dec.minValue = 0.0f; dec.maxValue = 1.f; @@ -167,20 +176,20 @@ return list; } -void AmplitudeFollower::setParameter(std::string paramname, float newval) +void AmplitudeFollower::setParameter(std::string paramid, float newval) { - if (paramname == "attack") { + if (paramid == "attack") { m_clampcoef = newval; - } else if (paramname == "release") { + } else if (paramid == "release") { m_relaxcoef = newval; } } -float AmplitudeFollower::getParameter(std::string paramname) const +float AmplitudeFollower::getParameter(std::string paramid) const { - if (paramname == "attack") { + if (paramid == "attack") { return m_clampcoef; - } else if (paramname == "release") { + } else if (paramid == "release") { return m_relaxcoef; }
--- a/examples/AmplitudeFollower.h Thu Jan 25 13:39:31 2007 +0000 +++ b/examples/AmplitudeFollower.h Mon Feb 26 18:08:48 2007 +0000 @@ -50,6 +50,7 @@ InputDomain getInputDomain() const { return TimeDomain; } + std::string getIdentifier() const; std::string getName() const; std::string getDescription() const; std::string getMaker() const; @@ -59,8 +60,8 @@ OutputList getOutputDescriptors() const; ParameterList getParameterDescriptors() const; - float getParameter(std::string paramname) const; - void setParameter(std::string paramname, float newval); + float getParameter(std::string paramid) const; + void setParameter(std::string paramid, float newval); FeatureSet process(const float *const *inputBuffers, Vamp::RealTime timestamp);
--- a/examples/PercussionOnsetDetector.cpp Thu Jan 25 13:39:31 2007 +0000 +++ b/examples/PercussionOnsetDetector.cpp Mon Feb 26 18:08:48 2007 +0000 @@ -62,15 +62,21 @@ } string -PercussionOnsetDetector::getName() const +PercussionOnsetDetector::getIdentifier() const { return "percussiononsets"; } string +PercussionOnsetDetector::getName() const +{ + return "Simple Percussion Onset Detector"; +} + +string PercussionOnsetDetector::getDescription() const { - return "Simple Percussion Onset Detector"; + return "Detect percussive note onsets by identifying broadband energy rises"; } string @@ -141,8 +147,9 @@ ParameterList list; ParameterDescriptor d; - d.name = "threshold"; - d.description = "Broadband energy rise threshold"; + d.identifier = "threshold"; + d.name = "Energy rise threshold"; + d.description = "Energy rise within a frequency bin necessary to count toward broadband total"; d.unit = "dB"; d.minValue = 0; d.maxValue = 20; @@ -150,8 +157,9 @@ d.isQuantized = false; list.push_back(d); - d.name = "sensitivity"; - d.description = "Peak detection sensitivity"; + d.identifier = "sensitivity"; + d.name = "Sensitivity"; + d.description = "Sensitivity of peak detector applied to broadband detection function"; d.unit = "%"; d.minValue = 0; d.maxValue = 100; @@ -163,21 +171,21 @@ } float -PercussionOnsetDetector::getParameter(std::string name) const +PercussionOnsetDetector::getParameter(std::string id) const { - if (name == "threshold") return m_threshold; - if (name == "sensitivity") return m_sensitivity; + if (id == "threshold") return m_threshold; + if (id == "sensitivity") return m_sensitivity; return 0.f; } void -PercussionOnsetDetector::setParameter(std::string name, float value) +PercussionOnsetDetector::setParameter(std::string id, float value) { - if (name == "threshold") { + if (id == "threshold") { if (value < 0) value = 0; if (value > 20) value = 20; m_threshold = value; - } else if (name == "sensitivity") { + } else if (id == "sensitivity") { if (value < 0) value = 0; if (value > 100) value = 100; m_sensitivity = value; @@ -190,9 +198,10 @@ OutputList list; OutputDescriptor d; - d.name = "onsets"; + d.identifier = "onsets"; + d.name = "Onsets"; + d.description = "Percussive note onset locations"; d.unit = ""; - d.description = "Onsets"; d.hasFixedBinCount = true; d.binCount = 0; d.hasKnownExtents = false; @@ -201,8 +210,9 @@ d.sampleRate = m_inputSampleRate; list.push_back(d); - d.name = "detectionfunction"; - d.description = "Onset Detection Function"; + d.identifier = "detectionfunction"; + d.name = "Detection Function"; + d.description = "Broadband energy rise detection function"; d.binCount = 1; d.isQuantized = true; d.quantizeStep = 1.0;
--- a/examples/PercussionOnsetDetector.h Thu Jan 25 13:39:31 2007 +0000 +++ b/examples/PercussionOnsetDetector.h Mon Feb 26 18:08:48 2007 +0000 @@ -50,6 +50,7 @@ InputDomain getInputDomain() const { return FrequencyDomain; } + std::string getIdentifier() const; std::string getName() const; std::string getDescription() const; std::string getMaker() const; @@ -60,8 +61,8 @@ size_t getPreferredBlockSize() const; ParameterList getParameterDescriptors() const; - float getParameter(std::string name) const; - void setParameter(std::string name, float value); + float getParameter(std::string id) const; + void setParameter(std::string id, float value); OutputList getOutputDescriptors() const;
--- a/examples/SpectralCentroid.cpp Thu Jan 25 13:39:31 2007 +0000 +++ b/examples/SpectralCentroid.cpp Mon Feb 26 18:08:48 2007 +0000 @@ -56,15 +56,21 @@ } string -SpectralCentroid::getName() const +SpectralCentroid::getIdentifier() const { return "spectralcentroid"; } string +SpectralCentroid::getName() const +{ + return "Spectral Centroid"; +} + +string SpectralCentroid::getDescription() const { - return "Spectral Centroid"; + return "Calculate the centroid frequency of the spectrum of the input signal"; } string @@ -108,9 +114,10 @@ OutputList list; OutputDescriptor d; - d.name = "logcentroid"; + d.identifier = "logcentroid"; + d.name = "Log Frequency Centroid"; + d.description = "Centroid of the log weighted frequency spectrum"; d.unit = "Hz"; - d.description = "Log Frequency Centroid"; d.hasFixedBinCount = true; d.binCount = 1; d.hasKnownExtents = false; @@ -118,8 +125,9 @@ d.sampleType = OutputDescriptor::OneSamplePerStep; list.push_back(d); - d.name = "linearcentroid"; - d.description = "Linear Frequency Centroid"; + d.identifier = "linearcentroid"; + d.name = "Linear Frequency Centroid"; + d.description = "Centroid of the linear frequency spectrum"; list.push_back(d); return list;
--- a/examples/SpectralCentroid.h Thu Jan 25 13:39:31 2007 +0000 +++ b/examples/SpectralCentroid.h Mon Feb 26 18:08:48 2007 +0000 @@ -50,6 +50,7 @@ InputDomain getInputDomain() const { return FrequencyDomain; } + std::string getIdentifier() const; std::string getName() const; std::string getDescription() const; std::string getMaker() const;
--- a/examples/ZeroCrossing.cpp Thu Jan 25 13:39:31 2007 +0000 +++ b/examples/ZeroCrossing.cpp Mon Feb 26 18:08:48 2007 +0000 @@ -54,15 +54,21 @@ } string -ZeroCrossing::getName() const +ZeroCrossing::getIdentifier() const { return "zerocrossing"; } string +ZeroCrossing::getName() const +{ + return "Zero Crossings"; +} + +string ZeroCrossing::getDescription() const { - return "Zero Crossings"; + return "Detect and count zero crossing points"; } string @@ -106,9 +112,10 @@ OutputList list; OutputDescriptor zc; - zc.name = "counts"; + zc.identifier = "counts"; + zc.name = "Zero Crossing Counts"; + zc.description = "The number of zero crossing points per processing block"; zc.unit = "crossings"; - zc.description = "Zero Crossing Counts"; zc.hasFixedBinCount = true; zc.binCount = 1; zc.hasKnownExtents = false; @@ -117,9 +124,10 @@ zc.sampleType = OutputDescriptor::OneSamplePerStep; list.push_back(zc); - zc.name = "zerocrossings"; + zc.identifier = "zerocrossings"; + zc.name = "Zero Crossings"; + zc.description = "The locations of zero crossing points"; zc.unit = ""; - zc.description = "Zero Crossings"; zc.hasFixedBinCount = true; zc.binCount = 0; zc.sampleType = OutputDescriptor::VariableSampleRate;
--- a/examples/ZeroCrossing.h Thu Jan 25 13:39:31 2007 +0000 +++ b/examples/ZeroCrossing.h Mon Feb 26 18:08:48 2007 +0000 @@ -50,6 +50,7 @@ InputDomain getInputDomain() const { return TimeDomain; } + std::string getIdentifier() const; std::string getName() const; std::string getDescription() const; std::string getMaker() const;
--- a/host/vamp-simple-host.cpp Thu Jan 25 13:39:31 2007 +0000 +++ b/host/vamp-simple-host.cpp Mon Feb 26 18:08:48 2007 +0000 @@ -126,13 +126,13 @@ cerr << endl << argv[0] << ": Running..." << endl; string soname = argv[1]; - string plugname = ""; + string plugid = ""; string wavname; if (argc >= 3) wavname = argv[2]; int sep = soname.find(":"); if (sep >= 0 && sep < int(soname.length())) { - plugname = soname.substr(sep + 1); + plugid = soname.substr(sep + 1); soname = soname.substr(0, sep); } @@ -166,9 +166,9 @@ Vamp::PluginHostAdapter plugin(descriptor, 48000); cerr << argv[0] << ": Plugin " << (index+1) - << " is \"" << plugin.getName() << "\"" << endl; + << " is \"" << plugin.getIdentifier() << "\"" << endl; - if (plugin.getName() == plugname) plugnumber = index; + if (plugin.getIdentifier() == plugid) plugnumber = index; ++index; } @@ -181,8 +181,8 @@ } if (plugnumber < 0) { - if (plugname != "") { - cerr << "ERROR: No such plugin as " << plugname << " in library" + if (plugid != "") { + cerr << "ERROR: No such plugin as " << plugid << " in library" << endl; DLCLOSE(libraryHandle); return 0; @@ -212,7 +212,7 @@ Vamp::PluginHostAdapter *plugin = new Vamp::PluginHostAdapter(descriptor, sfinfo.samplerate); - cerr << "Running " << plugin->getName() << "..." << endl; + cerr << "Running " << plugin->getIdentifier() << "..." << endl; int blockSize = plugin->getPreferredBlockSize(); int stepSize = plugin->getPreferredStepSize(); @@ -290,7 +290,7 @@ } od = outputs[output]; - cerr << "Output is " << od.name << endl; + cerr << "Output is " << od.identifier << endl; if (!plugin->initialise(channels, stepSize, blockSize)) { cerr << "ERROR: Plugin initialise (channels = " << channels @@ -405,18 +405,25 @@ char c = char('A' + index); if (c > 'Z') c = char('a' + (index - 26)); cerr << " [" << c << "] " - << plugin.getDescription() - << ", \"" << plugin.getName() << "\"" + << plugin.getName() + << ", \"" << plugin.getIdentifier() << "\"" << " [" << plugin.getMaker() - << "]" << std::endl; + << "]" << endl; + if (plugin.getDescription() != "") { + cerr << " - " << plugin.getDescription() << endl; + } Vamp::Plugin::OutputList outputs = plugin.getOutputDescriptors(); if (outputs.size() > 1) { for (size_t j = 0; j < outputs.size(); ++j) { cerr << " (" << j << ") " - << outputs[j].description - << ", \"" << outputs[j].name << "\"" + << outputs[j].name + << ", \"" << outputs[j].identifier << "\"" << endl; + if (outputs[j].description != "") { + cerr << " - " + << outputs[j].description << endl; + } } } ++index;
--- a/vamp-sdk/Plugin.h Thu Jan 25 13:39:31 2007 +0000 +++ b/vamp-sdk/Plugin.h Mon Feb 26 18:08:48 2007 +0000 @@ -196,12 +196,22 @@ { /** * The name of the output, in computer-usable form. Should be - * reasonably short and without whitespace or punctuation. + * reasonably short and without whitespace or punctuation, using + * the characters [a-zA-Z0-9_] only. + * Example: "zero_crossing_count" + */ + std::string identifier; + + /** + * The human-readable name of the output. + * Example: "Zero Crossing Counts" */ std::string name; /** - * The human-readable name of the output. + * A human-readable short text describing the output. May be + * empty if the name has said it all already. + * Example: "The number of zero crossing points per processing block" */ std::string description; @@ -226,8 +236,8 @@ size_t binCount; /** - * The names of each of the bins, if appropriate. This is - * always optional. + * The (human-readable) names of each of the bins, if + * appropriate. This is always optional. */ std::vector<std::string> binNames;
--- a/vamp-sdk/PluginAdapter.cpp Thu Jan 25 13:39:31 2007 +0000 +++ b/vamp-sdk/PluginAdapter.cpp Mon Feb 26 18:08:48 2007 +0000 @@ -63,6 +63,7 @@ m_parameters = plugin->getParameterDescriptors(); m_programs = plugin->getPrograms(); + m_descriptor.identifier = strdup(plugin->getIdentifier().c_str()); m_descriptor.name = strdup(plugin->getName().c_str()); m_descriptor.description = strdup(plugin->getDescription().c_str()); m_descriptor.maker = strdup(plugin->getMaker().c_str()); @@ -78,6 +79,7 @@ for (i = 0; i < m_parameters.size(); ++i) { VampParameterDescriptor *desc = (VampParameterDescriptor *) malloc(sizeof(VampParameterDescriptor)); + desc->identifier = strdup(m_parameters[i].identifier.c_str()); desc->name = strdup(m_parameters[i].name.c_str()); desc->description = strdup(m_parameters[i].description.c_str()); desc->unit = strdup(m_parameters[i].unit.c_str()); @@ -150,6 +152,7 @@ if (!m_populated) return; + free((void *)m_descriptor.identifier); free((void *)m_descriptor.name); free((void *)m_descriptor.description); free((void *)m_descriptor.maker); @@ -157,6 +160,7 @@ for (unsigned int i = 0; i < m_descriptor.parameterCount; ++i) { const VampParameterDescriptor *desc = m_descriptor.parameters[i]; + free((void *)desc->identifier); free((void *)desc->name); free((void *)desc->description); free((void *)desc->unit); @@ -281,7 +285,7 @@ PluginAdapterBase *adapter = lookupAdapter(handle); if (!adapter) return 0.0; Plugin::ParameterList &list = adapter->m_parameters; - return ((Plugin *)handle)->getParameter(list[param].name); + return ((Plugin *)handle)->getParameter(list[param].identifier); } void @@ -295,7 +299,7 @@ PluginAdapterBase *adapter = lookupAdapter(handle); if (!adapter) return; Plugin::ParameterList &list = adapter->m_parameters; - ((Plugin *)handle)->setParameter(list[param].name, value); + ((Plugin *)handle)->setParameter(list[param].identifier, value); } unsigned int @@ -407,6 +411,7 @@ std::cerr << "PluginAdapterBase::vampReleaseOutputDescriptor(" << desc << ")" << std::endl; #endif + if (desc->identifier) free((void *)desc->identifier); if (desc->name) free((void *)desc->name); if (desc->description) free((void *)desc->description); if (desc->unit) free((void *)desc->unit); @@ -506,7 +511,7 @@ !m_pluginOutputs[plugin]) { m_pluginOutputs[plugin] = new Plugin::OutputList (plugin->getOutputDescriptors()); -// std::cerr << "PluginAdapterBase::checkOutputMap: Have " << m_pluginOutputs[plugin]->size() << " outputs for plugin label " << plugin->getName() << std::endl; +// std::cerr << "PluginAdapterBase::checkOutputMap: Have " << m_pluginOutputs[plugin]->size() << " outputs for plugin " << plugin->getIdentifier() << std::endl; } } @@ -528,6 +533,7 @@ VampOutputDescriptor *desc = (VampOutputDescriptor *) malloc(sizeof(VampOutputDescriptor)); + desc->identifier = strdup(od.identifier.c_str()); desc->name = strdup(od.name.c_str()); desc->description = strdup(od.description.c_str()); desc->unit = strdup(od.unit.c_str());
--- a/vamp-sdk/PluginBase.h Thu Jan 25 13:39:31 2007 +0000 +++ b/vamp-sdk/PluginBase.h Mon Feb 26 18:08:48 2007 +0000 @@ -69,15 +69,29 @@ * * This text may be visible to the user, but it should not be the * main text used to identify a plugin to the user (that will be - * the description, below). + * the name, below). + * + * Example: "zero_crossings" + */ + virtual std::string getIdentifier() const = 0; + + /** + * Get a human-readable name or title of the plugin. This + * should be brief and self-contained, as it may be used to + * identify the plugin to the user in isolation (i.e. without also + * showing the plugin's "identifier"). + * + * Example: "Zero Crossings" */ virtual std::string getName() const = 0; /** - * Get a human-readable description or title of the plugin. This - * should be brief and self-contained, as it may be used to - * identify the plugin to the user in isolation (i.e. without also - * showing the plugin's "name"). + * Get a human-readable description for the plugin, typically + * a line of text that may optionally be displayed in addition + * to the plugin's "name". May be empty if the name has said + * it all already. + * + * Example: "Detect and count zero crossing points" */ virtual std::string getDescription() const = 0; @@ -109,10 +123,16 @@ * be reasonably short, and may only contain the characters * [a-zA-Z0-9_]. */ + std::string identifier; + + /** + * The human-readable name of the parameter. + */ std::string name; /** - * The human-readable name of the parameter. + * A human-readable short text describing the parameter. May be + * empty if the name has said it all already. */ std::string description; @@ -176,13 +196,13 @@ } /** - * Get the value of a named parameter. The argument is the name + * Get the value of a named parameter. The argument is the identifier * field from that parameter's descriptor. */ virtual float getParameter(std::string) const { return 0.0; } /** - * Set a named parameter. The first argument is the name field + * Set a named parameter. The first argument is the identifier field * from that parameter's descriptor. */ virtual void setParameter(std::string, float) { }
--- a/vamp-sdk/PluginHostAdapter.cpp Thu Jan 25 13:39:31 2007 +0000 +++ b/vamp-sdk/PluginHostAdapter.cpp Mon Feb 26 18:08:48 2007 +0000 @@ -141,6 +141,12 @@ } std::string +PluginHostAdapter::getIdentifier() const +{ + return m_descriptor->identifier; +} + +std::string PluginHostAdapter::getName() const { return m_descriptor->name; @@ -177,6 +183,7 @@ for (unsigned int i = 0; i < m_descriptor->parameterCount; ++i) { const VampParameterDescriptor *spd = m_descriptor->parameters[i]; ParameterDescriptor pd; + pd.identifier = spd->identifier; pd.name = spd->name; pd.description = spd->description; pd.unit = spd->unit; @@ -201,7 +208,7 @@ if (!m_handle) return 0.0; for (unsigned int i = 0; i < m_descriptor->parameterCount; ++i) { - if (param == m_descriptor->parameters[i]->name) { + if (param == m_descriptor->parameters[i]->identifier) { return m_descriptor->getParameter(m_handle, i); } } @@ -216,7 +223,7 @@ if (!m_handle) return; for (unsigned int i = 0; i < m_descriptor->parameterCount; ++i) { - if (param == m_descriptor->parameters[i]->name) { + if (param == m_descriptor->parameters[i]->identifier) { m_descriptor->setParameter(m_handle, i, value); return; } @@ -299,6 +306,7 @@ for (unsigned int i = 0; i < count; ++i) { VampOutputDescriptor *sd = m_descriptor->getOutputDescriptor(m_handle, i); OutputDescriptor d; + d.identifier = sd->identifier; d.name = sd->name; d.description = sd->description; d.unit = sd->unit;
--- a/vamp-sdk/PluginHostAdapter.h Thu Jan 25 13:39:31 2007 +0000 +++ b/vamp-sdk/PluginHostAdapter.h Mon Feb 26 18:08:48 2007 +0000 @@ -59,6 +59,7 @@ InputDomain getInputDomain() const; + std::string getIdentifier() const; std::string getName() const; std::string getDescription() const; std::string getMaker() const;
--- a/vamp/vamp.h Thu Jan 25 13:39:31 2007 +0000 +++ b/vamp/vamp.h Mon Feb 26 18:08:48 2007 +0000 @@ -68,9 +68,12 @@ typedef struct _VampParameterDescriptor { /** Computer-usable name of the parameter. Must not change. [a-zA-Z0-9_] */ + const char *identifier; + + /** Human-readable name of the parameter. May be translatable. */ const char *name; - /** Human-readable name of the parameter. May be translatable. */ + /** Human-readable short text about the parameter. May be translatable. */ const char *description; /** Human-readable unit of the parameter. */ @@ -112,9 +115,12 @@ typedef struct _VampOutputDescriptor { /** Computer-usable name of the output. Must not change. [a-zA-Z0-9_] */ + const char *identifier; + + /** Human-readable name of the output. May be translatable. */ const char *name; - /** Human-readable name of the output. May be translatable. */ + /** Human-readable short text about the output. May be translatable. */ const char *description; /** Human-readable name of the unit of the output. */ @@ -197,9 +203,12 @@ typedef struct _VampPluginDescriptor { /** Computer-usable name of the plugin. Must not change. [a-zA-Z0-9_] */ + const char *identifier; + + /** Human-readable name of the plugin. May be translatable. */ const char *name; - /** Human-readable name of the plugin. May be translatable. */ + /** Human-readable short text about the plugin. May be translatable. */ const char *description; /** Human-readable name of plugin's author or vendor. */