comparison data/fileio/CSVFormat.cpp @ 1515:ffec849858a7 import-audio-data

Add sample-range support to CSVFormat
author Chris Cannam
date Fri, 07 Sep 2018 16:55:29 +0100
parents c9c2aa17439a
children 2d291eac9f21
comparison
equal deleted inserted replaced
1514:b7042aaecebe 1515:ffec849858a7
82 82
83 if (lineno >= 150) break; 83 if (lineno >= 150) break;
84 } 84 }
85 85
86 guessPurposes(); 86 guessPurposes();
87 guessAudioSampleRange();
87 } 88 }
88 89
89 void 90 void
90 CSVFormat::guessSeparator(QString line) 91 CSVFormat::guessSeparator(QString line)
91 { 92 {
349 SVDEBUG << "Estimated model type: " << m_modelType << endl; 350 SVDEBUG << "Estimated model type: " << m_modelType << endl;
350 SVDEBUG << "Estimated timing type: " << m_timingType << endl; 351 SVDEBUG << "Estimated timing type: " << m_timingType << endl;
351 SVDEBUG << "Estimated units: " << m_timeUnits << endl; 352 SVDEBUG << "Estimated units: " << m_timeUnits << endl;
352 } 353 }
353 354
355 void
356 CSVFormat::guessAudioSampleRange()
357 {
358 AudioSampleRange range = SampleRangeSigned1;
359
360 range = SampleRangeSigned1;
361 bool knownSigned = false;
362 bool knownNonIntegral = false;
363
364 for (int i = 0; i < m_columnCount; ++i) {
365 if (!(m_columnQualities[i] & ColumnIntegral)) {
366 knownNonIntegral = true;
367 if (range == SampleRangeUnsigned255 ||
368 range == SampleRangeSigned32767) {
369 range = SampleRangeOther;
370 }
371 }
372 if (m_columnQualities[i] & ColumnLarge) {
373 if (range == SampleRangeSigned1 ||
374 range == SampleRangeUnsigned255) {
375 if (knownNonIntegral) {
376 range = SampleRangeOther;
377 } else {
378 range = SampleRangeSigned32767;
379 }
380 }
381 }
382 if (m_columnQualities[i] & ColumnSigned) {
383 knownSigned = true;
384 if (range == SampleRangeUnsigned255) {
385 range = SampleRangeSigned32767;
386 }
387 }
388 if (!(m_columnQualities[i] & ColumnSmall)) {
389 if (range == SampleRangeSigned1) {
390 if (knownNonIntegral) {
391 range = SampleRangeOther;
392 } else if (knownSigned) {
393 range = SampleRangeSigned32767;
394 } else {
395 range = SampleRangeUnsigned255;
396 }
397 }
398 }
399 }
400
401 m_audioSampleRange = range;
402 }
403
354 CSVFormat::ColumnPurpose 404 CSVFormat::ColumnPurpose
355 CSVFormat::getColumnPurpose(int i) 405 CSVFormat::getColumnPurpose(int i)
356 { 406 {
357 while (m_columnPurposes.size() <= i) { 407 while (m_columnPurposes.size() <= i) {
358 m_columnPurposes.push_back(ColumnUnknown); 408 m_columnPurposes.push_back(ColumnUnknown);