MCPcopy Create free account
hub / github.com/adamstark/AudioFile / test16Bit44100WithInteger

Function test16Bit44100WithInteger

tests/WavLoadingTests.cpp:333–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331 //=============================================================
332 template <typename T>
333 void test16Bit44100WithInteger (bool expectFailure = false)
334 {
335 AudioFile<T> audioFile;
336
337 if (expectFailure)
338 audioFile.shouldLogErrorsToConsole (false);
339
340 bool loadedOK = audioFile.load (projectBuildDirectory + "/test-audio/wav_stereo_16bit_44100.wav");
341
342 if (expectFailure)
343 {
344 CHECK_EQ (loadedOK, false);
345 return;
346 }
347
348 CHECK (loadedOK);
349 CHECK_EQ (audioFile.getNumSamplesPerChannel(), wav_stereo_16bit_44100::numSamplesPerChannel);
350 CHECK_EQ (audioFile.getBitDepth(), wav_stereo_16bit_44100::bitDepth);
351 CHECK_EQ (audioFile.getSampleRate(), wav_stereo_16bit_44100::sampleRate);
352 CHECK_EQ (audioFile.getNumChannels(), static_cast<int> (wav_stereo_16bit_44100::testBuffer.size()));
353
354 int offset = std::is_signed_v<T> ? 0 : 32768;
355
356 for (size_t i = 0; i < wav_stereo_16bit_44100::testBuffer[0].size(); i++)
357 {
358 for (int k = 0; k < audioFile.getNumChannels(); k++)
359 {
360 REQUIRE_EQ (audioFile.samples[k][i], std::round (wav_stereo_16bit_44100::testBuffer[k][i] * 32767 + offset));
361 }
362 }
363 }
364
365 //=============================================================
366 TEST_CASE ("WavLoadingTests_Stereo_16bit_44100_integers")

Callers

nothing calls this directly

Calls 6

loadMethod · 0.80
getBitDepthMethod · 0.80
getSampleRateMethod · 0.80
getNumChannelsMethod · 0.80

Tested by

no test coverage detected