changeset 781:f9f5e18a366e qt5

Merge from default branch
author Chris Cannam
date Wed, 27 Mar 2013 16:54:59 +0000
parents 7df8bd39d671 (current diff) cf466a5d411e (diff)
children 711a4652d616
files
diffstat 3 files changed, 35 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/SparseModel.h	Mon Mar 25 15:29:52 2013 +0000
+++ b/data/model/SparseModel.h	Wed Mar 27 16:54:59 2013 +0000
@@ -386,6 +386,7 @@
     {
         m_rows.clear();
         for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) {
+//            std::cerr << "rebuildRowVector: row " << m_rows.size() << " -> " << i->frame << std::endl;
             m_rows.push_back(i->frame);
         }
     }
@@ -406,6 +407,7 @@
         PointListIterator i = i0;
 
         for (i = i0; i != i1; ++i) {
+            if (i->frame < (int)frame) { continue; }
             if (indexAtFrame > 0) { --indexAtFrame; continue; }
             return i;
         }
@@ -427,11 +429,14 @@
         while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; }
         int initialIndexAtFrame = indexAtFrame;
 
+//        std::cerr << "getPointListIteratorForRow " << row << ": initialIndexAtFrame = " << initialIndexAtFrame << std::endl;
+
         PointListConstIterator i0, i1;
         getPointIterators(frame, i0, i1);
         PointListConstIterator i = i0;
 
         for (i = i0; i != i1; ++i) {
+            if (i->frame < (int)frame) { continue; }
             if (indexAtFrame > 0) { --indexAtFrame; continue; }
             return i;
         }
@@ -579,7 +584,7 @@
     long end = start + m_resolution;
 
     PointType startPoint(start), endPoint(end);
-    
+
     startItr = m_points.lower_bound(startPoint);
       endItr = m_points.upper_bound(endPoint);
 }
@@ -603,6 +608,8 @@
 
     PointType startPoint(start), endPoint(end);
     
+//    std::cerr << "getPointIterators: start frame " << start << ", end frame " << end << ", m_resolution " << m_resolution << std::endl;
+    
     startItr = m_points.lower_bound(startPoint);
       endItr = m_points.upper_bound(endPoint);
 }
@@ -775,8 +782,8 @@
                               QString indent,
                               QString extraAttributes) const
 {
-    std::cerr << "SparseModel::toXml: extraAttributes = \"" 
-              << extraAttributes.toStdString() << std::endl;
+//    std::cerr << "SparseModel::toXml: extraAttributes = \"" 
+//              << extraAttributes.toStdString() << std::endl;
 
     QString type = getXmlOutputType();
 
--- a/transform/FeatureExtractionModelTransformer.cpp	Mon Mar 25 15:29:52 2013 +0000
+++ b/transform/FeatureExtractionModelTransformer.cpp	Wed Mar 27 16:54:59 2013 +0000
@@ -41,7 +41,8 @@
     ModelTransformer(in, transform),
     m_plugin(0),
     m_descriptor(0),
-    m_outputFeatureNo(0)
+    m_outputNo(0),
+    m_fixedRateFeatureNo(-1) // we increment before use
 {
 //    SVDEBUG << "FeatureExtractionModelTransformer::FeatureExtractionModelTransformer: plugin " << pluginId << ", outputName " << m_transform.getOutput() << endl;
 
@@ -155,7 +156,7 @@
 //        SVDEBUG << "comparing output " << i << " name \"" << outputs[i].identifier << "\" with expected \"" << m_transform.getOutput() << "\"" << endl;
 	if (m_transform.getOutput() == "" ||
             outputs[i].identifier == m_transform.getOutput().toStdString()) {
-	    m_outputFeatureNo = i;
+	    m_outputNo = i;
 	    m_descriptor = new Vamp::Plugin::OutputDescriptor(outputs[i]);
 	    break;
 	}
@@ -339,7 +340,7 @@
         }
 
         Vamp::Plugin::OutputList outputs = m_plugin->getOutputDescriptors();
-        model->setScaleUnits(outputs[m_outputFeatureNo].unit.c_str());
+        model->setScaleUnits(outputs[m_outputNo].unit.c_str());
 
         m_output = model;
 
@@ -534,9 +535,8 @@
 
         if (m_abandoned) break;
 
-	for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) {
-	    Vamp::Plugin::Feature feature =
-		features[m_outputFeatureNo][fi];
+	for (size_t fi = 0; fi < features[m_outputNo].size(); ++fi) {
+	    Vamp::Plugin::Feature feature = features[m_outputNo][fi];
 	    addFeature(blockFrame, feature);
 	}
 
@@ -551,9 +551,8 @@
     if (!m_abandoned) {
         Vamp::Plugin::FeatureSet features = m_plugin->getRemainingFeatures();
 
-        for (size_t fi = 0; fi < features[m_outputFeatureNo].size(); ++fi) {
-            Vamp::Plugin::Feature feature =
-                features[m_outputFeatureNo][fi];
+        for (size_t fi = 0; fi < features[m_outputNo].size(); ++fi) {
+            Vamp::Plugin::Feature feature = features[m_outputNo][fi];
             addFeature(blockFrame, feature);
         }
     }
@@ -664,15 +663,19 @@
     } else if (m_descriptor->sampleType ==
 	       Vamp::Plugin::OutputDescriptor::FixedSampleRate) {
 
-	if (feature.hasTimestamp) {
-	    //!!! warning: sampleRate may be non-integral
-	    frame = Vamp::RealTime::realTime2Frame(feature.timestamp,
-//!!! see comment above when setting up modelResolution and modelRate
-//                                                   lrintf(m_descriptor->sampleRate));
-                                                   inputRate);
-	} else {
-	    frame = m_output->getEndFrame();
-	}
+        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);
+
+        std::cerr << "Feature hasTimestamp = " << feature.hasTimestamp << ", timestamp = " << feature.timestamp << ", frame works out to " << frame << std::endl;
+
     }
 	
     // Rather than repeat the complicated tests from the constructor
@@ -704,6 +707,8 @@
                 label = QString("[%1] %2").arg(i+1).arg(label);
             }
 
+            std::cerr << "Adding point at " << frame << " with value " << value << " and label " << label << std::endl;
+
             model->addPoint(SparseTimeValueModel::Point(frame, value, label));
         }
 
--- a/transform/FeatureExtractionModelTransformer.h	Mon Mar 25 15:29:52 2013 +0000
+++ b/transform/FeatureExtractionModelTransformer.h	Wed Mar 27 16:54:59 2013 +0000
@@ -40,7 +40,8 @@
 
     Vamp::Plugin *m_plugin;
     Vamp::Plugin::OutputDescriptor *m_descriptor;
-    int m_outputFeatureNo;
+    int m_fixedRateFeatureNo; // to assign times to FixedSampleRate features
+    int m_outputNo;
 
     void createOutputModel();