comparison data/fileio/CSVFormat.cpp @ 1521:2d291eac9f21 import-audio-data

Ignore non-value columns when guessing sample range
author Chris Cannam
date Wed, 12 Sep 2018 15:27:30 +0100
parents ffec849858a7
children c1b2eab6ac51
comparison
equal deleted inserted replaced
1520:954d0cf29ca7 1521:2d291eac9f21
358 AudioSampleRange range = SampleRangeSigned1; 358 AudioSampleRange range = SampleRangeSigned1;
359 359
360 range = SampleRangeSigned1; 360 range = SampleRangeSigned1;
361 bool knownSigned = false; 361 bool knownSigned = false;
362 bool knownNonIntegral = false; 362 bool knownNonIntegral = false;
363
364 SVDEBUG << "CSVFormat::guessAudioSampleRange: starting with assumption of "
365 << range << endl;
363 366
364 for (int i = 0; i < m_columnCount; ++i) { 367 for (int i = 0; i < m_columnCount; ++i) {
368 if (m_columnPurposes[i] != ColumnValue) {
369 SVDEBUG << "... column " << i
370 << " is not apparently a value, ignoring" << endl;
371 continue;
372 }
365 if (!(m_columnQualities[i] & ColumnIntegral)) { 373 if (!(m_columnQualities[i] & ColumnIntegral)) {
366 knownNonIntegral = true; 374 knownNonIntegral = true;
367 if (range == SampleRangeUnsigned255 || 375 if (range == SampleRangeUnsigned255 ||
368 range == SampleRangeSigned32767) { 376 range == SampleRangeSigned32767) {
369 range = SampleRangeOther; 377 range = SampleRangeOther;
370 } 378 }
379 SVDEBUG << "... column " << i
380 << " is non-integral, updating range to " << range << endl;
371 } 381 }
372 if (m_columnQualities[i] & ColumnLarge) { 382 if (m_columnQualities[i] & ColumnLarge) {
373 if (range == SampleRangeSigned1 || 383 if (range == SampleRangeSigned1 ||
374 range == SampleRangeUnsigned255) { 384 range == SampleRangeUnsigned255) {
375 if (knownNonIntegral) { 385 if (knownNonIntegral) {
376 range = SampleRangeOther; 386 range = SampleRangeOther;
377 } else { 387 } else {
378 range = SampleRangeSigned32767; 388 range = SampleRangeSigned32767;
379 } 389 }
380 } 390 }
391 SVDEBUG << "... column " << i << " is large, updating range to "
392 << range << endl;
381 } 393 }
382 if (m_columnQualities[i] & ColumnSigned) { 394 if (m_columnQualities[i] & ColumnSigned) {
383 knownSigned = true; 395 knownSigned = true;
384 if (range == SampleRangeUnsigned255) { 396 if (range == SampleRangeUnsigned255) {
385 range = SampleRangeSigned32767; 397 range = SampleRangeSigned32767;
386 } 398 }
399 SVDEBUG << "... column " << i << " is signed, updating range to "
400 << range << endl;
387 } 401 }
388 if (!(m_columnQualities[i] & ColumnSmall)) { 402 if (!(m_columnQualities[i] & ColumnSmall)) {
389 if (range == SampleRangeSigned1) { 403 if (range == SampleRangeSigned1) {
390 if (knownNonIntegral) { 404 if (knownNonIntegral) {
391 range = SampleRangeOther; 405 range = SampleRangeOther;
393 range = SampleRangeSigned32767; 407 range = SampleRangeSigned32767;
394 } else { 408 } else {
395 range = SampleRangeUnsigned255; 409 range = SampleRangeUnsigned255;
396 } 410 }
397 } 411 }
398 } 412 SVDEBUG << "... column " << i << " is not small, updating range to "
399 } 413 << range << endl;
400 414 }
415 }
416
417 SVDEBUG << "CSVFormat::guessAudioSampleRange: ended up with range "
418 << range << endl;
419
401 m_audioSampleRange = range; 420 m_audioSampleRange = range;
402 } 421 }
403 422
404 CSVFormat::ColumnPurpose 423 CSVFormat::ColumnPurpose
405 CSVFormat::getColumnPurpose(int i) 424 CSVFormat::getColumnPurpose(int i)