changeset 0:f559ab000b67

Initial skeleton
author Chris Cannam
date Fri, 07 Mar 2014 14:34:50 +0000
parents
children ab0b04e1c56b
files ConstrainedHarmonicPeak.cpp ConstrainedHarmonicPeak.h Makefile.inc Makefile.linux plugins.cpp vamp-plugin.list vamp-plugin.map
diffstat 7 files changed, 345 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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 <cmath>
+#include <cstdio>
+
+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;
+}
+
--- /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 <vamp-sdk/Plugin.h>
+
+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
--- /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
--- /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
+
--- /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 <vamp/vamp.h>
+#include <vamp-sdk/PluginAdapter.h>
+
+#include "ConstrainedHarmonicPeak.h"
+
+static Vamp::PluginAdapter<ConstrainedHarmonicPeak> 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;
+    }
+}
+
+
--- /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
--- /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: *;
+};