m_peakpick = new_aubio_peakpicker(m_threshold);
m_onsetdet = new_aubio_onsetdetection(m_onsettype, blockSize, channels);
+
+ m_delay = Vamp::RealTime::frame2RealTime(4 * stepSize,
+ lrintf(m_inputSampleRate));
+
+ m_lastOnset = Vamp::RealTime::zeroTime - m_delay - m_delay;
return true;
}
size_t
Onset::getPreferredBlockSize() const
{
- return 2*getPreferredStepSize();
+ return 2 * getPreferredStepSize();
}
Onset::ParameterList
d.description = "Onsets";
d.hasFixedBinCount = true;
d.binCount = 0;
- d.sampleType = OutputDescriptor::OneSamplePerStep;
+ d.sampleType = OutputDescriptor::VariableSampleRate;
+ d.sampleRate = 0;
list.push_back(d);
d = OutputDescriptor();
}
Onset::FeatureSet
-Onset::process(float **inputBuffers, Vamp::RealTime /* timestamp */)
+Onset::process(float **inputBuffers, Vamp::RealTime timestamp)
{
for (size_t i = 0; i < m_stepSize; ++i) {
for (size_t j = 0; j < m_channelCount; ++j) {
FeatureSet returnFeatures;
if (isonset) {
- Feature onsettime;
- onsettime.hasTimestamp = false;
- returnFeatures[0].push_back(onsettime);
+ if (timestamp - m_lastOnset >= m_delay) {
+ Feature onsettime;
+ onsettime.hasTimestamp = true;
+ onsettime.timestamp = timestamp - m_delay;
+ returnFeatures[0].push_back(onsettime);
+ m_lastOnset = timestamp;
+ }
}
Feature feature;
for (size_t j = 0; j < m_channelCount; ++j) {