a-EQ: Remove LPF/HPF completely from this plugin

This commit is contained in:
Damien Zammit 2016-07-15 01:53:32 +10:00
parent d8a97789c1
commit fdfff81850
3 changed files with 55 additions and 195 deletions

View file

@ -1063,38 +1063,36 @@ LV2Plugin::get_layout (uint32_t which, UILayoutHint& h) const
}
h.knob = true;
switch (which) {
case 0: h.x0 = 0; h.x1 = 1; h.y0 = 4; h.y1 = 5; break; // Shelf toggle L
case 1: h.x0 = 0; h.x1 = 1; h.y0 = 2; h.y1 = 3; break; // Frequency L
case 2: h.x0 = 0; h.x1 = 1; h.y0 = 0; h.y1 = 1; break; // Gain L
case 19: h.x0 = 0; h.x1 = 1; h.y0 = 5; h.y1 = 6; break; // enable L
case 0: h.x0 = 0; h.x1 = 1; h.y0 = 2; h.y1 = 3; break; // Frequency L
case 1: h.x0 = 0; h.x1 = 1; h.y0 = 0; h.y1 = 1; break; // Gain L
case 17: h.x0 = 0; h.x1 = 1; h.y0 = 5; h.y1 = 6; break; // enable L
case 3: h.x0 = 1; h.x1 = 3; h.y0 = 2; h.y1 = 3; break; // Frequency 1
case 4: h.x0 = 1; h.x1 = 3; h.y0 = 0; h.y1 = 1; break; // Gain 1
case 5: h.x0 = 2; h.x1 = 4; h.y0 = 1; h.y1 = 2; break; // Bandwidth 1
case 20: h.x0 = 1; h.x1 = 4; h.y0 = 5; h.y1 = 6; break; // enable 1
case 2: h.x0 = 1; h.x1 = 3; h.y0 = 2; h.y1 = 3; break; // Frequency 1
case 3: h.x0 = 1; h.x1 = 3; h.y0 = 0; h.y1 = 1; break; // Gain 1
case 4: h.x0 = 2; h.x1 = 4; h.y0 = 1; h.y1 = 2; break; // Bandwidth 1
case 18: h.x0 = 1; h.x1 = 4; h.y0 = 5; h.y1 = 6; break; // enable 1
case 6: h.x0 = 4; h.x1 = 6; h.y0 = 2; h.y1 = 3; break; // Frequency 2
case 7: h.x0 = 4; h.x1 = 6; h.y0 = 0; h.y1 = 1; break; // Gain 2
case 8: h.x0 = 5; h.x1 = 7; h.y0 = 1; h.y1 = 2; break; // Bandwidth 2
case 21: h.x0 = 4; h.x1 = 7; h.y0 = 5; h.y1 = 6; break; // enable 2
case 5: h.x0 = 4; h.x1 = 6; h.y0 = 2; h.y1 = 3; break; // Frequency 2
case 6: h.x0 = 4; h.x1 = 6; h.y0 = 0; h.y1 = 1; break; // Gain 2
case 7: h.x0 = 5; h.x1 = 7; h.y0 = 1; h.y1 = 2; break; // Bandwidth 2
case 19: h.x0 = 4; h.x1 = 7; h.y0 = 5; h.y1 = 6; break; // enable 2
case 9: h.x0 = 7; h.x1 = 9; h.y0 = 2; h.y1 = 3; break; // Frequency 3
case 10: h.x0 = 7; h.x1 = 9; h.y0 = 0; h.y1 = 1; break; // Gain 3
case 11: h.x0 = 8; h.x1 = 10; h.y0 = 1; h.y1 = 2; break; // Bandwidth 3
case 22: h.x0 = 7; h.x1 = 10; h.y0 = 5; h.y1 = 6; break; // enable 3
case 8: h.x0 = 7; h.x1 = 9; h.y0 = 2; h.y1 = 3; break; // Frequency 3
case 9: h.x0 = 7; h.x1 = 9; h.y0 = 0; h.y1 = 1; break; // Gain 3
case 10: h.x0 = 8; h.x1 = 10; h.y0 = 1; h.y1 = 2; break; // Bandwidth 3
case 20: h.x0 = 7; h.x1 = 10; h.y0 = 5; h.y1 = 6; break; // enable 3
case 12: h.x0 = 10; h.x1 = 12; h.y0 = 2; h.y1 = 3; break; // Frequency 4
case 13: h.x0 = 10; h.x1 = 12; h.y0 = 0; h.y1 = 1; break; // Gain 4
case 14: h.x0 = 11; h.x1 = 13; h.y0 = 1; h.y1 = 2; break; // Bandwidth 4
case 23: h.x0 = 10; h.x1 = 13; h.y0 = 5; h.y1 = 6; break; // enable 4
case 11: h.x0 = 10; h.x1 = 12; h.y0 = 2; h.y1 = 3; break; // Frequency 4
case 12: h.x0 = 10; h.x1 = 12; h.y0 = 0; h.y1 = 1; break; // Gain 4
case 13: h.x0 = 11; h.x1 = 13; h.y0 = 1; h.y1 = 2; break; // Bandwidth 4
case 21: h.x0 = 10; h.x1 = 13; h.y0 = 5; h.y1 = 6; break; // enable 4
case 15: h.x0 = 13; h.x1 = 14; h.y0 = 4; h.y1 = 5; break; // Shelf toggle H
case 16: h.x0 = 13; h.x1 = 14; h.y0 = 2; h.y1 = 3; break; // Frequency H
case 17: h.x0 = 13; h.x1 = 14; h.y0 = 0; h.y1 = 1; break; // Gain H
case 24: h.x0 = 13; h.x1 = 14; h.y0 = 5; h.y1 = 6; break; // enable H
case 14: h.x0 = 13; h.x1 = 14; h.y0 = 2; h.y1 = 3; break; // Frequency H
case 15: h.x0 = 13; h.x1 = 14; h.y0 = 0; h.y1 = 1; break; // Gain H
case 22: h.x0 = 13; h.x1 = 14; h.y0 = 5; h.y1 = 6; break; // enable H
case 18: h.x0 = 14; h.x1 = 15; h.y0 = 4; h.y1 = 6; break; // Master Gain
case 16: h.x0 = 14; h.x1 = 15; h.y0 = 4; h.y1 = 6; break; // Master Gain
default:
return false;
}

