From 491f474dd0586af7a4ba602d2729dd56afb8d208 Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Fri, 19 Jul 2019 23:21:58 +1000 Subject: Fixed LR4 equivalent --- plugins/ZaMultiComp/ZaMultiCompPlugin.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/plugins/ZaMultiComp/ZaMultiCompPlugin.cpp b/plugins/ZaMultiComp/ZaMultiCompPlugin.cpp index e7388d4..1338f5c 100644 --- a/plugins/ZaMultiComp/ZaMultiCompPlugin.cpp +++ b/plugins/ZaMultiComp/ZaMultiCompPlugin.cpp @@ -733,16 +733,17 @@ void ZaMultiCompPlugin::activate() * https://cytomic.com/files/dsp/SvfInputMixing.pdf */ -void ZaMultiCompPlugin::linear_svf_set_xover(struct linear_svf *self, float sample_rate, float cutoff, float resonance, bool hp) +void ZaMultiCompPlugin::linear_svf_set_xover(struct linear_svf *self, float sample_rate, float cutoff, float, bool hp) { double w; w = M_PI * cutoff / sample_rate; self->g = tan(w); - self->k = 1.4142135 * (1. - resonance * resonance); - self->m0 = self->g; + self->k = sqrt(2.); + + self->m0 = hp ? 0. : 1.; self->m1 = 0.; - self->m2 = hp ? 1. : self->k * self->k; + self->m2 = hp ? 1. : 0.; } void ZaMultiCompPlugin::linear_svf_reset(struct linear_svf *self) @@ -758,9 +759,9 @@ float ZaMultiCompPlugin::run_linear_svf_xover(struct linear_svf *self, float in) double s0 = self->s[0]; double s1 = self->s[1]; double g2 = g*g; - double vhigh = in * self->m2; - double vband = in * self->m1; double vlow = in * self->m0; + double vband = in * self->m1; + double vhigh = in * self->m2; v[0] = in; v[1] = -1. / (1. + g2 + g*k) * (-s0 + g*s1 - g*k*s0 + g2*vband + g*vhigh - g*vlow - g2*k*vlow); @@ -775,14 +776,20 @@ void ZaMultiCompPlugin::calc_lr4(float f, int i) { float srate = getSampleRate(); - linear_svf_set_xover(&simper[0][i][0], srate, f, 0.5, false); - linear_svf_set_xover(&simper[1][i][0], srate, f, 0.5, true); + linear_svf_set_xover(&simper[0][i][0], srate, f, 0., false); + linear_svf_set_xover(&simper[0][i][1], srate, f, 0., false); + linear_svf_set_xover(&simper[1][i][0], srate, f, 0., true); + linear_svf_set_xover(&simper[1][i][1], srate, f, 0., true); } void ZaMultiCompPlugin::run_lr4(int i, float in, float *outlo, float *outhi) { - *outlo = run_linear_svf_xover(&simper[0][i][0], in); - *outhi = run_linear_svf_xover(&simper[1][i][0], in); + double tmp; + + tmp = run_linear_svf_xover(&simper[0][i][0], in); + *outlo = run_linear_svf_xover(&simper[0][i][1], tmp); + tmp = run_linear_svf_xover(&simper[1][i][0], in); + *outhi = run_linear_svf_xover(&simper[1][i][1], tmp); } void ZaMultiCompPlugin::run_comp(int k, float in, float *out) -- cgit v1.2.3