changeset 0:b26975f6a1f1

Initial commit with skeleton code
author Chris Cannam
date Mon, 03 Mar 2014 16:35:27 +0000
parents
children 411c5c28fc43
files LowFreq.cpp LowFreq.h plugins.cpp vamp-plugin.list vamp-plugin.map
diffstat 5 files changed, 284 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LowFreq.cpp	Mon Mar 03 16:35:27 2014 +0000
@@ -0,0 +1,206 @@
+
+#include "LowFreq.h"
+
+static float defaultPShort = 0.1;
+static float defaultPLong = 1.0;
+
+LowFreq::LowFreq(float inputSampleRate) :
+    Plugin(inputSampleRate),
+    m_pShort(defaultPShort),
+    m_pLong(defaultPLong)
+{
+}
+
+LowFreq::~LowFreq()
+{
+}
+
+string
+LowFreq::getIdentifier() const
+{
+    return "lowfreq";
+}
+
+string
+LowFreq::getName() const
+{
+    return "Low-frequency Spectrogram";
+}
+
+string
+LowFreq::getDescription() const
+{
+    //!!! Return something helpful here!
+    return "";
+}
+
+string
+LowFreq::getMaker() const
+{
+    return "Queen Mary, University of London";
+}
+
+int
+LowFreq::getPluginVersion() const
+{
+    return 1;
+}
+
+string
+LowFreq::getCopyright() const
+{
+    return "GPL";
+}
+
+LowFreq::InputDomain
+LowFreq::getInputDomain() const
+{
+    return TimeDomain;
+}
+
+size_t
+LowFreq::getPreferredBlockSize() const
+{
+    //!!! calculate from params
+    return 0; 
+}
+
+size_t 
+LowFreq::getPreferredStepSize() const
+{
+    //!!!
+    return 0;
+}
+
+size_t
+LowFreq::getMinChannelCount() const
+{
+    return 1;
+}
+
+size_t
+LowFreq::getMaxChannelCount() const
+{
+    return 1;
+}
+
+LowFreq::ParameterList
+LowFreq::getParameterDescriptors() const
+{
+    ParameterList list;
+
+    ParameterDescriptor d;
+    d.identifier = "p_short";
+    d.name = "Shortest Period";
+    d.description = "Period in seconds of the highest-frequency component to include in the spectrogram. That is, 1/f where f is the highest frequency (in Hz) spanned by the spectrogram.";
+    d.unit = "s";
+    d.minValue = 0.01;
+    d.maxValue = 10;
+    d.defaultValue = defaultPShort;
+    d.isQuantized = false;
+    list.push_back(d);
+
+    ParameterDescriptor d;
+    d.identifier = "p_long";
+    d.name = "Longest Period";
+    d.description = "Period in seconds of the lowest-frequency component to include in the spectrogram. That is, 1/f where f is the lowest frequency (in Hz) spanned by the spectrogram.";
+    d.unit = "s";
+    d.minValue = 0.01;
+    d.maxValue = 10;
+    d.defaultValue = defaultPLong;
+    d.isQuantized = false;
+    list.push_back(d);
+
+    return list;
+}
+
+float
+LowFreq::getParameter(string identifier) const
+{
+    if (identifier == "p_short") {
+	return m_pShort;
+    } else if (identifier == "p_long") {
+	return m_pLong;
+    }
+    return 0;
+}
+
+void
+LowFreq::setParameter(string identifier, float value) 
+{
+    if (identifier == "p_short") {
+	m_pShort = value;
+    } else if (identifier == "p_long") {
+	m_pLong = value;
+    }
+}
+
+LowFreq::ProgramList
+LowFreq::getPrograms() const
+{
+    ProgramList list;
+    return list;
+}
+
+string
+LowFreq::getCurrentProgram() const
+{
+    return ""; // no programs
+}
+
+void
+LowFreq::selectProgram(string name)
+{
+}
+
+LowFreq::OutputList
+LowFreq::getOutputDescriptors() const
+{
+    OutputList list;
+
+    OutputDescriptor d;
+    d.identifier = "spectrogram";
+    d.name = "Spectrogram";
+    d.description = "";
+    d.unit = "";
+    d.hasFixedBinCount = true;
+    d.binCount = 1; //!!! calculate
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::OneSamplePerStep;
+    d.hasDuration = false;
+    list.push_back(d);
+
+    return list;
+}
+
+bool
+LowFreq::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
+LowFreq::reset()
+{
+    // Clear buffers, reset stored values, etc
+}
+
+LowFreq::FeatureSet
+LowFreq::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
+{
+    // Do actual work!
+    return FeatureSet();
+}
+
+LowFreq::FeatureSet
+LowFreq::getRemainingFeatures()
+{
+    return FeatureSet();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LowFreq.h	Mon Mar 03 16:35:27 2014 +0000
@@ -0,0 +1,53 @@
+#ifndef _LOWFREQ_H_
+#define _LOWFREQ_H_
+
+#include <vamp-sdk/Plugin.h>
+
+using std::string;
+
+
+class LowFreq : public Vamp::Plugin
+{
+public:
+    LowFreq(float inputSampleRate);
+    virtual ~LowFreq();
+
+    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:
+    float m_pShort;
+    float m_pLong;
+};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins.cpp	Mon Mar 03 16:35:27 2014 +0000
@@ -0,0 +1,20 @@
+
+#include <vamp/vamp.h>
+#include <vamp-sdk/PluginAdapter.h>
+
+#include "LowFreq.h"
+
+static Vamp::PluginAdapter<LowFreq> lowFreqAdapter;
+
+const VampPluginDescriptor *
+vampGetPluginDescriptor(unsigned int version, unsigned int index)
+{
+    if (version < 1) return 0;
+
+    switch (index) {
+    case  0: return lowFreqAdapter.getDescriptor();
+    default: return 0;
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-plugin.list	Mon Mar 03 16:35:27 2014 +0000
@@ -0,0 +1,1 @@
+_vampGetPluginDescriptor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-plugin.map	Mon Mar 03 16:35:27 2014 +0000
@@ -0,0 +1,4 @@
+{
+	global: vampGetPluginDescriptor;
+	local: *;
+};