diff data/model/AlignmentModel.cpp @ 1038:cc27f35aa75c cxx11

Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
author Chris Cannam
date Tue, 03 Mar 2015 15:18:24 +0000
parents 13f53ecc8bb5
children a1cd5abcb38b
line wrap: on
line diff
--- a/data/model/AlignmentModel.cpp	Tue Mar 03 09:33:59 2015 +0000
+++ b/data/model/AlignmentModel.cpp	Tue Mar 03 15:18:24 2015 +0000
@@ -37,8 +37,8 @@
         connect(m_rawPath, SIGNAL(modelChanged()),
                 this, SLOT(pathChanged()));
 
-        connect(m_rawPath, SIGNAL(modelChangedWithin(int, int)),
-                this, SLOT(pathChangedWithin(int, int)));
+        connect(m_rawPath, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)),
+                this, SLOT(pathChangedWithin(sv_frame_t, sv_frame_t)));
         
         connect(m_rawPath, SIGNAL(completionChanged()),
                 this, SLOT(pathCompletionChanged()));
@@ -74,19 +74,19 @@
     else return true;
 }
 
-int
+sv_frame_t
 AlignmentModel::getStartFrame() const
 {
-    int a = m_reference->getStartFrame();
-    int b = m_aligned->getStartFrame();
+    sv_frame_t a = m_reference->getStartFrame();
+    sv_frame_t b = m_aligned->getStartFrame();
     return std::min(a, b);
 }
 
-int
+sv_frame_t
 AlignmentModel::getEndFrame() const
 {
-    int a = m_reference->getEndFrame();
-    int b = m_aligned->getEndFrame();
+    sv_frame_t a = m_reference->getEndFrame();
+    sv_frame_t b = m_aligned->getEndFrame();
     return std::max(a, b);
 }
 
@@ -144,8 +144,8 @@
     return m_aligned;
 }
 
-int
-AlignmentModel::toReference(int frame) const
+sv_frame_t
+AlignmentModel::toReference(sv_frame_t frame) const
 {
 #ifdef DEBUG_ALIGNMENT_MODEL
     SVDEBUG << "AlignmentModel::toReference(" << frame << ")" << endl;
@@ -157,8 +157,8 @@
     return align(m_path, frame);
 }
 
-int
-AlignmentModel::fromReference(int frame) const
+sv_frame_t
+AlignmentModel::fromReference(sv_frame_t frame) const
 {
 #ifdef DEBUG_ALIGNMENT_MODEL
     SVDEBUG << "AlignmentModel::fromReference(" << frame << ")" << endl;
@@ -182,7 +182,7 @@
 }
 
 void
-AlignmentModel::pathChangedWithin(int, int)
+AlignmentModel::pathChangedWithin(sv_frame_t, sv_frame_t)
 {
     if (!m_pathComplete) return;
     constructPath();
@@ -242,9 +242,9 @@
         
     for (SparseTimeValueModel::PointList::const_iterator i = points.begin();
          i != points.end(); ++i) {
-        long frame = i->frame;
-        float value = i->value;
-        long rframe = lrintf(value * m_aligned->getSampleRate());
+        sv_frame_t frame = i->frame;
+        double value = i->value;
+        sv_frame_t rframe = lrint(value * m_aligned->getSampleRate());
         m_path->addPoint(PathPoint(frame, rframe));
     }
 
@@ -274,8 +274,8 @@
         
     for (PathModel::PointList::const_iterator i = points.begin();
          i != points.end(); ++i) {
-        long frame = i->frame;
-        long rframe = i->mapframe;
+        sv_frame_t frame = i->frame;
+        sv_frame_t rframe = i->mapframe;
         m_reversePath->addPoint(PathPoint(rframe, frame));
     }
 
@@ -284,8 +284,8 @@
 #endif
 }
 
-int
-AlignmentModel::align(PathModel *path, int frame) const
+sv_frame_t
+AlignmentModel::align(PathModel *path, sv_frame_t frame) const
 {
     if (!path) return frame;
 
@@ -315,13 +315,13 @@
 #endif
         --i;
     }
-    while (i != points.begin() && i->frame > long(frame)) --i;
+    while (i != points.begin() && i->frame > frame) --i;
 
-    long foundFrame = i->frame;
-    long foundMapFrame = i->mapframe;
+    sv_frame_t foundFrame = i->frame;
+    sv_frame_t foundMapFrame = i->mapframe;
 
-    long followingFrame = foundFrame;
-    long followingMapFrame = foundMapFrame;
+    sv_frame_t followingFrame = foundFrame;
+    sv_frame_t followingMapFrame = foundMapFrame;
 
     if (++i != points.end()) {
 #ifdef DEBUG_ALIGNMENT_MODEL
@@ -337,13 +337,13 @@
 
     if (foundMapFrame < 0) return 0;
 
-    int resultFrame = foundMapFrame;
+    sv_frame_t resultFrame = foundMapFrame;
 
-    if (followingFrame != foundFrame && long(frame) > foundFrame) {
-        float interp =
-            float(frame - foundFrame) /
-            float(followingFrame - foundFrame);
-        resultFrame += lrintf((followingMapFrame - foundMapFrame) * interp);
+    if (followingFrame != foundFrame && frame > foundFrame) {
+        double interp =
+            double(frame - foundFrame) /
+            double(followingFrame - foundFrame);
+        resultFrame += lrint(double(followingMapFrame - foundMapFrame) * interp);
     }
 
 #ifdef DEBUG_ALIGNMENT_MODEL