diff options
author | Damien Zammit <damien@zamaudio.com> | 2016-07-14 03:05:54 +1000 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2016-07-14 03:06:47 +1000 |
commit | 08f9fc40dcbd7dd6cced43e204faa8d1b7883ae3 (patch) | |
tree | 37f3cbf704cd414d8300ed561bd8793458b089a8 /libs/plugins/a-eq.lv2/a-eq.c | |
parent | b77b3cbe224a17fdb7e00ed14d003dbd5dd571f8 (diff) |
a-EQ: Fixed transfer functions, now boost/cut cancel out correctly
Diffstat (limited to 'libs/plugins/a-eq.lv2/a-eq.c')
-rw-r--r-- | libs/plugins/a-eq.lv2/a-eq.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/libs/plugins/a-eq.lv2/a-eq.c b/libs/plugins/a-eq.lv2/a-eq.c index fb799d8d8e..8dd81673ef 100644 --- a/libs/plugins/a-eq.lv2/a-eq.c +++ b/libs/plugins/a-eq.lv2/a-eq.c @@ -67,14 +67,14 @@ typedef enum { AEQ_OUTPUT, } PortIndex; -static inline float -to_dB(float g) { - return (20.f*log10(g)); +static inline double +to_dB(double g) { + return (20.0*log10(g)); } -static inline float -from_dB(float gdb) { - return (exp(gdb/20.f*log(10.f))); +static inline double +from_dB(double gdb) { + return (exp(gdb/20.0*log(10.0))); } struct linear_svf { @@ -458,7 +458,7 @@ calc_peq(Aeq* self, int i, double omega) { double A = pow(10.0, self->v_g[i]/40.0); double g = self->v_filter[i].g; - double k = self->v_filter[i].k; + double k = self->v_filter[i].k * A; double m1 = k * (A * A - 1.0) / A; H = (g*k*zzm + A*(g*zp*(m1*zm) + (zm*zm + g*g*zp*zp))) / (g*k*zzm + A*(zm*zm + g*g*zp*zp)); @@ -635,9 +635,8 @@ render_inline (LV2_Handle instance, uint32_t w, uint32_t max_h) // plot 20..20kHz +-20dB const float x_hz = 20.f * powf (1000.f, (float)x / (float)w); const float y_db = to_dB(eq_curve(self, x_hz)) + self->v_master; - const float y = h * -y_db / 40.0 + h / 2; + const float y = (float)h * (-y_db / 40.0 + 0.5); cairo_line_to (cr, x, y); - //printf("(hz,H,db)=(%f, %f, %f)\n", x_hz, from_dB(y_db), y_db); } cairo_stroke_preserve (cr); |