[reverb]
- added getter/setter for delay, feedback delay
This commit is contained in:
+57
-5
@@ -5,18 +5,34 @@
|
|||||||
#include <delay/buffer_multi.hpp>
|
#include <delay/buffer_multi.hpp>
|
||||||
#include <common/mix.hpp>
|
#include <common/mix.hpp>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
template<typename T, size_t numCh>
|
template<typename T, size_t numCh>
|
||||||
class Delay
|
class Delay
|
||||||
{
|
{
|
||||||
dsp::BufferMulti<T, numCh> m_buf;
|
dsp::BufferMulti<T, numCh> m_buf;
|
||||||
int m_delay_spec[numCh];
|
int m_delay_spec[numCh];
|
||||||
|
uint m_delaySize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Delay(uint maxDelaySize, int delayOffset=0)
|
Delay(uint delayCapacity, int delayOffset=0)
|
||||||
: m_buf(maxDelaySize)
|
: m_buf(delayCapacity)
|
||||||
{
|
{
|
||||||
float delayRagePerWindow = (float)(maxDelaySize-delayOffset)/(float)numCh;
|
setDelay(delayCapacity-delayOffset, delayOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDelay(uint delaySize, int delayOffset=0)
|
||||||
|
{
|
||||||
|
if ((delaySize + delayOffset) > m_buf.capacity())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float delayRagePerWindow = (float)(delaySize-delayOffset)/(float)numCh;
|
||||||
|
|
||||||
|
if (delayRagePerWindow < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Delay spec
|
// Delay spec
|
||||||
for (int i=0; i < numCh; i++)
|
for (int i=0; i < numCh; i++)
|
||||||
@@ -27,6 +43,12 @@ class Delay
|
|||||||
|
|
||||||
m_delay_spec[i] = -delay;
|
m_delay_spec[i] = -delay;
|
||||||
}
|
}
|
||||||
|
m_delaySize = delaySize;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint getDelay()
|
||||||
|
{
|
||||||
|
return m_delaySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void process(T in, T out[numCh])
|
void process(T in, T out[numCh])
|
||||||
@@ -89,6 +111,16 @@ class Diffusor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setDelay(uint delay)
|
||||||
|
{
|
||||||
|
m_dly.setDelay(delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint getDelay()
|
||||||
|
{
|
||||||
|
return m_dly.getDelay();
|
||||||
|
}
|
||||||
|
|
||||||
inline T process(T in)
|
inline T process(T in)
|
||||||
{
|
{
|
||||||
T temp[numCh];
|
T temp[numCh];
|
||||||
@@ -129,9 +161,9 @@ class Reverb
|
|||||||
T fb_gain;
|
T fb_gain;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Reverb(std::initializer_list<Diffusor<T, numCh>> maxDelay, uint fb_dly_min, uint fb_dly_max)
|
Reverb(std::initializer_list<Diffusor<T, numCh>> maxDelay, uint fb_maxDelay)
|
||||||
: m_diffusors(maxDelay)
|
: m_diffusors(maxDelay)
|
||||||
, m_feedbackDly(fb_dly_max, fb_dly_min)
|
, m_feedbackDly(fb_maxDelay, 0)
|
||||||
, fb_gain(0)
|
, fb_gain(0)
|
||||||
{
|
{
|
||||||
for (int c=0; c < numCh; c++)
|
for (int c=0; c < numCh; c++)
|
||||||
@@ -140,11 +172,31 @@ class Reverb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setDelay(uint delay, uint index)
|
||||||
|
{
|
||||||
|
m_diffusors[index].setDelay(delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint getDelay(uint index)
|
||||||
|
{
|
||||||
|
return m_diffusors[index].getDelay();
|
||||||
|
}
|
||||||
|
|
||||||
void setFeedbackGain(T value)
|
void setFeedbackGain(T value)
|
||||||
{
|
{
|
||||||
fb_gain = value;
|
fb_gain = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T getFeedbackGain()
|
||||||
|
{
|
||||||
|
return fb_gain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFeedbackDelay(uint delay_min, uint delay_max)
|
||||||
|
{
|
||||||
|
m_feedbackDly.setDelay(delay_max, delay_min);
|
||||||
|
}
|
||||||
|
|
||||||
void process_multi(float *in, float *out, unsigned numPoints)
|
void process_multi(float *in, float *out, unsigned numPoints)
|
||||||
{
|
{
|
||||||
for (int i=0; i < numPoints; i++)
|
for (int i=0; i < numPoints; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user