diff --git a/tests/AudioFilesT.cpp b/tests/AudioFilesT.cpp new file mode 100644 index 00000000..8046ca71 --- /dev/null +++ b/tests/AudioFilesT.cpp @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#include "AudioSpan.h" +#include "sfizz/Synth.h" +#include "TestHelpers.h" +#include "catch2/catch.hpp" +#include +using namespace Catch::literals; + +TEST_CASE("[AudioFiles] WavPack file") +{ + sfz::Synth synth; + sfz::AudioBuffer buffer { 2, static_cast(synth.getSamplesPerBlock()) }; + sfz::AudioSpan span { buffer }; + synth.loadSfzString(fs::current_path() / "tests/TestFiles/wavpack.sfz", R"( + sample=kick.wav key=60 pan=-100 + sample=kick.wv key=60 pan=100 + )"); + synth.noteOn(0, 60, 127); + synth.renderBlock(buffer); + REQUIRE( numPlayingVoices(synth) == 2 ); + REQUIRE( approxEqual(span.getConstSpan(0), span.getConstSpan(1)) ); + while (numPlayingVoices(synth) > 0) { + synth.renderBlock(buffer); + REQUIRE( approxEqual(span.getConstSpan(0), span.getConstSpan(1)) ); + } +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8553aca9..db17ba1d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -57,6 +57,7 @@ set(SFIZZ_TEST_SOURCES MessagingT.cpp OversamplerT.cpp MemoryT.cpp + AudioFilesT.cpp DataHelpers.h DataHelpers.cpp ) diff --git a/tests/TestFiles/kick.wv b/tests/TestFiles/kick.wv new file mode 100644 index 00000000..a00e5d9f Binary files /dev/null and b/tests/TestFiles/kick.wv differ