comparison data/fileio/CSVFileReader.cpp @ 990:dc1695b90a58

Add milliseconds as CSV import timing option
author Chris Cannam
date Fri, 03 Oct 2014 15:09:27 +0100
parents fae5689f7e27
children e369dd281cf2
comparison
equal deleted inserted replaced
988:58c4d69b4dd8 990:dc1695b90a58
99 if (timeUnits == CSVFormat::TimeSeconds) { 99 if (timeUnits == CSVFormat::TimeSeconds) {
100 100
101 double time = numeric.toDouble(&ok); 101 double time = numeric.toDouble(&ok);
102 if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok); 102 if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok);
103 calculatedFrame = int(time * sampleRate + 0.5); 103 calculatedFrame = int(time * sampleRate + 0.5);
104
105 } else if (timeUnits == CSVFormat::TimeMilliseconds) {
106
107 double time = numeric.toDouble(&ok);
108 if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok);
109 calculatedFrame = int((time / 1000.0) * sampleRate + 0.5);
104 110
105 } else { 111 } else {
106 112
107 long n = numeric.toLong(&ok); 113 long n = numeric.toLong(&ok);
108 if (n >= 0) calculatedFrame = n; 114 if (n >= 0) calculatedFrame = n;
147 // that's likely to be visible 153 // that's likely to be visible
148 windowSize = 1024; 154 windowSize = 1024;
149 } else { 155 } else {
150 windowSize = 1; 156 windowSize = 1;
151 } 157 }
152 if (timeUnits == CSVFormat::TimeSeconds) { 158 if (timeUnits == CSVFormat::TimeSeconds ||
159 timeUnits == CSVFormat::TimeMilliseconds) {
153 sampleRate = m_mainModelSampleRate; 160 sampleRate = m_mainModelSampleRate;
154 } 161 }
155 } 162 }
156 163
157 SparseOneDimensionalModel *model1 = 0; 164 SparseOneDimensionalModel *model1 = 0;