diff --git a/common/mix.hpp b/common/mix.hpp index faf5003..28d1712 100644 --- a/common/mix.hpp +++ b/common/mix.hpp @@ -89,6 +89,16 @@ class Shuffle out[s] = sign * in[c]; } }; + + static inline void inPlace(T *data, const int *shuffle_spec) + { + T temp[numCh]; + for (int c=0; c < numCh; c++) + { + temp[c] = data[c]; + } + Shuffle::outOfPlace(temp, data, shuffle_spec); + }; }; #endif diff --git a/delay/buffer_multi.hpp b/delay/buffer_multi.hpp index 7a2ffea..7e38f5c 100644 --- a/delay/buffer_multi.hpp +++ b/delay/buffer_multi.hpp @@ -126,6 +126,15 @@ class BufferMulti return *this; } + BufferMulti & operator =(T data[numCh]) + { + for (uint c=0; c < numCh; c++) + { + m_buffer[c][0] = data[c]; + } + return *this; + } + void quer(T *out, int offset=0) const { for (int c=0; c < numCh; c++) @@ -134,7 +143,7 @@ class BufferMulti } } - void quer(T *out, const int *offsets) const + void quer(T *out, const int offsets[numCh]) const { for (int c=0; c < numCh; c++) { diff --git a/reverb/reverb.hpp b/reverb/reverb.hpp index c45e25b..227177c 100644 --- a/reverb/reverb.hpp +++ b/reverb/reverb.hpp @@ -54,7 +54,6 @@ class Diffusor m_shuffle_spec[i] *= (T)-1; } } - } inline T process(T in) @@ -63,32 +62,68 @@ class Diffusor T qbuf[numCh]; m_dly.quer(qbuf, m_delay_spec); - - T sbuf[numCh]; - Shuffle::outOfPlace(qbuf, sbuf, m_shuffle_spec); - - Hadamard::inPlace(sbuf); - Householder::inPlace(sbuf); ++m_dly; - return sbuf[0]; + Shuffle::inPlace(qbuf, m_shuffle_spec); + Hadamard::inPlace(qbuf); + Householder::inPlace(qbuf); + return qbuf[0]; } + inline void process_multi(T data[numCh]) + { + m_dly = data; + m_dly.quer(data, m_delay_spec); + ++m_dly; + + Shuffle::inPlace(data, m_shuffle_spec); + Hadamard::inPlace(data); + } + + static inline void split(T in, T out[numCh]) + { + for (uint c=0; c < numCh; c++) + { + out[c] = in; + } + } + + static inline T combine(T data[numCh]) + { + Householder::inPlace(data); + return data[0]; + } }; template class Reverb { std::array, 3> m_diffusors; + dsp::BufferMulti m_feedbackDly; public: Reverb(uint maxDelay) : m_diffusors({maxDelay, maxDelay, maxDelay}) + , m_feedbackDly(maxDelay) { } + void process_multi(float *in, float *out, unsigned numPoints) + { + for (int i=0; i < numPoints; i++) + { + T temp[numCh]; + Diffusor::split(in[i], temp); + for (auto diffusor: m_diffusors) + { + diffusor.process_multi(temp); + } + out[i] = Diffusor::combine(temp); + } + } + void process(float *in, float *out, unsigned numPoints) { for (int i=0; i < numPoints; i++) @@ -101,6 +136,7 @@ class Reverb out[i] = temp; } } + }; #endif