diff transform/FeatureExtractionModelTransformer.cpp @ 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 786ee8d1f30e
children 8962f80f5d8e
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;