# HG changeset patch # User Chris Cannam # Date 1393864527 0 # Node ID b26975f6a1f1a0140f8050ece2db033fdc99fd9a Initial commit with skeleton code diff -r 000000000000 -r b26975f6a1f1 LowFreq.cpp --- /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(); +} + diff -r 000000000000 -r b26975f6a1f1 LowFreq.h --- /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 + +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 diff -r 000000000000 -r b26975f6a1f1 plugins.cpp --- /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 +#include + +#include "LowFreq.h" + +static Vamp::PluginAdapter 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; + } +} + + diff -r 000000000000 -r b26975f6a1f1 vamp-plugin.list --- /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 diff -r 000000000000 -r b26975f6a1f1 vamp-plugin.map --- /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: *; +};