Revision 31:b9c2f444cdaa
| BeatRootProcessor.h | ||
|---|---|---|
| 94 | 94 |
* file is set (see <code>setInputFile()</code>). */ |
| 95 | 95 |
BeatRootProcessor(float sr, AgentParameters parameters) : |
| 96 | 96 |
sampleRate(sr), |
| 97 |
hopTime(0.010), |
|
| 98 |
fftTime(0.04644), |
|
| 97 | 99 |
hopSize(0), |
| 98 | 100 |
fftSize(0), |
| 99 |
hopTime(0.010), |
|
| 100 |
fftTime(0.04644), |
|
| 101 | 101 |
agentParameters(parameters) |
| 102 | 102 |
{
|
| 103 | 103 |
hopSize = lrint(sampleRate * hopTime); |
| BeatRootVampPlugin.cpp | ||
|---|---|---|
| 22 | 22 |
#include <vamp-sdk/PluginAdapter.h> |
| 23 | 23 |
|
| 24 | 24 |
BeatRootVampPlugin::BeatRootVampPlugin(float inputSampleRate) : |
| 25 |
Plugin(inputSampleRate) |
|
| 25 |
Plugin(inputSampleRate), |
|
| 26 |
m_firstFrame(true) |
|
| 26 | 27 |
{
|
| 27 | 28 |
m_processor = new BeatRootProcessor(inputSampleRate, AgentParameters()); |
| 28 | 29 |
} |
| ... | ... | |
| 107 | 108 |
|
| 108 | 109 |
ParameterDescriptor desc; |
| 109 | 110 |
|
| 110 |
double postMarginFactor; |
|
| 111 |
|
|
| 112 |
/** The maximum amount by which a beat can be earlier than the |
|
| 113 |
* predicted beat time, expressed as a fraction of the beat |
|
| 114 |
* period. */ |
|
| 115 |
double preMarginFactor; |
|
| 116 |
|
|
| 117 |
/** The maximum allowed deviation from the initial tempo, |
|
| 118 |
* expressed as a fraction of the initial beat period. */ |
|
| 119 |
double maxChange; |
|
| 120 |
|
|
| 121 |
/** The default value of expiryTime, which is the time (in |
|
| 122 |
* seconds) after which an Agent that has no Event matching its |
|
| 123 |
* beat predictions will be destroyed. */ |
|
| 124 |
|
|
| 125 | 111 |
desc.identifier = "preMarginFactor"; |
| 126 | 112 |
desc.name = "Pre-Margin Factor"; |
| 127 | 113 |
desc.description = "The maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period."; |
| ... | ... | |
| 295 | 281 |
BeatRootVampPlugin::reset() |
| 296 | 282 |
{
|
| 297 | 283 |
m_processor->reset(); |
| 284 |
m_firstFrame = true; |
|
| 285 |
m_origin = Vamp::RealTime::zeroTime; |
|
| 298 | 286 |
} |
| 299 | 287 |
|
| 300 | 288 |
BeatRootVampPlugin::FeatureSet |
| 301 | 289 |
BeatRootVampPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp) |
| 302 | 290 |
{
|
| 291 |
if (m_firstFrame) {
|
|
| 292 |
m_origin = timestamp; |
|
| 293 |
m_firstFrame = false; |
|
| 294 |
} |
|
| 295 |
|
|
| 303 | 296 |
m_processor->processFrame(inputBuffers); |
| 304 | 297 |
return FeatureSet(); |
| 305 | 298 |
} |
| ... | ... | |
| 318 | 311 |
FeatureSet fs; |
| 319 | 312 |
|
| 320 | 313 |
for (EventList::const_iterator i = el.begin(); i != el.end(); ++i) {
|
| 321 |
f.timestamp = Vamp::RealTime::fromSeconds(i->time); |
|
| 314 |
f.timestamp = m_origin + Vamp::RealTime::fromSeconds(i->time);
|
|
| 322 | 315 |
fs[0].push_back(f); |
| 323 | 316 |
} |
| 324 | 317 |
|
| BeatRootVampPlugin.h | ||
|---|---|---|
| 64 | 64 |
protected: |
| 65 | 65 |
BeatRootProcessor *m_processor; |
| 66 | 66 |
AgentParameters m_parameters; |
| 67 |
Vamp::RealTime m_origin; |
|
| 68 |
bool m_firstFrame; |
|
| 67 | 69 |
}; |
| 68 | 70 |
|
| 69 | 71 |
|
Also available in: Unified diff