Use symmetric dB range for EQ plugins.

(cherry picked from commit cb3e7e001da3e0f43b3da8eed3f9660698f87ca2)
This commit is contained in:
Krzysztof Foltman
2010-11-06 23:44:11 +00:00
committed by Tobias Doerffel
parent 90e288976f
commit a9a91053d9
2 changed files with 7 additions and 7 deletions

View File

@@ -634,22 +634,22 @@ public:
extern const char *calf_copyright_info;
bool get_freq_gridline(int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context, bool use_frequencies = true);
bool get_freq_gridline(int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context, bool use_frequencies = true, float res = 256, float ofs = 0.4);
/// convert amplitude value to normalized grid-ish value (0dB = 0.5, 30dB = 1.0, -30 dB = 0.0, -60dB = -0.5, -90dB = -1.0)
static inline float dB_grid(float amp)
static inline float dB_grid(float amp, float res = 256, float ofs = 0.4)
{
return log(amp) * (1.0 / log(256.0)) + 0.4;
return log(amp) * (1.0 / log(res)) + ofs;
}
template<class Fx>
static bool get_graph(Fx &fx, int subindex, float *data, int points)
static bool get_graph(Fx &fx, int subindex, float *data, int points, float res = 256, float ofs = 0.4)
{
for (int i = 0; i < points; i++)
{
typedef std::complex<double> cfloat;
double freq = 20.0 * pow (20000.0 / 20.0, i * 1.0 / points);
data[i] = dB_grid(fx.freq_gain(subindex, freq, fx.srate));
data[i] = dB_grid(fx.freq_gain(subindex, freq, fx.srate), res, ofs);
}
return true;
}

View File

@@ -248,7 +248,7 @@ bool equalizerNband_audio_module<BaseClass, has_lphp>::get_graph(int index, int
return false;
if (index == AM::param_p1_freq && !subindex) {
context->set_line_width(1.5);
return ::get_graph(*this, subindex, data, points);
return ::get_graph(*this, subindex, data, points, 32, 0);
}
return false;
}
@@ -259,7 +259,7 @@ bool equalizerNband_audio_module<BaseClass, has_lphp>::get_gridline(int index, i
if (!is_active) {
return false;
} else {
return get_freq_gridline(subindex, pos, vertical, legend, context);
return get_freq_gridline(subindex, pos, vertical, legend, context, true, 32, 0);
}
}