#include "delay/buffer_multi.hpp" #include "test_common.hpp" #include #include #include #include #include #include int test_mix_1() { std::cout << "----------------------------------------------" << std::endl; std::cout << "Start test_mix_1::shuffle" << std::endl; std::cout << "----------------------------------------------" << std::endl; const int numCh = 5; { dsp::Buffer r_buf(5); dsp::Buffer t_buf{105, 106, 107, 108, 109}; t_buf = {105, 106, 107, 108, 109}; int s_spec[numCh] = {1, 3, 2, 4, 0}; int sbuf[numCh]; Shuffle::outOfPlace(t_buf.raw(), sbuf, s_spec); print(r_buf, 5); } { int sbuf[numCh]; int s_spec[numCh] = {-1, 0, -3, 2, -4}; dsp::BufferMulti r_buf(5); dsp::BufferMulti t_buf{5}; t_buf[0] = {105, 106, 107, 108, 109}; t_buf[1] = {205, 206, 207, 208, 209}; t_buf[2] = {305, 306, 307, 308, 309}; t_buf[3] = {405, 406, 407, 408, 409}; t_buf[4] = {505, 506, 507, 508, 509}; print(t_buf[0], 5); print(t_buf[1], 5); for (int i=0; i < numCh; i++) { Shuffle::outOfPlace(t_buf[i].raw(), sbuf, s_spec); print(r_buf[i], 5); } } return 0; } int test_mix_2() { dsp::BufferMulti r_buf(20); for (int i=0; i < 20; i++) { r_buf = 100 +i ; ++r_buf; } r_buf.reset(); for (int c=0; c < r_buf.numChannels(); c++) { print(r_buf[c], 20); std::cout << "----------------------------------------------" << std::endl; } for (int c=0; c < r_buf.numChannels(); c++) { dsp::Buffer v(r_buf[c], c); print(v, 20); std::cout << "----------------------------------------------" << std::endl; } return 0; } int test_mix_3() { const int nCh = 5; dsp::BufferMulti r_buf(10); for (int i=0; i < r_buf.capacity(); i++) { r_buf = (double)i/10 ; ++r_buf; } // r_buf.reset(); double sbuf[nCh]; double qbuf[nCh]; int delays[nCh] = {-2, -10, -4, 3, -3}; r_buf.quer(qbuf, delays); int s_spec[nCh] = {-1, 0, -3, 2, -4}; Shuffle::outOfPlace(qbuf, sbuf, s_spec); for (int i=0; i < nCh; i++) { std::cout << sbuf[i] << " "; } std::cout << std::endl; Hadamard::inPlace(sbuf); for (int i=0; i < nCh; i++) { std::cout << sbuf[i] << " "; } std::cout << std::endl; Householder::inPlace(sbuf); for (int i=0; i < nCh; i++) { std::cout << sbuf[i] << " "; } std::cout << std::endl; return 0; } void test_diffusor() { std::cout << "----------------------------------------------" << std::endl; std::cout << "test_diffusor()" << std::endl; Diffusor diff(5); double data_in[10] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7,0.8, 0.9, 1.0}; double data_out[10] = {0, 0, 0, 0, 0, 0, 0,0, 0, 0}; for (int i=0; i < 10; i++) { data_out[i] = diff.process(data_in[i]); } print(data_out, 10); } void test_reverb() { std::cout << "----------------------------------------------" << std::endl; std::cout << "test_reverb()" << std::endl; Reverb rev({32}, 2); float data_in[10] = {1, 2, 3, 4, 5, 6, 7,8, 9, 10}; float data_out[10] = {0, 0, 0, 0, 0, 0, 0,0, 0, 0}; rev.process(data_in, data_out, 10); print(data_out, 10); } int test_mix() { test_mix_1(); test_mix_2(); test_mix_3(); test_reverb(); test_diffusor(); return 0; }