View file

@ -39,8 +39,7 @@
#endif
typedef enum {
AEQ_SHELFTOGL = 0,
AEQ_FREQL,
AEQ_FREQL = 0,
AEQ_GAINL,
AEQ_FREQ1,
AEQ_GAIN1,
@ -54,7 +53,6 @@ typedef enum {
AEQ_FREQ4,
AEQ_GAIN4,
AEQ_BW4,
AEQ_SHELFTOGH,
AEQ_FREQH,
AEQ_GAINH,
AEQ_MASTER,
@ -96,8 +94,6 @@ static void linear_svf_reset(struct linear_svf *self)
}
typedef struct {
float* shelftogl;
float* shelftogh;
float* f0[BANDS];
float* g[BANDS];
float* bw[BANDS];
@ -114,8 +110,6 @@ typedef struct {
float v_bw[BANDS];
float v_f0[BANDS];
float v_filtog[BANDS];
float v_shelftogl;
float v_shelftogh;
float v_master;
bool need_expose;
@ -164,9 +158,6 @@ connect_port(LV2_Handle instance,
Aeq* aeq = (Aeq*)instance;
switch ((PortIndex)port) {
case AEQ_SHELFTOGL:
aeq->shelftogl = (float*)data;
break;
case AEQ_FREQL:
aeq->f0[0] = (float*)data;
break;
@ -209,9 +200,6 @@ connect_port(LV2_Handle instance,
case AEQ_BW4:
aeq->bw[4] = (float*)data;
break;
case AEQ_SHELFTOGH:
aeq->shelftogh = (float*)data;
break;
case AEQ_FREQH:
aeq->f0[5] = (float*)data;
break;
@ -261,42 +249,6 @@ activate(LV2_Handle instance)
// SVF filters
// http://www.cytomic.com/files/dsp/SvfLinearTrapOptimised2.pdf
static void linear_svf_set_hp(struct linear_svf *self, float sample_rate, float cutoff, float resonance)
{
double f0 = (double)cutoff;
double q = (double)resonance;
double sr = (double)sample_rate;
self->g = tan(M_PI * (f0 / sr));
self->k = 1.0 / q;
self->a[0] = 1.0 / (1.0 + self->g * (self->g + self->k));
self->a[1] = self->g * self->a[0];
self->a[2] = self->g * self->a[1];
self->m[0] = 1.0;
self->m[1] = -self->k;
self->m[2] = -1.0;
}
static void linear_svf_set_lp(struct linear_svf *self, float sample_rate, float cutoff, float resonance)
{
double f0 = (double)cutoff;
double q = (double)resonance;
double sr = (double)sample_rate;
self->g = tan(M_PI * (f0 / sr));
self->k = 1.0 / q;
self->a[0] = 1.0 / (1.0 + self->g * (self->g + self->k));
self->a[1] = self->g * self->a[0];
self->a[2] = self->g * self->a[1];
self->m[0] = 0.0;
self->m[1] = 0.0;
self->m[2] = 1.0;
}
static void linear_svf_set_peq(struct linear_svf *self, float gdb, float sample_rate, float cutoff, float bandwidth)
{
double f0 = (double)cutoff;
@ -379,11 +331,7 @@ static void set_params(LV2_Handle instance, int band) {
switch (band) {
case 0:
if (aeq->v_shelftogl > 0.5) {
linear_svf_set_lowshelf(&aeq->v_filter[0], aeq->v_g[0], aeq->srate, aeq->v_f0[0], 0.7071068);
} else {
linear_svf_set_hp(&aeq->v_filter[0], aeq->srate, aeq->v_f0[0], 0.7071068);
}
linear_svf_set_lowshelf(&aeq->v_filter[0], aeq->v_g[0], aeq->srate, aeq->v_f0[0], 0.7071068);
break;
case 1:
case 2:
@ -392,11 +340,7 @@ static void set_params(LV2_Handle instance, int band) {
linear_svf_set_peq(&aeq->v_filter[band], aeq->v_g[band], aeq->srate, aeq->v_f0[band], aeq->v_bw[band]);
break;
case 5:
if (aeq->v_shelftogh > 0.5) {
linear_svf_set_highshelf(&aeq->v_filter[5], aeq->v_g[5], aeq->srate, aeq->v_f0[5], 0.7071068);
} else {
linear_svf_set_lp(&aeq->v_filter[5], aeq->srate, aeq->v_f0[5], 0.7071068);
}
linear_svf_set_highshelf(&aeq->v_filter[5], aeq->v_g[5], aeq->srate, aeq->v_f0[5], 0.7071068);
break;
}
}
@ -447,14 +391,6 @@ run(LV2_Handle instance, uint32_t n_samples)
aeq->v_bw[i] += tau * (*aeq->bw[i] - aeq->v_bw[i]);
aeq->need_expose = true;
}
if (!is_eq(aeq->v_shelftogl, *aeq->shelftogl)) {
aeq->v_shelftogl = *(aeq->shelftogl);
aeq->need_expose = true;
}
if (!is_eq(aeq->v_shelftogh, *aeq->shelftogh)) {
aeq->v_shelftogh = *(aeq->shelftogh);
aeq->need_expose = true;
}
if (!is_eq(aeq->v_master, *aeq->master)) {
aeq->v_master = *(aeq->master);
aeq->need_expose = true;
@ -490,38 +426,6 @@ calc_peq(Aeq* self, int i, double omega) {
return cabs(H);
}
static double
calc_lowpass(Aeq* self, double omega) {
double complex H = 0.0;
double complex z = cexp(I * omega);
double complex zz = cexp(2. * I * omega);
double complex zm = z - 1.0;
double complex zp = z + 1.0;
double complex zzm = zz - 1.0;
double g = self->v_filter[5].g;
double k = self->v_filter[5].k;
H = (g*g*zp*zp) / (zm*zm + g*g*zp*zp + g*k*zzm);
return cabs(H);
}
static double
calc_highpass(Aeq* self, double omega) {
double complex H = 0.0;
double complex z = cexp(I * omega);
double complex zz = cexp(2. * I * omega);
double complex zm = z - 1.0;
double complex zp = z + 1.0;
double complex zzm = zz - 1.0;
double g = self->v_filter[0].g;
double k = self->v_filter[0].k;
H = zm*zm / (zm*zm + g*g*zp*zp + g*k*zzm);
return cabs(H);
}
static double
calc_lowshelf(Aeq* self, double omega) {
double complex H = 0.0;
@ -569,35 +473,17 @@ eq_curve (Aeq* self, float f) {
double SR = (double)self->srate;
double omega = f * 2. * M_PI / SR;
// low
if (self->v_shelftogl) {
// lowshelf
response *= calc_lowshelf(self, omega);
} else {
// hp:
response *= calc_highpass(self, omega);
}
// lowshelf
response *= calc_lowshelf(self, omega);
// peq1:
// peq 1 - 4:
response *= calc_peq(self, 1, omega);
// peq2:
response *= calc_peq(self, 2, omega);
// peq3:
response *= calc_peq(self, 3, omega);
// peq4:
response *= calc_peq(self, 4, omega);
// high
if (self->v_shelftogh) {
// highshelf:
response *= calc_highshelf(self, omega);
} else {
// lp:
response *= calc_lowpass(self, omega);
}
// highshelf:
response *= calc_highshelf(self, omega);
return (float)response;
}

View file

@ -32,18 +32,6 @@ unit:hz0
lv2:port [
a lv2:InputPort, lv2:ControlPort ;
lv2:index 0 ;
lv2:name "Shelf L" ;
lv2:symbol "shelftogl" ;
lv2:default 1.000000 ;
lv2:minimum 0.000000 ;
lv2:maximum 1.000000 ;
lv2:portProperty lv2:toggled ;
lv2:portProperty <http://lv2plug.in/ns/ext/port-props#causesArtifacts> ;
lv2:portProperty <http://lv2plug.in/ns/ext/port-props#notAutomatic> ;
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 1 ;
lv2:name "Frequency L" ;
lv2:symbol "freql" ;
lv2:default 160.000000 ;
@ -54,7 +42,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 2 ;
lv2:index 1 ;
lv2:name "Gain L" ;
lv2:symbol "gl" ;
lv2:default 0.000000 ;
@ -64,7 +52,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 3 ;
lv2:index 2 ;
lv2:name "Frequency 1" ;
lv2:symbol "freq1" ;
lv2:default 300.000000 ;
@ -75,7 +63,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 4 ;
lv2:index 3 ;
lv2:name "Gain 1" ;
lv2:symbol "g1" ;
lv2:default 0.000000 ;
@ -85,7 +73,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 5 ;
lv2:index 4 ;
lv2:name "Bandwidth 1" ;
lv2:symbol "bw1" ;
lv2:default 1.000000 ;
@ -95,7 +83,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 6 ;
lv2:index 5 ;
lv2:name "Frequency 2" ;
lv2:symbol "freq2" ;
lv2:default 1000.000000 ;
@ -106,7 +94,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 7 ;
lv2:index 6 ;
lv2:name "Gain 2" ;
lv2:symbol "g2" ;
lv2:default 0.000000 ;
@ -116,7 +104,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 8 ;
lv2:index 7 ;
lv2:name "Bandwidth 2" ;
lv2:symbol "bw2" ;
lv2:default 1.000000 ;
@ -126,7 +114,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 9 ;
lv2:index 8 ;
lv2:name "Frequency 3" ;
lv2:symbol "freq3" ;
lv2:default 2500.000000 ;
@ -137,7 +125,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 10 ;
lv2:index 9 ;
lv2:name "Gain 3" ;
lv2:symbol "g3" ;
lv2:default 0.000000 ;
@ -147,7 +135,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 11 ;
lv2:index 10 ;
lv2:name "Bandwidth 3" ;
lv2:symbol "bw3" ;
lv2:default 1.000000 ;
@ -157,7 +145,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 12 ;
lv2:index 11 ;
lv2:name "Frequency 4" ;
lv2:symbol "freq4" ;
lv2:default 6000.000000 ;
@ -168,7 +156,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 13 ;
lv2:index 12 ;
lv2:name "Gain 4" ;
lv2:symbol "g4" ;
lv2:default 0.000000 ;
@ -178,7 +166,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 14 ;
lv2:index 13 ;
lv2:name "Bandwidth 4" ;
lv2:symbol "bw4" ;
lv2:default 1.000000 ;
@ -188,19 +176,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 15 ;
lv2:name "Shelf H" ;
lv2:symbol "shelftogh" ;
lv2:default 1.000000 ;
lv2:minimum 0.000000 ;
lv2:maximum 1.000000 ;
lv2:portProperty lv2:toggled ;
lv2:portProperty <http://lv2plug.in/ns/ext/port-props#causesArtifacts> ;
lv2:portProperty <http://lv2plug.in/ns/ext/port-props#notAutomatic> ;
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 16 ;
lv2:index 14 ;
lv2:name "Frequency H" ;
lv2:symbol "freqh" ;
lv2:default 9000.000000 ;
@ -211,7 +187,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 17 ;
lv2:index 15 ;
lv2:name "Gain H" ;
lv2:symbol "gh" ;
lv2:default 0.000000 ;
@ -221,7 +197,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 18 ;
lv2:index 16 ;
lv2:name "Master Gain" ;
lv2:symbol "master" ;
lv2:default 0.000000 ;
@ -230,7 +206,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 19 ;
lv2:index 17 ;
lv2:name "Filter L" ;
lv2:symbol "filtogl" ;
lv2:default 1.000000 ;
@ -240,7 +216,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 20 ;
lv2:index 18 ;
lv2:name "Filter 1" ;
lv2:symbol "filtog1" ;
lv2:default 1.000000 ;
@ -250,7 +226,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 21 ;
lv2:index 19 ;
lv2:name "Filter 2" ;
lv2:symbol "filtog2" ;
lv2:default 1.000000 ;
@ -260,7 +236,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 22 ;
lv2:index 20 ;
lv2:name "Filter 3" ;
lv2:symbol "filtog3" ;
lv2:default 1.000000 ;
@ -270,7 +246,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 23 ;
lv2:index 21 ;
lv2:name "Filter 4" ;
lv2:symbol "filtog4" ;
lv2:default 1.000000 ;
@ -280,7 +256,7 @@ unit:hz0
],
[
a lv2:InputPort, lv2:ControlPort ;
lv2:index 24 ;
lv2:index 22 ;
lv2:name "Filter H" ;
lv2:symbol "filtogh" ;
lv2:default 1.000000 ;
@ -291,14 +267,14 @@ unit:hz0
lv2:port [
a lv2:InputPort, lv2:AudioPort ;
lv2:index 25 ;
lv2:index 23 ;
lv2:symbol "in_1" ;
lv2:name "Audio Input 1" ;
] ;
lv2:port [
a lv2:OutputPort, lv2:AudioPort ;
lv2:index 26 ;
lv2:index 24 ;
lv2:symbol "out_1" ;
lv2:name "Audio Output 1" ;
] ;