use plain FIR instead of max

This commit is contained in:
Connor Olding 2015-12-10 07:40:12 -08:00
parent 5ef106fc40
commit 23528169c5

View file

@ -65,7 +65,7 @@ struct Crap_level
biquad filters_R[bands]; biquad filters_R[bands];
ulong window_size; ulong window_size;
ulong lookahead; ulong lookahead;
double *window; double *window, window_sum;
double env, attack, release; double env, attack, release;
Delay<v2df> delay; Delay<v2df> delay;
Delay<double> window_delay; Delay<double> window_delay;
@ -101,18 +101,14 @@ struct Crap_level
for (ulong i = 0; i < rem; i++) for (ulong i = 0; i < rem; i++)
envs[i] *= 0.5; envs[i] *= 0.5;
// MaxFIR // FIR
double *applied = new double[window_size];
for (ulong i = 0; i < rem; i++) { for (ulong i = 0; i < rem; i++) {
window_delay.delay(envs[i]); window_delay.delay(envs[i]);
double sum = 0;
for (ulong j = 0; j < window_size; j++) for (ulong j = 0; j < window_size; j++)
applied[j] = window[j]*window_delay[j]; sum += window[j]*window_delay[j];
double max_ = 0; envs[i] = sum/window_sum*2;
for (ulong j = 0; j < window_size; j++)
max_ = fmax(max_, applied[j]);
envs[i] = max_;
} }
delete applied;
// Follower // Follower
for (ulong i = 0; i < rem; i++) { for (ulong i = 0; i < rem; i++) {
@ -172,10 +168,12 @@ struct Crap_level
delete window; delete window;
window = new double[window_size]; window = new double[window_size];
window_sum = 0;
for (ulong i = 0; i < window_size; i++) { for (ulong i = 0; i < window_size; i++) {
double x = double(i)/window_size; double x = double(i)/window_size;
double y = -(x - 0)*(x - 1)*(x + 0.6)/0.288; double y = -(x - 0)*(x - 1)*(x + 0.6)/0.288;
window[i] = y; window[i] = y;
window_sum += y;
} }
attack = 1 - exp(-1/(fs*0.002)); attack = 1 - exp(-1/(fs*0.002));