From 910170e8dc2151e229b2bd7ce4a47e623515e69e Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Thu, 13 Nov 2025 17:50:36 +0100 Subject: [PATCH] [Reverb] - no channel sum for last diffusion step - elimnated latency due to feedback delay - added print for channel shuffle and delay values --- reverb/reverb.hpp | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/reverb/reverb.hpp b/reverb/reverb.hpp index 701c7ff..e302a32 100644 --- a/reverb/reverb.hpp +++ b/reverb/reverb.hpp @@ -6,6 +6,7 @@ #include #include #include +#include template class Delay @@ -14,6 +15,15 @@ class Delay int m_delay_spec[numCh]; uint m_delaySize; + void print_delays() + { + std::cout << "delays" << std::endl; + for (int i=0; i < numCh; i++) + { + std::cout << m_delay_spec[i] << " "; + } + std::cout << std::endl; + } public: Delay(uint delayCapacity, int delayOffset) : m_buf(delayCapacity) @@ -40,6 +50,7 @@ class Delay m_delay_spec[i] = -delay; } m_delaySize = delaySize; + print_delays(); } uint getDelay() @@ -75,9 +86,17 @@ class Diffusor Delay m_dly; int m_shuffle_spec[numCh]; - public: - Diffusor(uint maxDelaySize) - : m_dly(maxDelaySize, 0) + void print_shuffle() + { + std::cout << "shuffle" << std::endl; + for (int i=0; i < numCh; i++) + { + std::cout << m_shuffle_spec[i] << " "; + } + std::cout << std::endl; + } + + void shuffle_init(double pn) { // Shuffle spec for (int i=0; i < numCh; i++) @@ -96,15 +115,22 @@ class Diffusor } // Shuffle signs - float p = 0.3; for (int i=0; i < numCh; i++) { - float z = (float)rand()/(float)RAND_MAX; - if (z <= p) + double z = (double)rand()/(double)RAND_MAX; + if (z < pn) { m_shuffle_spec[i] *= (T)-1; } } + + print_shuffle(); + } + public: + Diffusor(uint maxDelaySize, double pn=0.5) + : m_dly(maxDelaySize, 0) + { + shuffle_init(pn); } void setDelay(uint delay) @@ -141,7 +167,7 @@ class Diffusor // Out-of-place inline void process_multi(T in[numCh], T out[numCh]) { - m_dly.process(in); + m_dly.process(in, out); Shuffle::outOfPlace(in, out, m_shuffle_spec); Hadamard::inPlace(out); @@ -168,6 +194,11 @@ class Reverb } } + uint getNumDiffusionSteps() + { + return m_diffusors.size(); + } + void setDelay(uint delay, uint index) { m_diffusors[index].setDelay(delay); @@ -215,7 +246,7 @@ class Reverb // Mix for (int c=0; c < numCh; c++) { - out[i] += fb_dly_out[c]; + out[i] = temp[0]; } } }