Normalize reverb time to sample rate

For consistent decay across different sample rates
Closes #563
pull/838/head
probonopd 3 weeks ago
parent 29bbce3472
commit 808e8a7338
  1. 12
      src/effect_platervbstereo.cpp
  2. 1
      src/effect_platervbstereo.h

@ -85,6 +85,7 @@ const int16_t AudioWaveformSine[257] = {
AudioEffectPlateReverb::AudioEffectPlateReverb(float32_t samplerate)
{
m_samplerate = samplerate;
input_attn = 0.5f;
in_allp_k = INP_ALLP_COEFF;
@ -200,7 +201,8 @@ void AudioEffectPlateReverb::doReverb(const float32_t* inblockL, const float32_t
}
cleanup_done = false;
rv_time = rv_time_k;
rv_time = rv_time_k * (m_samplerate / 44100.0f);
float32_t rv_time_scaler_scaled = rv_time_scaler * (m_samplerate / 44100.0f);
for (uint16_t i=0; i < len; i++)
{
@ -300,7 +302,7 @@ void AudioEffectPlateReverb::doReverb(const float32_t* inblockL, const float32_t
temp1 = lpf1 - hpf1;
hpf1 += temp1 * lp_hipass_f;
acc = lpf1 + temp2*lp_hidamp_k + hpf1*lp_lodamp_k;
acc = acc * rv_time * rv_time_scaler; // scale by the reveb time
acc = acc * rv_time * rv_time_scaler_scaled; // scale by the reveb time
input = acc + in_allp_out_L;
@ -319,7 +321,7 @@ void AudioEffectPlateReverb::doReverb(const float32_t* inblockL, const float32_t
temp1 = lpf2 - hpf2;
hpf2 += temp1 * lp_hipass_f;
acc = lpf2 + temp2*lp_hidamp_k + hpf2*lp_lodamp_k;
acc = acc * rv_time * rv_time_scaler;
acc = acc * rv_time * rv_time_scaler_scaled;
input = acc + in_allp_out_R;
@ -338,7 +340,7 @@ void AudioEffectPlateReverb::doReverb(const float32_t* inblockL, const float32_t
temp1 = lpf3 - hpf3;
hpf3 += temp1 * lp_hipass_f;
acc = lpf3 + temp2*lp_hidamp_k + hpf3*lp_lodamp_k;
acc = acc * rv_time * rv_time_scaler;
acc = acc * rv_time * rv_time_scaler_scaled;
input = acc + in_allp_out_L;
@ -357,7 +359,7 @@ void AudioEffectPlateReverb::doReverb(const float32_t* inblockL, const float32_t
temp1 = lpf4 - hpf4;
hpf4 += temp1 * lp_hipass_f;
acc = lpf4 + temp2*lp_hidamp_k + hpf4*lp_lodamp_k;
acc = acc * rv_time * rv_time_scaler;
acc = acc * rv_time * rv_time_scaler_scaled;
lp_allp_out = acc;

@ -113,6 +113,7 @@ private:
bool bypass = false;
float32_t reverb_level;
float32_t input_attn;
float32_t m_samplerate; // store the sample rate
float32_t in_allp_k; // input allpass coeff
float32_t in_allp1_bufL[224]; // input allpass buffers

Loading…
Cancel
Save