diff transform/FeatureExtractionModelTransformer.cpp @ 451:3c5252e7cefd

* Fix (kinda) display of fixed-sample-rate features with sample rate different from the input model's rate
author Chris Cannam
date Wed, 08 Oct 2008 15:27:31 +0000
parents 55cff2c6e4a0
children ba7aaacb7211
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp	Tue Oct 07 12:59:55 2008 +0000
+++ b/transform/FeatureExtractionModelTransformer.cpp	Wed Oct 08 15:27:31 2008 +0000
@@ -203,7 +203,18 @@
 	break;
 
     case Vamp::Plugin::OutputDescriptor::FixedSampleRate:
-	modelRate = size_t(m_descriptor->sampleRate + 0.001);
+        //!!! SV doesn't actually support display of models that have
+        //!!! different underlying rates together -- so we always set
+        //!!! 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);
+        }
 	break;
     }
 
@@ -598,7 +609,9 @@
 	if (feature.hasTimestamp) {
 	    //!!! warning: sampleRate may be non-integral
 	    frame = Vamp::RealTime::realTime2Frame(feature.timestamp,
-                                                   lrintf(m_descriptor->sampleRate));
+//!!! see comment above when setting up modelResolution and modelRate
+//                                                   lrintf(m_descriptor->sampleRate));
+                                                   inputRate);
 	} else {
 	    frame = m_output->getEndFrame();
 	}