Revision 31:b9c2f444cdaa BeatRootVampPlugin.cpp

View differences:

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

  

Also available in: Unified diff