comparison data/fileio/test/AudioFileReaderTest.h @ 1428:87ae75da6527

Convert some cerrs to SVCERRs. Apart from anything else, this makes MSVC2017 happy
author Chris Cannam
date Thu, 01 Mar 2018 14:43:40 +0000
parents aadfb395e933
children 48e9f538e6e9
comparison
equal deleted inserted replaced
1427:622d193a00dc 1428:87ae75da6527
186 private slots: 186 private slots:
187 void init() 187 void init()
188 { 188 {
189 if (!QDir(audioDir).exists()) { 189 if (!QDir(audioDir).exists()) {
190 QString cwd = QDir::currentPath(); 190 QString cwd = QDir::currentPath();
191 cerr << "ERROR: Audio test file directory \"" << audioDir << "\" does not exist (cwd = " << cwd << ")" << endl; 191 SVCERR << "ERROR: Audio test file directory \"" << audioDir << "\" does not exist (cwd = " << cwd << ")" << endl;
192 QVERIFY2(QDir(audioDir).exists(), "Audio test file directory not found"); 192 QVERIFY2(QDir(audioDir).exists(), "Audio test file directory not found");
193 } 193 }
194 if (!QDir(diffDir).exists() && !QDir().mkpath(diffDir)) { 194 if (!QDir(diffDir).exists() && !QDir().mkpath(diffDir)) {
195 cerr << "ERROR: Audio diff directory \"" << diffDir << "\" does not exist and could not be created" << endl; 195 SVCERR << "ERROR: Audio diff directory \"" << diffDir << "\" does not exist and could not be created" << endl;
196 QVERIFY2(QDir(diffDir).exists(), "Audio diff directory not found and could not be created"); 196 QVERIFY2(QDir(diffDir).exists(), "Audio diff directory not found and could not be created");
197 } 197 }
198 } 198 }
199 199
200 void read_data() 200 void read_data()
424 int maxIndex = 0; 424 int maxIndex = 0;
425 425
426 for (int i = 0; i < refFrames; ++i) { 426 for (int i = 0; i < refFrames; ++i) {
427 int ix = i + offset; 427 int ix = i + offset;
428 if (ix >= read) { 428 if (ix >= read) {
429 cerr << "ERROR: audiofile " << audiofile << " reads truncated (read-rate reference frames " << i << " onward, of " << refFrames << ", are lost)" << endl; 429 SVCERR << "ERROR: audiofile " << audiofile << " reads truncated (read-rate reference frames " << i << " onward, of " << refFrames << ", are lost)" << endl;
430 QVERIFY(ix < read); 430 QVERIFY(ix < read);
431 } 431 }
432 432
433 if (ix + discard >= read) { 433 if (ix + discard >= read) {
434 // we forgive the very edge samples when 434 // we forgive the very edge samples when
463 cerr << "channel " << c << ": mean diff " << meanDiff << endl; 463 cerr << "channel " << c << ": mean diff " << meanDiff << endl;
464 cerr << "channel " << c << ": rms diff " << rmsDiff << endl; 464 cerr << "channel " << c << ": rms diff " << rmsDiff << endl;
465 cerr << "channel " << c << ": max diff " << maxDiff << " at " << maxIndex << endl; 465 cerr << "channel " << c << ": max diff " << maxDiff << " at " << maxIndex << endl;
466 */ 466 */
467 if (rmsDiff >= rmsLimit) { 467 if (rmsDiff >= rmsLimit) {
468 cerr << "ERROR: for audiofile " << audiofile << ": RMS diff = " << rmsDiff << " for channel " << c << " (limit = " << rmsLimit << ")" << endl; 468 SVCERR << "ERROR: for audiofile " << audiofile << ": RMS diff = " << rmsDiff << " for channel " << c << " (limit = " << rmsLimit << ")" << endl;
469 QVERIFY(rmsDiff < rmsLimit); 469 QVERIFY(rmsDiff < rmsLimit);
470 } 470 }
471 if (maxDiff >= maxLimit) { 471 if (maxDiff >= maxLimit) {
472 cerr << "ERROR: for audiofile " << audiofile << ": max diff = " << maxDiff << " at frame " << maxIndex << " of " << read << " on channel " << c << " (limit = " << maxLimit << ", edge limit = " << edgeLimit << ", mean diff = " << meanDiff << ", rms = " << rmsDiff << ")" << endl; 472 SVCERR << "ERROR: for audiofile " << audiofile << ": max diff = " << maxDiff << " at frame " << maxIndex << " of " << read << " on channel " << c << " (limit = " << maxLimit << ", edge limit = " << edgeLimit << ", mean diff = " << meanDiff << ", rms = " << rmsDiff << ")" << endl;
473 QVERIFY(maxDiff < maxLimit); 473 QVERIFY(maxDiff < maxLimit);
474 } 474 }
475 475
476 // and check for spurious material at end 476 // and check for spurious material at end
477 477
478 for (sv_frame_t i = refFrames; i + offset < read; ++i) { 478 for (sv_frame_t i = refFrames; i + offset < read; ++i) {
479 sv_frame_t ix = i + offset; 479 sv_frame_t ix = i + offset;
480 float quiet = 0.1f; //!!! allow some ringing - but let's come back to this, it should tail off 480 float quiet = 0.1f; //!!! allow some ringing - but let's come back to this, it should tail off
481 float mag = fabsf(test[ix * channels + c]); 481 float mag = fabsf(test[ix * channels + c]);
482 if (mag > quiet) { 482 if (mag > quiet) {
483 cerr << "ERROR: audiofile " << audiofile << " contains spurious data after end of reference (found sample " << test[ix * channels + c] << " at index " << ix << " of channel " << c << " after reference+offset ended at " << refFrames+offset << ")" << endl; 483 SVCERR << "ERROR: audiofile " << audiofile << " contains spurious data after end of reference (found sample " << test[ix * channels + c] << " at index " << ix << " of channel " << c << " after reference+offset ended at " << refFrames+offset << ")" << endl;
484 QVERIFY(mag < quiet); 484 QVERIFY(mag < quiet);
485 } 485 }
486 } 486 }
487 } 487 }
488 } 488 }