# HG changeset patch # User Chris Cannam # Date 1394558984 0 # Node ID 7f97a4d9d14f09517a4e25f172305d5a9c64b36a # Parent 68f3eaefe2977fcfd313c8481a33fcaa7e4fe103 Use fixed-rate feature no directly as column number, rather than do a calculation that might introduce rounding error diff -r 68f3eaefe297 -r 7f97a4d9d14f transform/FeatureExtractionModelTransformer.cpp --- 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(); 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;