changeset 0:886f11e41417

* Add skeleton files
author Chris Cannam
date Mon, 24 Jan 2011 10:26:57 +0000
parents
children 791398eaf639
files .hgignore BeatRootVampPlugin.cpp BeatRootVampPlugin.h
diffstat 3 files changed, 291 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Mon Jan 24 10:26:57 2011 +0000
@@ -0,0 +1,4 @@
+syntax: glob
+*~
+*.o
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BeatRootVampPlugin.cpp	Mon Jan 24 10:26:57 2011 +0000
@@ -0,0 +1,221 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp feature extraction plugin for the BeatRoot beat tracker.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2011 Simon Dixon, Chris Cannam and QMUL.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include "BeatRootVampPlugin.h"
+
+
+BeatRootVampPlugin::BeatRootVampPlugin(float inputSampleRate) :
+    Plugin(inputSampleRate)
+{
+    m_processor = new BeatRootProcessor(inputSampleRate);
+}
+
+BeatRootVampPlugin::~BeatRootVampPlugin()
+{
+    delete m_processor;
+}
+
+string
+BeatRootVampPlugin::getIdentifier() const
+{
+    return "beatroot";
+}
+
+string
+BeatRootVampPlugin::getName() const
+{
+    return "BeatRoot Beat Tracker";
+}
+
+string
+BeatRootVampPlugin::getDescription() const
+{
+    return "Identify beat locations in music";
+}
+
+string
+BeatRootVampPlugin::getMaker() const
+{
+    return "Simon Dixon (plugin by Chris Cannam)";
+}
+
+int
+BeatRootVampPlugin::getPluginVersion() const
+{
+    // Increment this each time you release a version that behaves
+    // differently from the previous one
+    return 1;
+}
+
+string
+BeatRootVampPlugin::getCopyright() const
+{
+    return "GPL";
+}
+
+BeatRootVampPlugin::InputDomain
+BeatRootVampPlugin::getInputDomain() const
+{
+    return FrequencyDomain;
+}
+
+size_t
+BeatRootVampPlugin::getPreferredBlockSize() const
+{
+    return m_processor->getFFTSize();
+}
+
+size_t 
+BeatRootVampPlugin::getPreferredStepSize() const
+{
+    return m_processor->getHopSize();
+}
+
+size_t
+BeatRootVampPlugin::getMinChannelCount() const
+{
+    return 1;
+}
+
+size_t
+BeatRootVampPlugin::getMaxChannelCount() const
+{
+    return 1;
+}
+
+BeatRootVampPlugin::ParameterList
+BeatRootVampPlugin::getParameterDescriptors() const
+{
+    ParameterList list;
+    return list;
+}
+
+float
+BeatRootVampPlugin::getParameter(string identifier) const
+{
+    return 0;
+}
+
+void
+BeatRootVampPlugin::setParameter(string identifier, float value) 
+{
+}
+
+BeatRootVampPlugin::ProgramList
+BeatRootVampPlugin::getPrograms() const
+{
+    ProgramList list;
+    return list;
+}
+
+string
+BeatRootVampPlugin::getCurrentProgram() const
+{
+    return ""; // no programs
+}
+
+void
+BeatRootVampPlugin::selectProgram(string name)
+{
+}
+
+BeatRootVampPlugin::OutputList
+BeatRootVampPlugin::getOutputDescriptors() const
+{
+    OutputList list;
+
+    // See OutputDescriptor documentation for the possibilities here.
+    // Every plugin must have at least one output.
+
+    OutputDescriptor d;
+    d.identifier = "beats";
+    d.name = "Beats";
+    d.description = "Estimated beat locations";
+    d.unit = "";
+    d.hasFixedBinCount = true;
+    d.binCount = 0;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::VariableSampleRate;
+    d.hasDuration = false;
+    list.push_back(d);
+
+    return list;
+}
+
+bool
+BeatRootVampPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize)
+{
+    if (channels < getMinChannelCount() ||
+	channels > getMaxChannelCount()) {
+	std::cerr << "BeatRootVampPlugin::initialise: Unsupported number ("
+		  << channels << ") of channels" << std::endl;
+	return false;
+    }
+
+    if (stepSize != getPreferredStepSize()) {
+	std::cerr << "BeatRootVampPlugin::initialise: Unsupported step size "
+		  << "for sample rate (" << stepSize << ", required step is "
+		  << getPreferredStepSize() << " for rate " << m_inputSampleRate
+		  << ")" << std::endl;
+	return false;
+    }
+
+    if (blockSize != getPreferredBlockSize()) {
+	std::cerr << "BeatRootVampPlugin::initialise: Unsupported block size "
+		  << "for sample rate (" << blockSize << ", required size is "
+		  << getPreferredBlockSize() << " for rate " << m_inputSampleRate
+		  << ")" << std::endl;
+	return false;
+    }
+
+    m_processor->initialise();
+
+    return true;
+}
+
+void
+BeatRootVampPlugin::reset()
+{
+    m_processor->reset();
+}
+
+BeatRootVampPlugin::FeatureSet
+BeatRootVampPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
+{
+    // Do actual work!
+    return FeatureSet();
+}
+
+BeatRootVampPlugin::FeatureSet
+BeatRootVampPlugin::getRemainingFeatures()
+{
+    return FeatureSet();
+}
+
+
+static Vamp::PluginAdapter<BeatRootVampPlugin> brAdapter;
+
+const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int version,
+                                                    unsigned int index)
+{
+    if (version < 1) return 0;
+
+    switch (index) {
+    case  0: return brAdapter.getDescriptor();
+    default: return 0;
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BeatRootVampPlugin.h	Mon Jan 24 10:26:57 2011 +0000
@@ -0,0 +1,66 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp feature extraction plugin for the BeatRoot beat tracker.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2011 Simon Dixon, Chris Cannam and QMUL.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef _BEATROOT_VAMP_PLUGIN_H_
+#define _BEATROOT_VAMP_PLUGIN_H_
+
+#include <vamp-sdk/Plugin.h>
+
+using std::string;
+
+class BeatRootVampPlugin : public Vamp::Plugin
+{
+public:
+    BeatRootVampPlugin(float inputSampleRate);
+    virtual ~BeatRootVampPlugin();
+
+    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:
+    BeatRootProcessor *m_processor;
+};
+
+
+
+#endif