Mercurial > hg > svcore
changeset 779:15cd67fcbdad
Fix calculation of timestamps for fixed-rate features
author | Chris Cannam |
---|---|
date | Wed, 27 Mar 2013 15:27:33 +0000 |
parents | d373ced0e6e9 |
children | cf466a5d411e |
files | transform/FeatureExtractionModelTransformer.cpp transform/FeatureExtractionModelTransformer.h |
diffstat | 2 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp Wed Mar 27 15:07:27 2013 +0000 +++ b/transform/FeatureExtractionModelTransformer.cpp Wed Mar 27 15:27:33 2013 +0000 @@ -41,7 +41,8 @@ ModelTransformer(in, transform), m_plugin(0), m_descriptor(0), - m_outputNo(0) + m_outputNo(0), + m_fixedRateFeatureNo(-1) // we increment before use { // SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl; @@ -662,6 +663,17 @@ } else if (m_descriptor->sampleType == Vamp::Plugin::OutputDescriptor::FixedSampleRate) { + if (!feature.hasTimestamp) { + ++m_fixedRateFeatureNo; + } else { + RealTime ts(feature.timestamp.sec, feature.timestamp.nsec); + m_fixedRateFeatureNo = + lrint(ts.toDouble() * m_descriptor->sampleRate); + } + + frame = lrintf((m_fixedRateFeatureNo / m_descriptor->sampleRate) + * inputRate); +/* if (feature.hasTimestamp) { //!!! warning: sampleRate may be non-integral frame = Vamp::RealTime::realTime2Frame(feature.timestamp, @@ -671,8 +683,8 @@ } else { frame = m_output->getEndFrame(); } - -// std::cerr << "Feature hasTimestamp = " << feature.hasTimestamp << ", timestamp = " << feature.timestamp << ", frame works out to " << frame << std::endl; +*/ + std::cerr << "Feature hasTimestamp = " << feature.hasTimestamp << ", timestamp = " << feature.timestamp << ", frame works out to " << frame << std::endl; }
--- a/transform/FeatureExtractionModelTransformer.h Wed Mar 27 15:07:27 2013 +0000 +++ b/transform/FeatureExtractionModelTransformer.h Wed Mar 27 15:27:33 2013 +0000 @@ -40,6 +40,7 @@ Vamp::Plugin *m_plugin; Vamp::Plugin::OutputDescriptor *m_descriptor; + int m_fixedRateFeatureNo; // to assign times to FixedSampleRate features int m_outputNo; void createOutputModel();