From d90c5970b9682bf9491a8e8d69d0238a167be19d Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Tue, 11 Nov 2025 01:50:07 +0100 Subject: [PATCH 1/4] CMake: Add build include dir as public This is needed so that targets linking against the libspatialaudio target will properly get the build dir include when using the build interface. Without this, generated headers will not be found properly. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c665f8a..70cdafe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,8 +153,8 @@ target_sources(spatialaudio ) target_include_directories(spatialaudio - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/include + PUBLIC + $ ) target_compile_definitions(spatialaudio PRIVATE From 32195db5db4a3ebec6aafde50f9fbbfe85aa14d3 Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Tue, 11 Nov 2025 01:50:48 +0100 Subject: [PATCH 2/4] Tests: Add AmbisonicShelfFilters test --- tests/CMakeLists.txt | 1 + tests/TestAmbisonicShelfFilters.cpp | 46 +++++++++++++++++++++++++++++ tests/meson.build | 3 ++ 3 files changed, 50 insertions(+) create mode 100644 tests/TestAmbisonicShelfFilters.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 27a09aa..44df8a5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,3 +8,4 @@ function(spaudio_add_test name) endfunction() spaudio_add_test(TestInsideAngleRange) +spaudio_add_test(TestAmbisonicShelfFilters) diff --git a/tests/TestAmbisonicShelfFilters.cpp b/tests/TestAmbisonicShelfFilters.cpp new file mode 100644 index 0000000..980f22f --- /dev/null +++ b/tests/TestAmbisonicShelfFilters.cpp @@ -0,0 +1,46 @@ +#undef NDEBUG +#include +#include +#include +#include + +#include "AmbisonicShelfFilters.h" + +int main() { + spaudio::AmbisonicShelfFilters shelfFilters; + + spaudio::BFormat outputSignal; + constexpr size_t nSamples = 128; + constexpr unsigned order = 3; + constexpr bool b3D = true; + + outputSignal.Configure(order, b3D, nSamples); + outputSignal.Reset(); + + bool ret = shelfFilters.Configure(order, b3D, nSamples, 0); + assert(ret); + + std::array impulse; + std::vector> output(outputSignal.GetChannelCount(), std::vector(nSamples, 0.f)); + + impulse.fill(0.f); + impulse[0] = 1.f; + + for (unsigned i = 0; i < outputSignal.GetChannelCount(); ++i) + outputSignal.InsertStream(impulse.data(), i, nSamples); + + shelfFilters.Process(&outputSignal, nSamples); + + for (unsigned i = 0; i < outputSignal.GetChannelCount(); ++i) + outputSignal.ExtractStream(output[i].data(), i, nSamples); + + for (unsigned iSamp = 0; iSamp < nSamples; ++iSamp) { + std::cout << std::setw(4) << iSamp << ": "; + for (unsigned iCh = 0; iCh < outputSignal.GetChannelCount(); ++iCh) + { + std::cout << std::setw(12) << std::fixed << + output[iCh][iSamp] << std::setw(0) << ", "; + } + std::cout << std::endl; + } +} diff --git a/tests/meson.build b/tests/meson.build index b808767..d3b50ae 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -2,3 +2,6 @@ e = executable('TestInsideAngleRange', 'TestInsideAngleRange.cpp', dependencies: [libspatialaudio_dep]) test('TestInsideAngleRange', e) + +e = executable('TestAmbisonicShelfFilters', 'TestAmbisonicShelfFilters.cpp', dependencies: [libspatialaudio_dep]) +test('TestAmbisonicShelfFilters', e) From f5542c20e2d4b6a1f2915fd899570ff66a16d206 Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Tue, 11 Nov 2025 02:35:01 +0100 Subject: [PATCH 3/4] Tests: Add AmbisonicDecoderPresets test --- tests/CMakeLists.txt | 1 + tests/TestAmbisonicDecoderPresets.cpp | 60 +++++++++++++++++++++++++++ tests/meson.build | 3 ++ 3 files changed, 64 insertions(+) create mode 100644 tests/TestAmbisonicDecoderPresets.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 44df8a5..39b3455 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,3 +9,4 @@ endfunction() spaudio_add_test(TestInsideAngleRange) spaudio_add_test(TestAmbisonicShelfFilters) +spaudio_add_test(TestAmbisonicDecoderPresets) diff --git a/tests/TestAmbisonicDecoderPresets.cpp b/tests/TestAmbisonicDecoderPresets.cpp new file mode 100644 index 0000000..ae244f2 --- /dev/null +++ b/tests/TestAmbisonicDecoderPresets.cpp @@ -0,0 +1,60 @@ +#undef NDEBUG +#include +#include +#include +#include + +#include "AmbisonicEncoder.h" +#include "AmbisonicDecoder.h" + +int main() { + constexpr unsigned nSamples = 1; + unsigned order = 1; + bool b3D = true; + unsigned sampleRate = 48000; + auto layout = spaudio::Amblib_SpeakerSetUps::kAmblib_71; + + spaudio::AmbisonicEncoder ambiEnc; + bool success = ambiEnc.Configure(order, b3D, sampleRate, 0.f); + assert(success); + + spaudio::AmbisonicDecoder ambiDec; + success = ambiDec.Configure(order, b3D, nSamples, sampleRate, layout); + assert(success); + assert(ambiDec.GetPresetLoaded()); + + unsigned nLdspk = ambiDec.GetSpeakerCount(); + + spaudio::BFormat inputSignal; + inputSignal.Configure(order, b3D, nSamples); + inputSignal.Reset(); + std::array impulse; + impulse[0] = 1.f; + + float** ldspkOut = new float* [nLdspk]; + for (unsigned iLdspk = 0; iLdspk < nLdspk; ++iLdspk) + ldspkOut[iLdspk] = new float[nSamples]; + + for (float az = 0.f; az < 360.f; az += 1.f) + { + ambiEnc.SetPosition({ spaudio::DegreesToRadians(az), 0.f, 1.f }); + ambiEnc.Refresh(); + ambiEnc.Process(impulse.data(), nSamples, &inputSignal); + + ambiDec.Process(&inputSignal, nSamples, ldspkOut); + + for (unsigned iSamp = 0; iSamp < nSamples; ++iSamp) { + std::cout << std::setw(4) << iSamp << ": "; + for (unsigned iLdspk = 0; iLdspk < nLdspk; ++iLdspk) + { + std::cout << std::setw(12) << std::fixed << + ldspkOut[iLdspk][iSamp] << std::setw(0) << ", "; + } + std::cout << std::endl; + } + } + + for (unsigned iLdspk = 0; iLdspk < nLdspk; ++iLdspk) + delete[] ldspkOut[iLdspk]; + delete[] ldspkOut; +} diff --git a/tests/meson.build b/tests/meson.build index d3b50ae..d7d03b4 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -5,3 +5,6 @@ test('TestInsideAngleRange', e) e = executable('TestAmbisonicShelfFilters', 'TestAmbisonicShelfFilters.cpp', dependencies: [libspatialaudio_dep]) test('TestAmbisonicShelfFilters', e) + +e = executable('TestAmbisonicDecoderPresets', 'TestAmbisonicDecoderPresets.cpp', dependencies: [libspatialaudio_dep]) +test('TestAmbisonicDecoderPresets', e) From f446138000c151869e9f925c95592bfb2c974e93 Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Tue, 11 Nov 2025 03:14:59 +0100 Subject: [PATCH 4/4] Tests: CMake: Fix DLL search path for tests --- tests/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 39b3455..c13a80c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,10 @@ function(spaudio_add_test name) target_link_libraries(${name} PRIVATE spatialaudio) add_test(NAME ${name} COMMAND $) + set_property(TEST ${name} + PROPERTY + ENVIRONMENT_MODIFICATION + "PATH=path_list_append:$") endfunction() spaudio_add_test(TestInsideAngleRange)