# HG changeset patch # User cannam # Date 1240477164 0 # Node ID 6c9f10b8a53ab6c16ae2dc19a7a317c306bddf08 # Parent e0b7a35ea18ef20b99374f7cad32c009b0fd1183 * Add skeleton diff -r e0b7a35ea18e -r 6c9f10b8a53a skeleton/MyPlugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/MyPlugin.cpp Thu Apr 23 08:59:24 2009 +0000 @@ -0,0 +1,210 @@ + +// This is a skeleton file for use in creating your own plugin +// libraries. Replace MyPlugin and myPlugin throughout with the name +// of your first plugin class, and fill in the gaps as appropriate. + + +#include "MyPlugin.h" + + +MyPlugin::MyPlugin(float inputSampleRate) : + Plugin(inputSampleRate) +{ +} + +MyPlugin::~MyPlugin() +{ +} + +string +MyPlugin::getIdentifier() const +{ + return "myplugin"; +} + +string +MyPlugin::getName() const +{ + return "My Plugin"; +} + +string +MyPlugin::getDescription() const +{ + // Return something helpful here! + return ""; +} + +string +MyPlugin::getMaker() const +{ + // Your name here + return ""; +} + +int +MyPlugin::getPluginVersion() const +{ + // Increment this each time you release a version that behaves + // differently from the previous one + return 1; +} + +string +MyPlugin::getCopyright() const +{ + // This function is not ideally named. It does not necessarily + // need to say who made the plugin -- getMaker does that -- but it + // should indicate the terms under which it is distributed. For + // example, "Copyright (year). All Rights Reserved", or "GPL" + return ""; +} + +MyPlugin::InputDomain +MyPlugin::getInputDomain() const +{ + return TimeDomain; +} + +size_t +MyPlugin::getPreferredBlockSize() const +{ + return 0; // 0 means "I can handle any block size" +} + +size_t +MyPlugin::getPreferredStepSize() const +{ + return 0; // 0 means "anything sensible"; in practice this + // means the same as the block size for TimeDomain + // plugins, or half of it for FrequencyDomain plugins +} + +size_t +MyPlugin::getMinChannelCount() const +{ + return 1; +} + +size_t +MyPlugin::getMaxChannelCount() const +{ + return 1; +} + +MyPlugin::ParameterList +MyPlugin::getParameterDescriptors() const +{ + ParameterList list; + + // If the plugin has no adjustable parameters, return an empty + // list here (and there's no need to provide implementations of + // getParameter and setParameter in that case either). + + ParameterDescriptor d; + d.identifier = "parameter"; + d.name = "Some Parameter"; + d.description = ""; + d.unit = ""; + d.minValue = 0; + d.maxValue = 10; + d.defaultValue = 5; + d.isQuantized = false; + list.push_back(d); + + return list; +} + +float +MyPlugin::getParameter(string identifier) const +{ + if (identifier == "parameter") { + return 5; // return the ACTUAL current value of your parameter here! + } + return 0; +} + +void +MyPlugin::setParameter(string identifier, float value) +{ + if (identifier == "parameter") { + // set the actual value of your parameter + } +} + +MyPlugin::ProgramList +MyPlugin::getPrograms() const +{ + ProgramList list; + + // If you have no programs, return an empty list (or simply don't + // implement this function or getCurrentProgram/selectProgram) + + return list; +} + +string +MyPlugin::getCurrentProgram() const +{ + return ""; // no programs +} + +void +MyPlugin::selectProgram(string name) +{ +} + +MyPlugin::OutputList +MyPlugin::getOutputDescriptors() const +{ + OutputList list; + + // See OutputDescriptor documentation for the possibilities here. + // Every plugin must have at least one output. + + OutputDescriptor d; + d.identifier = "output"; + d.name = "My Output"; + d.description = ""; + d.unit = ""; + d.hasFixedBinCount = true; + d.binCount = 1; + d.hasKnownExtents = false; + d.isQuantized = false; + d.sampleType = OutputDescriptor::OneSamplePerStep; + d.hasDuration = false; + list.push_back(d); + + return list; +} + +bool +MyPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize) +{ + if (channels < getMinChannelCount() || + channels > getMaxChannelCount()) return false; + + // Real initialisation work goes here! + + return true; +} + +void +MyPlugin::reset() +{ + // Clear buffers, reset stored values, etc +} + +MyPlugin::FeatureSet +MyPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp) +{ + // Do actual work! + return FeatureSet(); +} + +MyPlugin::FeatureSet +MyPlugin::getRemainingFeatures() +{ + return FeatureSet(); +} + diff -r e0b7a35ea18e -r 6c9f10b8a53a skeleton/MyPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/MyPlugin.h Thu Apr 23 08:59:24 2009 +0000 @@ -0,0 +1,59 @@ + +// This is a skeleton file for use in creating your own plugin +// libraries. Replace MyPlugin and myPlugin throughout with the name +// of your first plugin class, and fill in the gaps as appropriate. + + +// Remember to use a different guard symbol in each header! +#ifndef _MY_PLUGIN_H_ +#define _MY_PLUGIN_H_ + +#include + +using std::string; + + +class MyPlugin : public Vamp::Plugin +{ +public: + MyPlugin(float inputSampleRate); + virtual ~MyPlugin(); + + string getIdentifier() const; + string getName() const; + string getDescription() const; + string getMaker() const; + int getPluginVersion() const; + string getCopyright() const; + + InputDomain getInputDomain() const; + size_t getPreferredBlockSize() const; + size_t getPreferredStepSize() const; + size_t getMinChannelCount() const; + size_t getMaxChannelCount() const; + + ParameterList getParameterDescriptors() const; + float getParameter(string identifier) const; + void setParameter(string identifier, float value); + + ProgramList getPrograms() const; + string getCurrentProgram() const; + void selectProgram(string name); + + OutputList getOutputDescriptors() const; + + bool initialise(size_t channels, size_t stepSize, size_t blockSize); + void reset(); + + FeatureSet process(const float *const *inputBuffers, + Vamp::RealTime timestamp); + + FeatureSet getRemainingFeatures(); + +protected: + // plugin-specific data and methods go here +}; + + + +#endif diff -r e0b7a35ea18e -r 6c9f10b8a53a skeleton/plugins.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/plugins.cpp Thu Apr 23 08:59:24 2009 +0000 @@ -0,0 +1,37 @@ + +// This is a skeleton file for use in creating your own plugin +// libraries. Replace MyPlugin and myPlugin throughout with the name +// of your first plugin class, and fill in the gaps as appropriate. + + +#include +#include + +#include "MyPlugin.h" + + +// Declare one static adapter here for each plugin class in this library. + +static Vamp::PluginAdapter myPluginAdapter; + + +// This is the entry-point for the library, and the only function that +// needs to be publicly exported. + +const VampPluginDescriptor * +vampGetPluginDescriptor(unsigned int version, unsigned int index) +{ + if (version < 1) return 0; + + // Return a different plugin adaptor's descriptor for each index, + // and return 0 for the first index after you run out of plugins. + // (That's how the host finds out how many plugins are in this + // library.) + + switch (index) { + case 0: return myPluginAdapter.getDescriptor(); + default: return 0; + } +} + + diff -r e0b7a35ea18e -r 6c9f10b8a53a src/vamp-hostsdk/PluginInputDomainAdapter.cpp --- a/src/vamp-hostsdk/PluginInputDomainAdapter.cpp Fri Mar 20 15:49:59 2009 +0000 +++ b/src/vamp-hostsdk/PluginInputDomainAdapter.cpp Thu Apr 23 08:59:24 2009 +0000 @@ -222,12 +222,12 @@ } if (blockSize < 2) { - std::cerr << "ERROR: Vamp::HostExt::PluginInputDomainAdapter::Impl::initialise: blocksize < 2 not supported" << std::endl; + std::cerr << "ERROR: PluginInputDomainAdapter::initialise: blocksize < 2 not supported" << std::endl; return false; } if (blockSize & (blockSize-1)) { - std::cerr << "ERROR: Vamp::HostExt::PluginInputDomainAdapter::Impl::initialise: non-power-of-two\nblocksize " << blockSize << " not supported" << std::endl; + std::cerr << "ERROR: PluginInputDomainAdapter::initialise: non-power-of-two\nblocksize " << blockSize << " not supported" << std::endl; return false; } @@ -311,7 +311,7 @@ { if (blockSize < 2) { - std::cerr << "WARNING: Vamp::HostExt::PluginInputDomainAdapter::Impl::initialise: blocksize < 2 not" << std::endl + std::cerr << "WARNING: PluginInputDomainAdapter::initialise: blocksize < 2 not" << std::endl << "supported, increasing from " << blockSize << " to 2" << std::endl; blockSize = 2; @@ -340,7 +340,7 @@ nearest = nearest*2; } - std::cerr << "WARNING: Vamp::HostExt::PluginInputDomainAdapter::Impl::initialise: non-power-of-two\nblocksize " << blockSize << " not supported, using blocksize " << nearest << " instead" << std::endl; + std::cerr << "WARNING: PluginInputDomainAdapter::initialise: non-power-of-two\nblocksize " << blockSize << " not supported, using blocksize " << nearest << " instead" << std::endl; blockSize = nearest; #endif