[Reverb]
- no channel sum for last diffusion step - elimnated latency due to feedback delay - added print for channel shuffle and delay values
This commit is contained in:
+39
-8
@@ -6,6 +6,7 @@
|
||||
#include <common/mix.hpp>
|
||||
#include <initializer_list>
|
||||
#include <sys/types.h>
|
||||
#include <iostream>
|
||||
|
||||
template<typename T, size_t numCh>
|
||||
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<T, numCh> 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<T, numCh>::outOfPlace(in, out, m_shuffle_spec);
|
||||
Hadamard<T, numCh>::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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user