comparison data/fileio/test/AudioFileReaderTest.h @ 1429:48e9f538e6e9

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 87ae75da6527
children d2555df635ec
comparison
equal deleted inserted replaced
1428:87ae75da6527 1429:48e9f538e6e9
252 AudioFileReaderFactory::Normalisation::None); 252 AudioFileReaderFactory::Normalisation::None);
253 params.gaplessMode = (gapless ? 253 params.gaplessMode = (gapless ?
254 AudioFileReaderFactory::GaplessMode::Gapless : 254 AudioFileReaderFactory::GaplessMode::Gapless :
255 AudioFileReaderFactory::GaplessMode::Gappy); 255 AudioFileReaderFactory::GaplessMode::Gappy);
256 256
257 AudioFileReader *reader = 257 AudioFileReader *reader =
258 AudioFileReaderFactory::createReader 258 AudioFileReaderFactory::createReader
259 (audioDir + "/" + format + "/" + audiofile, params); 259 (audioDir + "/" + format + "/" + audiofile, params);
260 260
261 if (!reader) { 261 if (!reader) {
262 #if ( QT_VERSION >= 0x050000 ) 262 #if ( QT_VERSION >= 0x050000 )
263 QSKIP("Unsupported file, skipping"); 263 QSKIP("Unsupported file, skipping");
264 #else 264 #else
265 QSKIP("Unsupported file, skipping", SkipSingle); 265 QSKIP("Unsupported file, skipping", SkipSingle);
266 #endif 266 #endif
267 } 267 }
268 268
269 QString extension; 269 QString extension;
270 sv_samplerate_t fileRate; 270 sv_samplerate_t fileRate;
271 int channels; 271 int channels;
272 int fileBitdepth; 272 int fileBitdepth;
274 274
275 QCOMPARE((int)reader->getChannelCount(), channels); 275 QCOMPARE((int)reader->getChannelCount(), channels);
276 QCOMPARE(reader->getNativeRate(), fileRate); 276 QCOMPARE(reader->getNativeRate(), fileRate);
277 QCOMPARE(reader->getSampleRate(), readRate); 277 QCOMPARE(reader->getSampleRate(), readRate);
278 278
279 AudioTestData tdata(readRate, channels); 279 AudioTestData tdata(readRate, channels);
280 280
281 float *reference = tdata.getInterleavedData(); 281 float *reference = tdata.getInterleavedData();
282 sv_frame_t refFrames = tdata.getFrameCount(); 282 sv_frame_t refFrames = tdata.getFrameCount();
283 283
284 // The reader should give us exactly the expected number of 284 // The reader should give us exactly the expected number of
285 // frames, except for mp3/aac files. We ask for quite a lot 285 // frames, except for mp3/aac files. We ask for quite a lot
286 // more, though, so we can (a) check that we only get the 286 // more, though, so we can (a) check that we only get the
287 // expected number back (if this is not mp3/aac) or (b) take 287 // expected number back (if this is not mp3/aac) or (b) take
288 // into account silence at beginning and end (if it is). 288 // into account silence at beginning and end (if it is).
289 floatvec_t test = reader->getInterleavedFrames(0, refFrames + 5000); 289 floatvec_t test = reader->getInterleavedFrames(0, refFrames + 5000);
290 290
291 delete reader; 291 delete reader;
292 reader = 0; 292 reader = 0;
293 293
294 sv_frame_t read = test.size() / channels; 294 sv_frame_t read = test.size() / channels;
295 295
296 bool perceptual = (extension == "mp3" || 296 bool perceptual = (extension == "mp3" ||
297 extension == "aac" || 297 extension == "aac" ||
298 extension == "m4a"); 298 extension == "m4a");
299 299
459 double meanDiff = totalDiff / double(refFrames); 459 double meanDiff = totalDiff / double(refFrames);
460 double rmsDiff = sqrt(totalSqrDiff / double(refFrames)); 460 double rmsDiff = sqrt(totalSqrDiff / double(refFrames));
461 461
462 /* 462 /*
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 SVCERR << "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 }
482 if (mag > quiet) { 482 if (mag > quiet) {
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; 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 }
489 }; 489 };
490 490
491 #endif 491 #endif