changeset 990:dc1695b90a58

Add milliseconds as CSV import timing option
author Chris Cannam
date Fri, 03 Oct 2014 15:09:27 +0100 (2014-10-03)
parents 58c4d69b4dd8
children 1974859baba5
files data/fileio/CSVFileReader.cpp data/fileio/CSVFormat.h
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/CSVFileReader.cpp	Wed Oct 01 14:06:28 2014 +0100
+++ b/data/fileio/CSVFileReader.cpp	Fri Oct 03 15:09:27 2014 +0100
@@ -101,6 +101,12 @@
         double time = numeric.toDouble(&ok);
         if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok);
         calculatedFrame = int(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);
         
     } else {
         
@@ -149,7 +155,8 @@
         } else {
             windowSize = 1;
         }
-	if (timeUnits == CSVFormat::TimeSeconds) {
+	if (timeUnits == CSVFormat::TimeSeconds ||
+            timeUnits == CSVFormat::TimeMilliseconds) {
 	    sampleRate = m_mainModelSampleRate;
 	}
     }
--- a/data/fileio/CSVFormat.h	Wed Oct 01 14:06:28 2014 +0100
+++ b/data/fileio/CSVFormat.h	Fri Oct 03 15:09:27 2014 +0100
@@ -37,8 +37,9 @@
 
     enum TimeUnits {
 	TimeSeconds,
+        TimeMilliseconds,
 	TimeAudioFrames,
-	TimeWindows
+	TimeWindows,
     };
 
     enum ColumnPurpose {