mirror of https://github.com/AxioDL/amuse.git
Fix reverb issue
This commit is contained in:
parent
e9213ab179
commit
531961be78
|
@ -28,7 +28,7 @@ template <typename T>
|
||||||
class EffectReverbHiImp;
|
class EffectReverbHiImp;
|
||||||
|
|
||||||
/** Reverb effect with configurable reflection filtering */
|
/** Reverb effect with configurable reflection filtering */
|
||||||
class EffectReverb
|
class EffectReverbStd
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
float x140_x1c8_coloration; /**< [0.0, 1.0] influences filter coefficients to define surface characteristics of a room */
|
float x140_x1c8_coloration; /**< [0.0, 1.0] influences filter coefficients to define surface characteristics of a room */
|
||||||
|
@ -42,7 +42,7 @@ protected:
|
||||||
friend class EffectReverbStdImp;
|
friend class EffectReverbStdImp;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
friend class EffectReverbHiImp;
|
friend class EffectReverbHiImp;
|
||||||
EffectReverb(float coloration, float mix, float time,
|
EffectReverbStd(float coloration, float mix, float time,
|
||||||
float damping, float preDelay);
|
float damping, float preDelay);
|
||||||
public:
|
public:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -80,7 +80,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Reverb effect with configurable reflection filtering, adds per-channel low-pass and crosstalk */
|
/** Reverb effect with configurable reflection filtering, adds per-channel low-pass and crosstalk */
|
||||||
class EffectReverbHi : public EffectReverb
|
class EffectReverbHi : public EffectReverbStd
|
||||||
{
|
{
|
||||||
float x1dc_crosstalk; /**< [0.0, 1.0] factor defining how much reflections are allowed to bleed to other channels */
|
float x1dc_crosstalk; /**< [0.0, 1.0] factor defining how much reflections are allowed to bleed to other channels */
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public:
|
||||||
|
|
||||||
/** Standard-quality 2-stage reverb */
|
/** Standard-quality 2-stage reverb */
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class EffectReverbStdImp : public EffectBase<T>, public EffectReverb
|
class EffectReverbStdImp : public EffectBase<T>, public EffectReverbStd
|
||||||
{
|
{
|
||||||
ReverbDelayLine x0_AP[8][2] = {}; /**< All-pass delay lines */
|
ReverbDelayLine x0_AP[8][2] = {}; /**< All-pass delay lines */
|
||||||
ReverbDelayLine x78_C[8][2] = {}; /**< Comb delay lines */
|
ReverbDelayLine x78_C[8][2] = {}; /**< Comb delay lines */
|
||||||
|
|
|
@ -80,7 +80,7 @@ public:
|
||||||
EffectDelay& makeDelay(uint32_t initDelay, uint32_t initFeedback, uint32_t initOutput);
|
EffectDelay& makeDelay(uint32_t initDelay, uint32_t initFeedback, uint32_t initOutput);
|
||||||
|
|
||||||
/** Add new standard-quality reverb effect to effect stack and assume ownership */
|
/** Add new standard-quality reverb effect to effect stack and assume ownership */
|
||||||
EffectReverb& makeReverbStd(float coloration, float mix, float time,
|
EffectReverbStd& makeReverbStd(float coloration, float mix, float time,
|
||||||
float damping, float preDelay);
|
float damping, float preDelay);
|
||||||
|
|
||||||
/** Add new high-quality reverb effect to effect stack and assume ownership */
|
/** Add new high-quality reverb effect to effect stack and assume ownership */
|
||||||
|
|
|
@ -53,7 +53,7 @@ void ReverbDelayLine::setdelay(int32_t delay)
|
||||||
x4_outPoint += x8_length;
|
x4_outPoint += x8_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectReverb::EffectReverb(float coloration, float mix, float time,
|
EffectReverbStd::EffectReverbStd(float coloration, float mix, float time,
|
||||||
float damping, float preDelay)
|
float damping, float preDelay)
|
||||||
: x140_x1c8_coloration(clamp(0.f, coloration, 1.f)),
|
: x140_x1c8_coloration(clamp(0.f, coloration, 1.f)),
|
||||||
x144_x1cc_mix(clamp(0.f, mix, 1.f)),
|
x144_x1cc_mix(clamp(0.f, mix, 1.f)),
|
||||||
|
@ -64,14 +64,14 @@ EffectReverb::EffectReverb(float coloration, float mix, float time,
|
||||||
|
|
||||||
EffectReverbHi::EffectReverbHi(float coloration, float mix, float time,
|
EffectReverbHi::EffectReverbHi(float coloration, float mix, float time,
|
||||||
float damping, float preDelay, float crosstalk)
|
float damping, float preDelay, float crosstalk)
|
||||||
: EffectReverb(coloration, mix, time, damping, preDelay),
|
: EffectReverbStd(coloration, mix, time, damping, preDelay),
|
||||||
x1dc_crosstalk(clamp(0.f, crosstalk, 1.0f))
|
x1dc_crosstalk(clamp(0.f, crosstalk, 1.0f))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
EffectReverbStdImp<T>::EffectReverbStdImp(float coloration, float mix, float time,
|
EffectReverbStdImp<T>::EffectReverbStdImp(float coloration, float mix, float time,
|
||||||
float damping, float preDelay, double sampleRate)
|
float damping, float preDelay, double sampleRate)
|
||||||
: EffectReverb(coloration, mix, time, damping, preDelay),
|
: EffectReverbStd(coloration, mix, time, damping, preDelay),
|
||||||
m_sampleRate(sampleRate)
|
m_sampleRate(sampleRate)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ void EffectReverbStdImp<T>::_update()
|
||||||
size_t tapDelay = CTapDelays[t] * m_sampleRate / 32000.0;
|
size_t tapDelay = CTapDelays[t] * m_sampleRate / 32000.0;
|
||||||
combLine.allocate(tapDelay);
|
combLine.allocate(tapDelay);
|
||||||
combLine.setdelay(tapDelay);
|
combLine.setdelay(tapDelay);
|
||||||
xf4_combCoef[c][t] = std::pow(10.f, tapDelay * -3 / timeSamples);
|
xf4_combCoef[c][t] = std::pow(10.f, tapDelay * -3.f / timeSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int t=0 ; t<2 ; ++t)
|
for (int t=0 ; t<2 ; ++t)
|
||||||
|
@ -153,9 +153,10 @@ void EffectReverbStdImp<T>::applyEffect(T* audio, size_t frameCount, const Chann
|
||||||
ReverbDelayLine* linesC = x78_C[c];
|
ReverbDelayLine* linesC = x78_C[c];
|
||||||
ReverbDelayLine* linesAP = x0_AP[c];
|
ReverbDelayLine* linesAP = x0_AP[c];
|
||||||
|
|
||||||
float sample = audio[c];
|
for (int s=0 ; s<160 && f<frameCount ; ++s, ++f)
|
||||||
for (int s=1 ; s<160 && f<frameCount ; ++s, ++f)
|
|
||||||
{
|
{
|
||||||
|
float sample = audio[s * chanMap.m_channelCount + c];
|
||||||
|
|
||||||
/* Pre-delay stage */
|
/* Pre-delay stage */
|
||||||
float sample2 = sample;
|
float sample2 = sample;
|
||||||
if (x120_preDelayTime != 0)
|
if (x120_preDelayTime != 0)
|
||||||
|
@ -224,8 +225,7 @@ void EffectReverbStdImp<T>::applyEffect(T* audio, size_t frameCount, const Chann
|
||||||
linesAP[1].x4_outPoint = 0;
|
linesAP[1].x4_outPoint = 0;
|
||||||
|
|
||||||
/* Mix out */
|
/* Mix out */
|
||||||
audio[(s-1) * chanMap.m_channelCount + c] = ClampFull<T>(dampWet * allPass + dampDry * sample);
|
audio[s * chanMap.m_channelCount + c] = ClampFull<T>(dampWet * allPass + dampDry * sample);
|
||||||
sample = audio[s * chanMap.m_channelCount + c];
|
|
||||||
}
|
}
|
||||||
x130_preDelayPtr[c] = preDelayPtr;
|
x130_preDelayPtr[c] = preDelayPtr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,10 @@ EffectDelay& Submix::makeDelay(uint32_t initDelay, uint32_t initFeedback, uint32
|
||||||
return makeEffect<EffectDelay>(initDelay, initFeedback, initOutput);
|
return makeEffect<EffectDelay>(initDelay, initFeedback, initOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectReverb& Submix::makeReverbStd(float coloration, float mix, float time,
|
EffectReverbStd& Submix::makeReverbStd(float coloration, float mix, float time,
|
||||||
float damping, float preDelay)
|
float damping, float preDelay)
|
||||||
{
|
{
|
||||||
return makeEffect<EffectReverb>(coloration, mix, time, damping, preDelay);
|
return makeEffect<EffectReverbStd>(coloration, mix, time, damping, preDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectReverbHi& Submix::makeReverbHi(float coloration, float mix, float time,
|
EffectReverbHi& Submix::makeReverbHi(float coloration, float mix, float time,
|
||||||
|
|
Loading…
Reference in New Issue