diff data/fileio/CSVFileReader.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 920699b6989d
children 26cf6d5251ec
line wrap: on
line diff
--- a/data/fileio/CSVFileReader.cpp	Tue Mar 03 09:33:59 2015 +0000
+++ b/data/fileio/CSVFileReader.cpp	Tue Mar 03 15:18:24 2015 +0000
@@ -95,7 +95,7 @@
     return m_error;
 }
 
-int
+sv_frame_t
 CSVFileReader::convertTimeValue(QString s, int lineno, int sampleRate,
                                 int windowSize) const
 {
@@ -104,7 +104,7 @@
 
     CSVFormat::TimeUnits timeUnits = m_format.getTimeUnits();
 
-    int calculatedFrame = 0;
+    sv_frame_t calculatedFrame = 0;
 
     bool ok = false;
     QString numeric = s;
@@ -114,13 +114,13 @@
 
         double time = numeric.toDouble(&ok);
         if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok);
-        calculatedFrame = int(time * sampleRate + 0.5);
+        calculatedFrame = sv_frame_t(time * sampleRate + 0.5);
     
     } else if (timeUnits == CSVFormat::TimeMilliseconds) {
 
         double time = numeric.toDouble(&ok);
         if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok);
-        calculatedFrame = int((time / 1000.0) * sampleRate + 0.5);
+        calculatedFrame = sv_frame_t((time / 1000.0) * sampleRate + 0.5);
         
     } else {
         
@@ -189,15 +189,15 @@
 
     float min = 0.0, max = 0.0;
 
-    int frameNo = 0;
-    int duration = 0;
-    int endFrame = 0;
+    sv_frame_t frameNo = 0;
+    sv_frame_t duration = 0;
+    sv_frame_t endFrame = 0;
 
     bool haveAnyValue = false;
     bool haveEndTime = false;
     bool pitchLooksLikeMIDI = true;
 
-    int startFrame = 0; // for calculation of dense model resolution
+    sv_frame_t startFrame = 0; // for calculation of dense model resolution
     bool firstEverValue = true;
 
     std::map<QString, int> labelCountMap;
@@ -373,7 +373,7 @@
                         model3->setStartFrame(startFrame);
                     } else if (lineno == 1 &&
                                timingType == CSVFormat::ExplicitTiming) {
-                        model3->setResolution(frameNo - startFrame);
+                        model3->setResolution(int(frameNo - startFrame));
                     }
                     
                     firstEverValue = false;