# HG changeset patch # User Chris Cannam # Date 1394202890 0 # Node ID f559ab000b67147c0f157273ae80b2b4baebbe7e Initial skeleton diff -r 000000000000 -r f559ab000b67 ConstrainedHarmonicPeak.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ConstrainedHarmonicPeak.cpp Fri Mar 07 14:34:50 2014 +0000 @@ -0,0 +1,211 @@ + +#include "ConstrainedHarmonicPeak.h" + +#include +#include + +using std::cerr; +using std::endl; +using std::vector; + +ConstrainedHarmonicPeak::ConstrainedHarmonicPeak(float inputSampleRate) : + Plugin(inputSampleRate), + m_blockSize(0), + m_minFreq(0), + m_maxFreq(inputSampleRate/2) +{ +} + +ConstrainedHarmonicPeak::~ConstrainedHarmonicPeak() +{ +} + +string +ConstrainedHarmonicPeak::getIdentifier() const +{ + return "constrainedharmonicpeak"; +} + +string +ConstrainedHarmonicPeak::getName() const +{ + return "Frequency-Constrained Harmonic Peak"; +} + +string +ConstrainedHarmonicPeak::getDescription() const +{ + //!!! Return something helpful here! + return ""; +} + +string +ConstrainedHarmonicPeak::getMaker() const +{ + return "Queen Mary, University of London"; +} + +int +ConstrainedHarmonicPeak::getPluginVersion() const +{ + return 1; +} + +string +ConstrainedHarmonicPeak::getCopyright() const +{ + return "GPL"; +} + +ConstrainedHarmonicPeak::InputDomain +ConstrainedHarmonicPeak::getInputDomain() const +{ + return FrequencyDomain; +} + +size_t +ConstrainedHarmonicPeak::getPreferredBlockSize() const +{ + return 2048; +} + +size_t +ConstrainedHarmonicPeak::getPreferredStepSize() const +{ + return 512; +} + +size_t +ConstrainedHarmonicPeak::getMinChannelCount() const +{ + return 1; +} + +size_t +ConstrainedHarmonicPeak::getMaxChannelCount() const +{ + return 1; +} + +ConstrainedHarmonicPeak::ParameterList +ConstrainedHarmonicPeak::getParameterDescriptors() const +{ + ParameterList list; + + ParameterDescriptor d; + d.identifier = "minfreq"; + d.name = "Minimum frequency"; + d.description = ""; + d.unit = "Hz"; + d.minValue = 0; + d.maxValue = m_inputSampleRate/2; + d.defaultValue = 0; + d.isQuantized = false; + list.push_back(d); + + d.identifier = "maxfreq"; + d.name = "Maximum frequency"; + d.description = ""; + d.unit = "Hz"; + d.minValue = 0; + d.maxValue = m_inputSampleRate/2; + d.defaultValue = 0; + d.isQuantized = false; + list.push_back(d); + + return list; +} + +float +ConstrainedHarmonicPeak::getParameter(string identifier) const +{ + if (identifier == "minfreq") { + return m_minFreq; + } else if (identifier == "maxfreq") { + return m_maxFreq; + } + return 0; +} + +void +ConstrainedHarmonicPeak::setParameter(string identifier, float value) +{ + if (identifier == "minfreq") { + m_minFreq = value; + } else if (identifier == "maxfreq") { + m_maxFreq = value; + } +} + +ConstrainedHarmonicPeak::ProgramList +ConstrainedHarmonicPeak::getPrograms() const +{ + ProgramList list; + return list; +} + +string +ConstrainedHarmonicPeak::getCurrentProgram() const +{ + return ""; // no programs +} + +void +ConstrainedHarmonicPeak::selectProgram(string name) +{ +} + +ConstrainedHarmonicPeak::OutputList +ConstrainedHarmonicPeak::getOutputDescriptors() const +{ + OutputList list; + + OutputDescriptor d; + d.identifier = "peak"; + d.name = "Peak frequency"; + d.description = ""; + d.unit = "Hz"; + d.sampleType = OutputDescriptor::OneSamplePerStep; + d.hasDuration = false; + list.push_back(d); + + return list; +} + +bool +ConstrainedHarmonicPeak::initialise(size_t channels, size_t stepSize, size_t blockSize) +{ + if (channels < getMinChannelCount() || + channels > getMaxChannelCount()) { + cerr << "ConstrainedHarmonicPeak::initialise: ERROR: channels " << channels + << " out of acceptable range " << getMinChannelCount() + << " -> " << getMaxChannelCount() << endl; + return false; + } + + m_blockSize = blockSize; + + return true; +} + +void +ConstrainedHarmonicPeak::reset() +{ +} + +ConstrainedHarmonicPeak::FeatureSet +ConstrainedHarmonicPeak::process(const float *const *inputBuffers, Vamp::RealTime timestamp) +{ + FeatureSet fs; + + return fs; +} + +ConstrainedHarmonicPeak::FeatureSet +ConstrainedHarmonicPeak::getRemainingFeatures() +{ + FeatureSet fs; + + return fs; +} + diff -r 000000000000 -r f559ab000b67 ConstrainedHarmonicPeak.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ConstrainedHarmonicPeak.h Fri Mar 07 14:34:50 2014 +0000 @@ -0,0 +1,53 @@ +#ifndef CONSTRAINEDHARMONICPEAK_H +#define CONSTRAINEDHARMONICPEAK_H + +#include + +using std::string; + +class ConstrainedHarmonicPeak : public Vamp::Plugin +{ +public: + ConstrainedHarmonicPeak(float inputSampleRate); + virtual ~ConstrainedHarmonicPeak(); + + 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: + int m_blockSize; + float m_minFreq; + float m_maxFreq; +}; + + + +#endif diff -r 000000000000 -r f559ab000b67 Makefile.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile.inc Fri Mar 07 14:34:50 2014 +0000 @@ -0,0 +1,43 @@ + +PLUGIN_EXT ?= .so + +CXX ?= g++ +CC ?= gcc + +CFLAGS := $(CFLAGS) +CXXFLAGS := -I. $(CXXFLAGS) + +PLUGIN := chp(PLUGIN_EXT) + +SOURCES := ConstrainedHarmonicPeak.cpp + +PLUGIN_MAIN := plugins.cpp + +TESTS := + +OBJECTS := $(SOURCES:.cpp=.o) +OBJECTS := $(OBJECTS:.c=.o) + +PLUGIN_OBJECTS := $(OBJECTS) $(PLUGIN_MAIN:.cpp=.o) + +all: $(PLUGIN) $(TESTS) + for t in $(TESTS); do echo "Running $$t"; ./"$$t" || exit 1; done + +plugin: $(PLUGIN) + +$(PLUGIN): $(PLUGIN_OBJECTS) + $(CXX) -o $@ $^ $(PLUGIN_LDFLAGS) + +clean: + rm -f $(PLUGIN_OBJECTS) test/*.o + +distclean: clean + rm -f $(PLUGIN) $(TESTS) + +depend: + makedepend -Y -fMakefile.inc *.cpp test/*.cpp *.h test/*.h + +# DO NOT DELETE + +ConstrainedHarmonicPeak.o: ConstrainedHarmonicPeak.h +plugins.o: ConstrainedHarmonicPeak.h diff -r 000000000000 -r f559ab000b67 Makefile.linux --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile.linux Fri Mar 07 14:34:50 2014 +0000 @@ -0,0 +1,13 @@ + +CFLAGS := -Wall -O3 -fPIC -I../vamp-plugin-sdk/ -I../qm-dsp +#CFLAGS := -g -fPIC -I../vamp-plugin-sdk + +CXXFLAGS := $(CFLAGS) + +PLUGIN_LDFLAGS := -shared -Wl,-Bstatic -L../qm-dsp -lqm-dsp -L../vamp-plugin-sdk -lvamp-sdk -Wl,-Bdynamic -Wl,--version-script=vamp-plugin.map +TEST_LDFLAGS := -Wl,-Bstatic -L../vamp-plugin-sdk -lvamp-sdk -Wl,-Bdynamic -lboost_unit_test_framework + +PLUGIN_EXT := .so + +include Makefile.inc + diff -r 000000000000 -r f559ab000b67 plugins.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins.cpp Fri Mar 07 14:34:50 2014 +0000 @@ -0,0 +1,20 @@ + +#include +#include + +#include "ConstrainedHarmonicPeak.h" + +static Vamp::PluginAdapter chpAdapter; + +const VampPluginDescriptor * +vampGetPluginDescriptor(unsigned int version, unsigned int index) +{ + if (version < 1) return 0; + + switch (index) { + case 0: return chpAdapter.getDescriptor(); + default: return 0; + } +} + + diff -r 000000000000 -r f559ab000b67 vamp-plugin.list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vamp-plugin.list Fri Mar 07 14:34:50 2014 +0000 @@ -0,0 +1,1 @@ +_vampGetPluginDescriptor diff -r 000000000000 -r f559ab000b67 vamp-plugin.map --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vamp-plugin.map Fri Mar 07 14:34:50 2014 +0000 @@ -0,0 +1,4 @@ +{ + global: vampGetPluginDescriptor; + local: *; +};