To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / BeatRootVampPlugin.cpp @ 2:7d4e6b1ff3d1
History | View | Annotate | Download (4.66 KB)
| 1 |
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
|---|---|
| 2 |
|
| 3 |
/*
|
| 4 |
Vamp feature extraction plugin for the BeatRoot beat tracker.
|
| 5 |
|
| 6 |
Centre for Digital Music, Queen Mary, University of London.
|
| 7 |
This file copyright 2011 Simon Dixon, Chris Cannam and QMUL.
|
| 8 |
|
| 9 |
This program is free software; you can redistribute it and/or
|
| 10 |
modify it under the terms of the GNU General Public License as
|
| 11 |
published by the Free Software Foundation; either version 2 of the
|
| 12 |
License, or (at your option) any later version. See the file
|
| 13 |
COPYING included with this distribution for more information.
|
| 14 |
*/
|
| 15 |
|
| 16 |
#include "BeatRootVampPlugin.h" |
| 17 |
#include "BeatRootProcessor.h" |
| 18 |
|
| 19 |
|
| 20 |
BeatRootVampPlugin::BeatRootVampPlugin(float inputSampleRate) :
|
| 21 |
Plugin(inputSampleRate) |
| 22 |
{
|
| 23 |
m_processor = new BeatRootProcessor(inputSampleRate);
|
| 24 |
} |
| 25 |
|
| 26 |
BeatRootVampPlugin::~BeatRootVampPlugin() |
| 27 |
{
|
| 28 |
delete m_processor;
|
| 29 |
} |
| 30 |
|
| 31 |
string
|
| 32 |
BeatRootVampPlugin::getIdentifier() const
|
| 33 |
{
|
| 34 |
return "beatroot"; |
| 35 |
} |
| 36 |
|
| 37 |
string
|
| 38 |
BeatRootVampPlugin::getName() const
|
| 39 |
{
|
| 40 |
return "BeatRoot Beat Tracker"; |
| 41 |
} |
| 42 |
|
| 43 |
string
|
| 44 |
BeatRootVampPlugin::getDescription() const
|
| 45 |
{
|
| 46 |
return "Identify beat locations in music"; |
| 47 |
} |
| 48 |
|
| 49 |
string
|
| 50 |
BeatRootVampPlugin::getMaker() const
|
| 51 |
{
|
| 52 |
return "Simon Dixon (plugin by Chris Cannam)"; |
| 53 |
} |
| 54 |
|
| 55 |
int
|
| 56 |
BeatRootVampPlugin::getPluginVersion() const
|
| 57 |
{
|
| 58 |
// Increment this each time you release a version that behaves
|
| 59 |
// differently from the previous one
|
| 60 |
return 1; |
| 61 |
} |
| 62 |
|
| 63 |
string
|
| 64 |
BeatRootVampPlugin::getCopyright() const
|
| 65 |
{
|
| 66 |
return "GPL"; |
| 67 |
} |
| 68 |
|
| 69 |
BeatRootVampPlugin::InputDomain |
| 70 |
BeatRootVampPlugin::getInputDomain() const
|
| 71 |
{
|
| 72 |
return FrequencyDomain;
|
| 73 |
} |
| 74 |
|
| 75 |
size_t |
| 76 |
BeatRootVampPlugin::getPreferredBlockSize() const
|
| 77 |
{
|
| 78 |
return m_processor->getFFTSize();
|
| 79 |
} |
| 80 |
|
| 81 |
size_t |
| 82 |
BeatRootVampPlugin::getPreferredStepSize() const
|
| 83 |
{
|
| 84 |
return m_processor->getHopSize();
|
| 85 |
} |
| 86 |
|
| 87 |
size_t |
| 88 |
BeatRootVampPlugin::getMinChannelCount() const
|
| 89 |
{
|
| 90 |
return 1; |
| 91 |
} |
| 92 |
|
| 93 |
size_t |
| 94 |
BeatRootVampPlugin::getMaxChannelCount() const
|
| 95 |
{
|
| 96 |
return 1; |
| 97 |
} |
| 98 |
|
| 99 |
BeatRootVampPlugin::ParameterList |
| 100 |
BeatRootVampPlugin::getParameterDescriptors() const
|
| 101 |
{
|
| 102 |
ParameterList list; |
| 103 |
return list;
|
| 104 |
} |
| 105 |
|
| 106 |
float
|
| 107 |
BeatRootVampPlugin::getParameter(string identifier) const |
| 108 |
{
|
| 109 |
return 0; |
| 110 |
} |
| 111 |
|
| 112 |
void
|
| 113 |
BeatRootVampPlugin::setParameter(string identifier, float value) |
| 114 |
{
|
| 115 |
} |
| 116 |
|
| 117 |
BeatRootVampPlugin::ProgramList |
| 118 |
BeatRootVampPlugin::getPrograms() const
|
| 119 |
{
|
| 120 |
ProgramList list; |
| 121 |
return list;
|
| 122 |
} |
| 123 |
|
| 124 |
string
|
| 125 |
BeatRootVampPlugin::getCurrentProgram() const
|
| 126 |
{
|
| 127 |
return ""; // no programs |
| 128 |
} |
| 129 |
|
| 130 |
void
|
| 131 |
BeatRootVampPlugin::selectProgram(string name)
|
| 132 |
{
|
| 133 |
} |
| 134 |
|
| 135 |
BeatRootVampPlugin::OutputList |
| 136 |
BeatRootVampPlugin::getOutputDescriptors() const
|
| 137 |
{
|
| 138 |
OutputList list; |
| 139 |
|
| 140 |
// See OutputDescriptor documentation for the possibilities here.
|
| 141 |
// Every plugin must have at least one output.
|
| 142 |
|
| 143 |
OutputDescriptor d; |
| 144 |
d.identifier = "beats";
|
| 145 |
d.name = "Beats";
|
| 146 |
d.description = "Estimated beat locations";
|
| 147 |
d.unit = "";
|
| 148 |
d.hasFixedBinCount = true;
|
| 149 |
d.binCount = 0;
|
| 150 |
d.hasKnownExtents = false;
|
| 151 |
d.isQuantized = false;
|
| 152 |
d.sampleType = OutputDescriptor::VariableSampleRate; |
| 153 |
d.hasDuration = false;
|
| 154 |
list.push_back(d); |
| 155 |
|
| 156 |
return list;
|
| 157 |
} |
| 158 |
|
| 159 |
bool
|
| 160 |
BeatRootVampPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize) |
| 161 |
{
|
| 162 |
if (channels < getMinChannelCount() ||
|
| 163 |
channels > getMaxChannelCount()) {
|
| 164 |
std::cerr << "BeatRootVampPlugin::initialise: Unsupported number ("
|
| 165 |
<< channels << ") of channels" << std::endl;
|
| 166 |
return false; |
| 167 |
} |
| 168 |
|
| 169 |
if (stepSize != getPreferredStepSize()) {
|
| 170 |
std::cerr << "BeatRootVampPlugin::initialise: Unsupported step size "
|
| 171 |
<< "for sample rate (" << stepSize << ", required step is " |
| 172 |
<< getPreferredStepSize() << " for rate " << m_inputSampleRate
|
| 173 |
<< ")" << std::endl;
|
| 174 |
return false; |
| 175 |
} |
| 176 |
|
| 177 |
if (blockSize != getPreferredBlockSize()) {
|
| 178 |
std::cerr << "BeatRootVampPlugin::initialise: Unsupported block size "
|
| 179 |
<< "for sample rate (" << blockSize << ", required size is " |
| 180 |
<< getPreferredBlockSize() << " for rate " << m_inputSampleRate
|
| 181 |
<< ")" << std::endl;
|
| 182 |
return false; |
| 183 |
} |
| 184 |
|
| 185 |
m_processor->initialise(); |
| 186 |
|
| 187 |
return true; |
| 188 |
} |
| 189 |
|
| 190 |
void
|
| 191 |
BeatRootVampPlugin::reset() |
| 192 |
{
|
| 193 |
m_processor->reset(); |
| 194 |
} |
| 195 |
|
| 196 |
BeatRootVampPlugin::FeatureSet |
| 197 |
BeatRootVampPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp) |
| 198 |
{
|
| 199 |
// Do actual work!
|
| 200 |
return FeatureSet();
|
| 201 |
} |
| 202 |
|
| 203 |
BeatRootVampPlugin::FeatureSet |
| 204 |
BeatRootVampPlugin::getRemainingFeatures() |
| 205 |
{
|
| 206 |
return FeatureSet();
|
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
static Vamp::PluginAdapter<BeatRootVampPlugin> brAdapter;
|
| 211 |
|
| 212 |
const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int version, |
| 213 |
unsigned int index) |
| 214 |
{
|
| 215 |
if (version < 1) return 0; |
| 216 |
|
| 217 |
switch (index) {
|
| 218 |
case 0: return brAdapter.getDescriptor(); |
| 219 |
default: return 0; |
| 220 |
} |
| 221 |
} |
| 222 |
|