comparison data/model/Labeller.h @ 1046:2f49be7d4264 cxx11

More type fixes
author Chris Cannam
date Tue, 10 Mar 2015 13:22:10 +0000
parents 59e7fe1b1003
children 22f66068b464
comparison
equal deleted inserted replaced
1045:1a73618b0b67 1046:2f49be7d4264
130 m_dp *= 10; 130 m_dp *= 10;
131 } 131 }
132 if (m_counter > m_cycle) m_counter = 1; 132 if (m_counter > m_cycle) m_counter = 1;
133 } 133 }
134 134
135 void setSampleRate(float rate) { m_rate = rate; } 135 void setSampleRate(sv_samplerate_t rate) { m_rate = rate; }
136 136
137 void resetCounters() { 137 void resetCounters() {
138 m_counter = 1; 138 m_counter = 1;
139 m_counter2 = 1; 139 m_counter2 = 1;
140 m_cycle = 4; 140 m_cycle = 4;
260 value = 0; 260 value = 0;
261 break; 261 break;
262 262
263 case ValueFromSimpleCounter: 263 case ValueFromSimpleCounter:
264 case ValueFromCyclicalCounter: 264 case ValueFromCyclicalCounter:
265 value = m_counter; 265 value = float(m_counter);
266 incrementCounter(); 266 incrementCounter();
267 break; 267 break;
268 268
269 case ValueFromTwoLevelCounter: 269 case ValueFromTwoLevelCounter:
270 value = m_counter2 + double(m_counter) / double(m_dp); 270 value = float(m_counter2 + double(m_counter) / double(m_dp));
271 incrementCounter(); 271 incrementCounter();
272 break; 272 break;
273 273
274 case ValueFromFrameNumber: 274 case ValueFromFrameNumber:
275 value = newPoint.frame; 275 value = float(newPoint.frame);
276 break; 276 break;
277 277
278 case ValueFromRealTime: 278 case ValueFromRealTime:
279 if (m_rate == 0.f) { 279 if (m_rate == 0.0) {
280 std::cerr << "ERROR: Labeller::getValueFor: Real-time conversion required, but no sample rate set" << std::endl; 280 std::cerr << "ERROR: Labeller::getValueFor: Real-time conversion required, but no sample rate set" << std::endl;
281 } else { 281 } else {
282 value = float(newPoint.frame) / float(m_rate); 282 value = float(double(newPoint.frame) / m_rate);
283 } 283 }
284 break; 284 break;
285 285
286 case ValueFromDurationToNext: 286 case ValueFromDurationToNext:
287 case ValueFromTempoToNext: 287 case ValueFromTempoToNext:
288 case ValueFromDurationFromPrevious: 288 case ValueFromDurationFromPrevious:
289 case ValueFromTempoFromPrevious: 289 case ValueFromTempoFromPrevious:
290 if (m_rate == 0.f) { 290 if (m_rate == 0.0) {
291 std::cerr << "ERROR: Labeller::getValueFor: Real-time conversion required, but no sample rate set" << std::endl; 291 std::cerr << "ERROR: Labeller::getValueFor: Real-time conversion required, but no sample rate set" << std::endl;
292 } else if (!prevPoint) { 292 } else if (!prevPoint) {
293 std::cerr << "ERROR: Labeller::getValueFor: Time difference required, but only one point provided" << std::endl; 293 std::cerr << "ERROR: Labeller::getValueFor: Time difference required, but only one point provided" << std::endl;
294 } else { 294 } else {
295 int f0 = prevPoint->frame, f1 = newPoint.frame; 295 sv_frame_t f0 = prevPoint->frame, f1 = newPoint.frame;
296 if (m_type == ValueFromDurationToNext || 296 if (m_type == ValueFromDurationToNext ||
297 m_type == ValueFromDurationFromPrevious) { 297 m_type == ValueFromDurationFromPrevious) {
298 value = float(f1 - f0) / m_rate; 298 value = float(double(f1 - f0) / m_rate);
299 } else { 299 } else {
300 if (f1 > f0) { 300 if (f1 > f0) {
301 value = (60.f * m_rate) / (f1 - f0); 301 value = float((60.0 * m_rate) / double(f1 - f0));
302 } 302 }
303 } 303 }
304 } 304 }
305 break; 305 break;
306 306
311 break; 311 break;
312 312
313 case ValueFromLabel: 313 case ValueFromLabel:
314 if (newPoint.label != "") { 314 if (newPoint.label != "") {
315 // more forgiving than QString::toFloat() 315 // more forgiving than QString::toFloat()
316 value = atof(newPoint.label.toLocal8Bit()); 316 value = float(atof(newPoint.label.toLocal8Bit()));
317 } else { 317 } else {
318 value = 0.f; 318 value = 0.f;
319 } 319 }
320 break; 320 break;
321 } 321 }
326 ValueType m_type; 326 ValueType m_type;
327 int m_counter; 327 int m_counter;
328 int m_counter2; 328 int m_counter2;
329 int m_cycle; 329 int m_cycle;
330 int m_dp; 330 int m_dp;
331 float m_rate; 331 sv_samplerate_t m_rate;
332 }; 332 };
333 333
334 #endif 334 #endif