From 09c9256b921fae672a8623f0dc563a57321030ed Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Mon, 7 Aug 2023 22:13:34 +0200 Subject: [PATCH] Enable the test --- tests/AudioFilesT.cpp | 51 +++++++++++++++++++++++++++++++++++++++---- tests/FilesT.cpp | 39 --------------------------------- 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/tests/AudioFilesT.cpp b/tests/AudioFilesT.cpp index 8e326b9f..9cd9dfc2 100644 --- a/tests/AudioFilesT.cpp +++ b/tests/AudioFilesT.cpp @@ -59,10 +59,10 @@ struct CompareOutputOpts /** * @brief Compare the outputs of 2 sfz files with a given set of options, for a single note pressed. - * - * @param lFile - * @param rFile - * @param opts + * + * @param lFile + * @param rFile + * @param opts */ void compareOutputs(const std::string& lFile, const std::string& rFile, CompareOutputOpts opts) { @@ -143,3 +143,46 @@ TEST_CASE("[AudioFiles] Flac file (resampled)") opts.sampleRate = 48000.0f; compareOutputs(lFile, rFile, opts); } + +TEST_CASE("[Files] Embedded sample data") +{ + sfz::Synth synth1; + sfz::Synth synth2; + + synth1.enableFreeWheeling(); + synth2.enableFreeWheeling(); + + synth1.setSamplesPerBlock(256); + synth2.setSamplesPerBlock(256); + + synth1.loadSfzFile(fs::current_path() / "tests/TestFiles/kick.sfz"); + synth2.loadSfzFile(fs::current_path() / "tests/TestFiles/kick_embedded.sfz"); + + REQUIRE(synth1.getNumPreloadedSamples() == 1); + REQUIRE(synth2.getNumPreloadedSamples() == 1); + + sfz::AudioBuffer buffer1 { 2, 256 }; + sfz::AudioBuffer buffer2 { 2, 256 }; + std::vector tmp1 (buffer1.getNumFrames()); + std::vector tmp2 (buffer2.getNumFrames()); + + synth1.noteOn(0, 60, 100); + synth2.noteOn(0, 60, 100); + + for (unsigned i = 0; i < 100; ++i) { + synth1.renderBlock(buffer1); + synth2.renderBlock(buffer2); + + const auto left1 = buffer1.getConstSpan(0); + const auto left2 = buffer2.getConstSpan(0); + std::copy(left1.begin(), left1.end(), tmp1.begin()); + std::copy(left2.begin(), left2.end(), tmp2.begin()); + REQUIRE(tmp1 == tmp2); + + const auto right1 = buffer1.getConstSpan(0); + const auto right2 = buffer2.getConstSpan(0); + std::copy(right1.begin(), right1.end(), tmp1.begin()); + std::copy(right2.begin(), right2.end(), tmp2.begin()); + REQUIRE(tmp1 == tmp2); + } +} diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index 7ab1a2f9..140d67cd 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -779,45 +779,6 @@ TEST_CASE("[Files] Unused samples are cleared on reloading") REQUIRE(synth.getNumPreloadedSamples() == 0); } -// FIXME: -// this breaks on Github win32/win64/linux CI "sometimes" -// but I can't reproduce it reliably. -#if !defined(_WIN32) && !defined(_WIN64) && !defined(__APPLE__) -TEST_CASE("[Files] Embedded sample data") -{ - sfz::Synth synth1; - sfz::Synth synth2; - synth1.loadSfzFile(fs::current_path() / "tests/TestFiles/kick.sfz"); - synth2.loadSfzFile(fs::current_path() / "tests/TestFiles/kick_embedded.sfz"); - REQUIRE(synth1.getNumPreloadedSamples() == 1); - REQUIRE(synth2.getNumPreloadedSamples() == 1); - - AudioBuffer buffer1 { 2, 256 }; - AudioBuffer buffer2 { 2, 256 }; - std::vector tmp1 (buffer1.getNumFrames()); - std::vector tmp2 (buffer2.getNumFrames()); - - synth1.noteOn(0, 60, 100); - synth2.noteOn(0, 60, 100); - - for (unsigned i = 0; i < 100; ++i) { - synth1.renderBlock(buffer1); - synth2.renderBlock(buffer2); - - const auto left1 = buffer1.getConstSpan(0); - const auto left2 = buffer2.getConstSpan(0); - std::copy(left1.begin(), left1.end(), tmp1.begin()); - std::copy(left2.begin(), left2.end(), tmp2.begin()); - REQUIRE(tmp1 == tmp2); - - const auto right1 = buffer1.getConstSpan(0); - const auto right2 = buffer2.getConstSpan(0); - std::copy(right1.begin(), right1.end(), tmp1.begin()); - std::copy(right2.begin(), right2.end(), tmp2.begin()); - REQUIRE(tmp1 == tmp2); - } -} -#endif TEST_CASE("[Files] Key center from audio file, with embedded sample data") { sfz::Synth synth;