From 01d644b76e062934e772e35b712156cbe477f0cd Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sat, 8 Nov 2025 16:22:30 +0100 Subject: [PATCH] added test_mix_3 --- delay/buffer.hpp | 5 +++++ delay/tests/Makefile | 2 +- delay/tests/test_mix.cpp | 42 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/delay/buffer.hpp b/delay/buffer.hpp index c5c9e1c..613e98f 100644 --- a/delay/buffer.hpp +++ b/delay/buffer.hpp @@ -89,6 +89,11 @@ class Buffer return m_capacity/m_increment; } + T *raw() const + { + return &m_buffer[m_index]; + } + void reset() { m_index = 0; diff --git a/delay/tests/Makefile b/delay/tests/Makefile index 9cb5ad8..183f62c 100644 --- a/delay/tests/Makefile +++ b/delay/tests/Makefile @@ -15,7 +15,7 @@ INCLUDES += -I $(realpath .) -I $(realpath ../../) CXX_SRCS := test_main.cpp test_buffer.cpp test_buffer_multi.cpp test_mix.cpp -LIBS := -lstdc++ +LIBS := -lstdc++ -lm run: link @echo Running $(TARGET) diff --git a/delay/tests/test_mix.cpp b/delay/tests/test_mix.cpp index 3507485..d99259e 100644 --- a/delay/tests/test_mix.cpp +++ b/delay/tests/test_mix.cpp @@ -5,6 +5,7 @@ #include #include +#include int test_mix_1() @@ -71,9 +72,50 @@ int test_mix_2() return 0; } +int test_mix_3() +{ + const int nCh = 5; + dsp::BufferMulti r_buf(nCh, 10); + for (int i=0; i < r_buf.capacity(); i++) + { + r_buf = (double)i/10 ; + ++r_buf; + } +// r_buf.reset(); + + dsp::Buffer qbuf(r_buf.quer({-2, -10, -4, 3, -3})); + dsp::Buffer sbuf(nCh); + dsp::Buffer s_spec = {-1, 0, -3, 2, -4}; + Shuffle::outOfPlace(qbuf, sbuf, s_spec); + + double *q = sbuf.raw(); + + for (int i=0; i < nCh; i++) + { + std::cout << q[i] << " "; + } + std::cout << std::endl; + + Hadamard::inPlace(q); + for (int i=0; i < nCh; i++) + { + std::cout << q[i] << " "; + } + std::cout << std::endl; + + Householder::inPlace(q); + for (int i=0; i < nCh; i++) + { + std::cout << q[i] << " "; + } + std::cout << std::endl; + return 0; +} + int test_mix() { test_mix_1(); test_mix_2(); + test_mix_3(); return 0; } \ No newline at end of file