Mercurial > hg > vamp-test-plugin
changeset 0:21d94fc628c8
Start on plugin that provides test outputs for each supported format
author | Chris Cannam |
---|---|
date | Thu, 21 Mar 2013 19:22:16 +0000 |
parents | |
children | 572e2a3f3f11 |
files | Makefile VampTestPlugin.cpp VampTestPlugin.h plugins.cpp vamp-plugin.list vamp-plugin.map |
diffstat | 6 files changed, 363 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Thu Mar 21 19:22:16 2013 +0000 @@ -0,0 +1,101 @@ + +## Skeleton Makefile for Vamp plugin builds using command-line tools. +## This requires GNU make, which is what you get with OS/X, Linux, or +## MinGW/Cygwin on Windows. +## +## Rename this to Makefile, and edit as appropriate. +## This Makefile WILL NOT WORK until you have edited it as described +## below -- the Makefile as supplied does nothing useful at all! +## +## Various sets of options are provided, commented out -- just uncomment +## (remove the '#' characters for) the set that most closely resembles +## your own situation, and adjust to taste. Then run "gmake". +## +## (For Windows builds using MS Visual Studio, start instead with the +## VampExamplePlugins project found in the build directory of the SDK.) + + +# Edit this to the base name of your plugin library +# +PLUGIN_LIBRARY_NAME := vamp-test-plugin + +# Edit this to list the .cpp or .c files in your plugin project +# +PLUGIN_SOURCES := VampTestPlugin.cpp plugins.cpp + +# Edit this to list the .h files in your plugin project +# +PLUGIN_HEADERS := VampTestPlugin.h + +# Edit this to the location of the Vamp plugin SDK, relative to your +# project directory +# +VAMP_SDK_DIR := ../vamp-plugin-sdk + + +## Uncomment these for an OS/X universal binary (32- and 64-bit Intel) +## supporting 10.5 or newer. Use this if you have OS/X 10.7 with the +## Xcode 4 command-line tools. + +# CXX := g++ +# CXXFLAGS := -mmacosx-version-min=10.5 -arch i386 -arch x86_64 -I$(VAMP_SDK_DIR) -Wall -fPIC +# PLUGIN_EXT := .dylib +# LDFLAGS := $(CXXFLAGS) -dynamiclib -install_name $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT) $(VAMP_SDK_DIR)/libvamp-sdk.a -exported_symbols_list vamp-plugin.list + + +## Uncomment these for an OS/X universal binary (PPC and 32- and +## 64-bit Intel) supporting 10.5 or newer. Use this if you have OS/X +## 10.6 with the Xcode 3 command-line tools. + +# CXXFLAGS := -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch i386 -arch x86_64 -arch ppc -I$(VAMP_SDK_DIR) -Wall -fPIC +# PLUGIN_EXT := .dylib +# LDFLAGS := $(CXXFLAGS) -dynamiclib -install_name $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT) $(VAMP_SDK_DIR)/libvamp-sdk.a -exported_symbols_list vamp-plugin.list + + +## Uncomment these for an OS/X universal binary (PPC and 32- and +## 64-bit Intel) supporting 10.4 or newer. Use this if you have OS/X +## 10.4, 10.5 or 10.6 and you have the 10.4 SDK installed. + +# CXX := g++-4.0 +# CXXFLAGS := -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -arch i386 -arch x86_64 -arch ppc -I$(VAMP_SDK_DIR) -Wall -fPIC +# PLUGIN_EXT := .dylib +# LDFLAGS := $(CXXFLAGS) -dynamiclib -install_name $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT) $(VAMP_SDK_DIR)/libvamp-sdk.a -exported_symbols_list vamp-plugin.list + + +## Uncomment these for Linux using the standard tools: + +CXXFLAGS := -I$(VAMP_SDK_DIR) -Wall -fPIC +PLUGIN_EXT := .so +LDFLAGS := -shared -Wl,-soname=$(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT) $(VAMP_SDK_DIR)/libvamp-sdk.a -Wl,--version-script=vamp-plugin.map + + +## Uncomment these for a cross-compile from Linux to Windows using MinGW: + +# CXX := i586-mingw32msvc-g++ +# CXXFLAGS := -I$(VAMP_SDK_DIR) -Wall +# PLUGIN_EXT := .dll +# LDFLAGS := --static-libgcc -Wl,-soname=$(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT) -shared $(VAMP_SDK_DIR)/libvamp-sdk.a + + +## Uncomment these for OpenSolaris using SunStudio compiler and GNU make: + +# CXX := CC +# CXXFLAGS := -G -I$(VAMP_SDK_DIR) +w -KPIC +# PLUGIN_EXT := .so +# LDFLAGS := -G -h$(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT) $(VAMP_SDK_DIR)/libvamp-sdk.a -Qoption ld -Mvamp-plugin.map + + + +## All of the above + +PLUGIN_OBJECTS := $(PLUGIN_SOURCES:.cpp=.o) +PLUGIN_OBJECTS := $(PLUGIN_OBJECTS:.c=.o) + +$(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT): $(PLUGIN_OBJECTS) + $(CXX) -o $@ $^ $(LDFLAGS) + +$(PLUGIN_OBJECTS): $(PLUGIN_HEADERS) + +clean: + rm -f *.o +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VampTestPlugin.cpp Thu Mar 21 19:22:16 2013 +0000 @@ -0,0 +1,170 @@ + + +#include "VampTestPlugin.h" + + +VampTestPlugin::VampTestPlugin(float inputSampleRate) : + Plugin(inputSampleRate) + // Also be sure to set your plugin parameters (presumably stored + // in member variables) to their default values here -- the host + // will not do that for you +{ +} + +VampTestPlugin::~VampTestPlugin() +{ +} + +string +VampTestPlugin::getIdentifier() const +{ + return "vamp-test-plugin"; +} + +string +VampTestPlugin::getName() const +{ + return "Vamp Test Plugin"; +} + +string +VampTestPlugin::getDescription() const +{ + return "Test plugin for hosts handling various output types"; +} + +string +VampTestPlugin::getMaker() const +{ + return "Chris Cannam"; +} + +int +VampTestPlugin::getPluginVersion() const +{ + return 1; +} + +string +VampTestPlugin::getCopyright() const +{ + return "BSD"; +} + +VampTestPlugin::InputDomain +VampTestPlugin::getInputDomain() const +{ + return TimeDomain; +} + +size_t +VampTestPlugin::getPreferredBlockSize() const +{ + return 0; +} + +size_t +VampTestPlugin::getPreferredStepSize() const +{ + return 0; +} + +size_t +VampTestPlugin::getMinChannelCount() const +{ + return 1; +} + +size_t +VampTestPlugin::getMaxChannelCount() const +{ + return 1; +} + +VampTestPlugin::ParameterList +VampTestPlugin::getParameterDescriptors() const +{ + ParameterList list; + return list; +} + +float +VampTestPlugin::getParameter(string identifier) const +{ + return 0; +} + +void +VampTestPlugin::setParameter(string identifier, float value) +{ +} + +VampTestPlugin::ProgramList +VampTestPlugin::getPrograms() const +{ + ProgramList list; + return list; +} + +string +VampTestPlugin::getCurrentProgram() const +{ + return ""; // no programs +} + +void +VampTestPlugin::selectProgram(string name) +{ +} + +VampTestPlugin::OutputList +VampTestPlugin::getOutputDescriptors() const +{ + OutputList list; + + 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 +VampTestPlugin::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 +VampTestPlugin::reset() +{ + // Clear buffers, reset stored values, etc +} + +VampTestPlugin::FeatureSet +VampTestPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp) +{ + // Do actual work! + return FeatureSet(); +} + +VampTestPlugin::FeatureSet +VampTestPlugin::getRemainingFeatures() +{ + return FeatureSet(); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VampTestPlugin.h Thu Mar 21 19:22:16 2013 +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 _VAMP_TEST_PLUGIN_H_ +#define _VAMP_TEST_PLUGIN_H_ + +#include <vamp-sdk/Plugin.h> + +using std::string; + + +class VampTestPlugin : public Vamp::Plugin +{ +public: + VampTestPlugin(float inputSampleRate); + virtual ~VampTestPlugin(); + + 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins.cpp Thu Mar 21 19:22:16 2013 +0000 @@ -0,0 +1,28 @@ + + +#include <vamp/vamp.h> +#include <vamp-sdk/PluginAdapter.h> + +#include "VampTestPlugin.h" + + +static Vamp::PluginAdapter<VampTestPlugin> myPluginAdapter; + + +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; + } +} + +