[SCM] calf/master: + Reverb: added sanitization of the outer loop + Reverb: much better reverb time to feedback formula (empirical, based on measurements with different feedback) + Reverb: some insignificant code reorganization (might help with adding more reverb types with different tap lengths) + Benchmark: added impulse response measurement for reverb (to help me with coming up with the formula)
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:36:51 UTC 2013
The following commit has been merged in the master branch:
commit ea743f99d3b95f80ab6a9c45f55fff75f0aff17a
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Sun Dec 30 14:09:31 2007 +0000
+ Reverb: added sanitization of the outer loop
+ Reverb: much better reverb time to feedback formula (empirical, based on measurements with different feedback)
+ Reverb: some insignificant code reorganization (might help with adding more reverb types with different tap lengths)
+ Benchmark: added impulse response measurement for reverb (to help me with coming up with the formula)
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@60 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/src/benchmark.cpp b/src/benchmark.cpp
index edc1eea..2128586 100644
--- a/src/benchmark.cpp
+++ b/src/benchmark.cpp
@@ -286,6 +286,40 @@ void effect_test()
dsp::do_simple_benchmark<effect_benchmark<synth::filter_audio_module> >(5, 10000);
}
+void reverbir_calc()
+{
+ enum { LEN = 1048576 };
+ static float data[2][LEN];
+
+ for (int t = 1; t < 38; t++)
+ {
+ reverb<float> rvb;
+
+ memset(data, 0, sizeof(data));
+ data[0][0] = 1;
+ data[1][0] = 0;
+
+ rvb.set_cutoff(22000);
+ rvb.setup(44100);
+ rvb.reset();
+ rvb.set_fb(t < 19 ? t * 0.05 : 0.905 + (t - 19) * 0.005);
+
+ for (int i = 0; i < LEN; i++)
+ rvb.process(data[0][i], data[1][i]);
+
+ int i;
+ for (i = LEN - 1; i > 0; i--)
+ {
+ // printf("[%d]=%f\n", i, data[0][i]);
+ if (fabs(data[0][i]) < 0.001 && fabs(data[1][i]) < 0.001)
+ continue;
+ break;
+ }
+ if (i < LEN - 1)
+ printf("%f\t%f\n", rvb.get_fb(), i / 44100.0);
+ }
+}
+
int main(int argc, char *argv[])
{
while(1) {
@@ -316,5 +350,8 @@ int main(int argc, char *argv[])
if (!unit || !strcmp(unit, "effects"))
effect_test();
+ if (!strcmp(unit, "reverbir"))
+ reverbir_calc();
+
return 0;
}
diff --git a/src/calf/audio_fx.h b/src/calf/audio_fx.h
index 134fd12..3f60321 100644
--- a/src/calf/audio_fx.h
+++ b/src/calf/audio_fx.h
@@ -258,10 +258,10 @@ class reverb: public audio_effect
public:
reverb()
{
- setup(44100);
phase = 0.0;
time = 1.0;
cutoff = 9000;
+ setup(44100);
}
virtual void setup(int sample_rate) {
sr = sample_rate;
@@ -275,7 +275,16 @@ public:
}
void set_time(float time) {
this->time = time;
- fb = pow(1.0f/4096.0f, (float)(1700/(time*sr)));
+ // fb = pow(1.0f/4096.0f, (float)(1700/(time*sr)));
+ fb = 1.0 - 0.3 / (time * sr / 44100.0);
+ }
+ float get_fb()
+ {
+ return this->fb;
+ }
+ void set_fb(float fb)
+ {
+ this->fb = fb;
}
float get_cutoff() {
return cutoff;
@@ -294,15 +303,16 @@ public:
apL5.reset();apR5.reset();
apL6.reset();apR6.reset();
lp_left.reset();lp_right.reset();
+ old_left = 0; old_right = 0;
}
void process(T &left, T &right)
{
- const int tl1 = 697, tr1 = 783;
- const int tl2 = 957, tr2 = 929;
- const int tl3 = 649, tr3 = 531;
- const int tl4 = 1249, tr4 = 1377;
- const int tl5 = 1573, tr5 = 1671;
- const int tl6 = 1877, tr6 = 1781;
+ const int tl1 = 697 << 16, tr1 = 783 << 16;
+ const int tl2 = 957 << 16, tr2 = 929 << 16;
+ const int tl3 = 649 << 16, tr3 = 531 << 16;
+ const int tl4 = 1249 << 16, tr4 = 1377 << 16;
+ const int tl5 = 1573 << 16, tr5 = 1671 << 16;
+ const int tl6 = 1877 << 16, tr6 = 1781 << 16;
static const float fDec=1700.f;
static const float l1dec=exp(-697.f/fDec), r1dec=exp(-783.f/fDec);
static const float l2dec=exp(-975.f/fDec), r2dec=exp(-929.f/fDec);
@@ -323,24 +333,26 @@ public:
phase += dphase;
left += old_right;
- left = apL1.process_allpass_comb_lerp16(left, tl1 * 65536 - 45*lfo, l1dec);
- left = apL2.process_allpass_comb_lerp16(left, tl2 * 65536 + 47*lfo, l2dec);
+ left = apL1.process_allpass_comb_lerp16(left, tl1 - 45*lfo, l1dec);
+ left = apL2.process_allpass_comb_lerp16(left, tl2 + 47*lfo, l2dec);
float out_left = left;
- left = apL3.process_allpass_comb_lerp16(left, tl3 * 65536 + 54*lfo, l3dec);
- left = apL4.process_allpass_comb_lerp16(left, tl4 * 65536 - 69*lfo, l4dec);
- left = apL5.process_allpass_comb_lerp16(left, tl5 * 65536 - 69*lfo, l5dec);
- left = apL6.process_allpass_comb_lerp16(left, tl6 * 65536 - 46*lfo, l6dec);
+ left = apL3.process_allpass_comb_lerp16(left, tl3 + 54*lfo, l3dec);
+ left = apL4.process_allpass_comb_lerp16(left, tl4 - 69*lfo, l4dec);
+ left = apL5.process_allpass_comb_lerp16(left, tl5 - 69*lfo, l5dec);
+ left = apL6.process_allpass_comb_lerp16(left, tl6 - 46*lfo, l6dec);
old_left = lp_left.process(left * fb);
+ sanitize(old_left);
right += old_left;
- right = apR1.process_allpass_comb_lerp16(right, tr1 * 65536 - 45*lfo, r1dec);
- right = apR2.process_allpass_comb_lerp16(right, tr2 * 65536 + 47*lfo, r2dec);
+ right = apR1.process_allpass_comb_lerp16(right, tr1 - 45*lfo, r1dec);
+ right = apR2.process_allpass_comb_lerp16(right, tr2 + 47*lfo, r2dec);
float out_right = right;
- right = apR3.process_allpass_comb_lerp16(right, tr3 * 65536 + 54*lfo, r3dec);
- right = apR4.process_allpass_comb_lerp16(right, tr4 * 65536 - 69*lfo, r4dec);
- right = apR5.process_allpass_comb_lerp16(right, tr5 * 65536 - 69*lfo, r5dec);
- right = apR6.process_allpass_comb_lerp16(right, tr6 * 65536 - 46*lfo, r6dec);
+ right = apR3.process_allpass_comb_lerp16(right, tr3 + 54*lfo, r3dec);
+ right = apR4.process_allpass_comb_lerp16(right, tr4 - 69*lfo, r4dec);
+ right = apR5.process_allpass_comb_lerp16(right, tr5 - 69*lfo, r5dec);
+ right = apR6.process_allpass_comb_lerp16(right, tr6 - 46*lfo, r6dec);
old_right = lp_right.process(right * fb);
+ sanitize(old_right);
left = out_left, right = out_right;
}
diff --git a/src/modules.cpp b/src/modules.cpp
index fee70fb..dbce083 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -66,7 +66,7 @@ static synth::ladspa_wrapper<flanger_audio_module> flanger(flanger_info);
const char *reverb_audio_module::port_names[] = {"In L", "In R", "Out L", "Out R"};
parameter_properties reverb_audio_module::param_props[] = {
- { 1.5, 1.0, 4.0, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_SEC, NULL, "decay_time", "Decay time" },
+ { 1.5, 0.5, 15.0, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_SEC, NULL, "decay_time", "Decay time" },
{ 5000, 2000,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hf_damp", "High Frq Damp" },
{ 0.25, 0, 2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "amount", "Amount" },
};
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list