Mercurial > hg > svcore
changeset 889:7f97a4d9d14f
Use fixed-rate feature no directly as column number, rather than do a calculation that might introduce rounding error
author | Chris Cannam |
---|---|
date | Tue, 11 Mar 2014 17:29:44 +0000 |
parents | 68f3eaefe297 |
children | 8962f80f5d8e 451f7f3ab6e7 16c48a3db2a7 |
files | transform/FeatureExtractionModelTransformer.cpp |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp Thu Feb 06 18:30:11 2014 +0000 +++ b/transform/FeatureExtractionModelTransformer.cpp Tue Mar 11 17:29:44 2014 +0000 @@ -228,12 +228,11 @@ //!!! the model rate to be the input model's rate, and adjust //!!! the resolution appropriately. We can't properly display //!!! data with a higher resolution than the base model at all -// modelRate = size_t(m_descriptor->sampleRate + 0.001); if (m_descriptor->sampleRate > input->getSampleRate()) { modelResolution = 1; } else { - modelResolution = size_t(input->getSampleRate() / - m_descriptor->sampleRate); + modelResolution = size_t(round(input->getSampleRate() / + m_descriptor->sampleRate)); } break; } @@ -683,7 +682,7 @@ // << ", m_descriptor->sampleRate = " << m_descriptor->sampleRate // << ", inputRate = " << inputRate // << " giving frame = "; - + frame = lrintf((m_fixedRateFeatureNo / m_descriptor->sampleRate) * int(inputRate)); @@ -801,7 +800,14 @@ getConformingOutput<EditableDenseThreeDimensionalModel>(); if (!model) return; - model->setColumn(frame / model->getResolution(), values); +// cerr << "(note: model resolution = " << model->getResolution() << ")" +// << endl; + + if (!feature.hasTimestamp && m_fixedRateFeatureNo >= 0) { + model->setColumn(m_fixedRateFeatureNo, values); + } else { + model->setColumn(frame / model->getResolution(), values); + } } else { SVDEBUG << "FeatureExtractionModelTransformer::addFeature: Unknown output model type!" << endl;