comparison BeatRootVampPlugin.cpp @ 0:886f11e41417

* Add skeleton files
author Chris Cannam
date Mon, 24 Jan 2011 10:26:57 +0000
parents
children 7d4e6b1ff3d1
comparison
equal deleted inserted replaced
-1:000000000000 0:886f11e41417
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
18
19 BeatRootVampPlugin::BeatRootVampPlugin(float inputSampleRate) :
20 Plugin(inputSampleRate)
21 {
22 m_processor = new BeatRootProcessor(inputSampleRate);
23 }
24
25 BeatRootVampPlugin::~BeatRootVampPlugin()
26 {
27 delete m_processor;
28 }
29
30 string
31 BeatRootVampPlugin::getIdentifier() const
32 {
33 return "beatroot";
34 }
35
36 string
37 BeatRootVampPlugin::getName() const
38 {
39 return "BeatRoot Beat Tracker";
40 }
41
42 string
43 BeatRootVampPlugin::getDescription() const
44 {
45 return "Identify beat locations in music";
46 }
47
48 string
49 BeatRootVampPlugin::getMaker() const
50 {
51 return "Simon Dixon (plugin by Chris Cannam)";
52 }
53
54 int
55 BeatRootVampPlugin::getPluginVersion() const
56 {
57 // Increment this each time you release a version that behaves
58 // differently from the previous one
59 return 1;
60 }
61
62 string
63 BeatRootVampPlugin::getCopyright() const
64 {
65 return "GPL";
66 }
67
68 BeatRootVampPlugin::InputDomain
69 BeatRootVampPlugin::getInputDomain() const
70 {
71 return FrequencyDomain;
72 }
73
74 size_t
75 BeatRootVampPlugin::getPreferredBlockSize() const
76 {
77 return m_processor->getFFTSize();
78 }
79
80 size_t
81 BeatRootVampPlugin::getPreferredStepSize() const
82 {
83 return m_processor->getHopSize();
84 }
85
86 size_t
87 BeatRootVampPlugin::getMinChannelCount() const
88 {
89 return 1;
90 }
91
92 size_t
93 BeatRootVampPlugin::getMaxChannelCount() const
94 {
95 return 1;
96 }
97
98 BeatRootVampPlugin::ParameterList
99 BeatRootVampPlugin::getParameterDescriptors() const
100 {
101 ParameterList list;
102 return list;
103 }
104
105 float
106 BeatRootVampPlugin::getParameter(string identifier) const
107 {
108 return 0;
109 }
110
111 void
112 BeatRootVampPlugin::setParameter(string identifier, float value)
113 {
114 }
115
116 BeatRootVampPlugin::ProgramList
117 BeatRootVampPlugin::getPrograms() const
118 {
119 ProgramList list;
120 return list;
121 }
122
123 string
124 BeatRootVampPlugin::getCurrentProgram() const
125 {
126 return ""; // no programs
127 }
128
129 void
130 BeatRootVampPlugin::selectProgram(string name)
131 {
132 }
133
134 BeatRootVampPlugin::OutputList
135 BeatRootVampPlugin::getOutputDescriptors() const
136 {
137 OutputList list;
138
139 // See OutputDescriptor documentation for the possibilities here.
140 // Every plugin must have at least one output.
141
142 OutputDescriptor d;
143 d.identifier = "beats";
144 d.name = "Beats";
145 d.description = "Estimated beat locations";
146 d.unit = "";
147 d.hasFixedBinCount = true;
148 d.binCount = 0;
149 d.hasKnownExtents = false;
150 d.isQuantized = false;
151 d.sampleType = OutputDescriptor::VariableSampleRate;
152 d.hasDuration = false;
153 list.push_back(d);
154
155 return list;
156 }
157
158 bool
159 BeatRootVampPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize)
160 {
161 if (channels < getMinChannelCount() ||
162 channels > getMaxChannelCount()) {
163 std::cerr << "BeatRootVampPlugin::initialise: Unsupported number ("
164 << channels << ") of channels" << std::endl;
165 return false;
166 }
167
168 if (stepSize != getPreferredStepSize()) {
169 std::cerr << "BeatRootVampPlugin::initialise: Unsupported step size "
170 << "for sample rate (" << stepSize << ", required step is "
171 << getPreferredStepSize() << " for rate " << m_inputSampleRate
172 << ")" << std::endl;
173 return false;
174 }
175
176 if (blockSize != getPreferredBlockSize()) {
177 std::cerr << "BeatRootVampPlugin::initialise: Unsupported block size "
178 << "for sample rate (" << blockSize << ", required size is "
179 << getPreferredBlockSize() << " for rate " << m_inputSampleRate
180 << ")" << std::endl;
181 return false;
182 }
183
184 m_processor->initialise();
185
186 return true;
187 }
188
189 void
190 BeatRootVampPlugin::reset()
191 {
192 m_processor->reset();
193 }
194
195 BeatRootVampPlugin::FeatureSet
196 BeatRootVampPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
197 {
198 // Do actual work!
199 return FeatureSet();
200 }
201
202 BeatRootVampPlugin::FeatureSet
203 BeatRootVampPlugin::getRemainingFeatures()
204 {
205 return FeatureSet();
206 }
207
208
209 static Vamp::PluginAdapter<BeatRootVampPlugin> brAdapter;
210
211 const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int version,
212 unsigned int index)
213 {
214 if (version < 1) return 0;
215
216 switch (index) {
217 case 0: return brAdapter.getDescriptor();
218 default: return 0;
219 }
220 }
221