Introduce an accurate version of coefficient_to_dB and use it in non speed-critical
code. Fixes mantis 2833. git-svn-id: svn://localhost/ardour2/branches/3.0@5565 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
4f3bddf7ef
commit
970a3a7292
|
@ -668,7 +668,7 @@ AutomationLine::fraction_to_string (double fraction) const
|
|||
if (fraction == 0.0) {
|
||||
snprintf (buf, sizeof (buf), "-inf");
|
||||
} else {
|
||||
snprintf (buf, sizeof (buf), "%.1f", coefficient_to_dB (slider_position_to_gain (fraction)));
|
||||
snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain (fraction)));
|
||||
}
|
||||
} else {
|
||||
double dummy = 0.0;
|
||||
|
|
|
@ -646,15 +646,15 @@ gnome_canvas_waveview_ensure_cache (GnomeCanvasWaveView *waveview, gulong start_
|
|||
for (n = 0; n < cache->data_size; ++n) {
|
||||
|
||||
if (buf[n].max > 0.0f) {
|
||||
buf[n].max = alt_log_meter(coefficient_to_dB(buf[n].max));
|
||||
buf[n].max = alt_log_meter(fast_coefficient_to_dB(buf[n].max));
|
||||
} else if (buf[n].max < 0.0f) {
|
||||
buf[n].max = -alt_log_meter(coefficient_to_dB(-buf[n].max));
|
||||
buf[n].max = -alt_log_meter(fast_coefficient_to_dB(-buf[n].max));
|
||||
}
|
||||
|
||||
if (buf[n].min > 0.0f) {
|
||||
buf[n].min = alt_log_meter(coefficient_to_dB(buf[n].min));
|
||||
buf[n].min = alt_log_meter(fast_coefficient_to_dB(buf[n].min));
|
||||
} else if (buf[n].min < 0.0f) {
|
||||
buf[n].min = -alt_log_meter(coefficient_to_dB(-buf[n].min));
|
||||
buf[n].min = -alt_log_meter(fast_coefficient_to_dB(-buf[n].min));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4730,8 +4730,6 @@ Editor::adjust_region_scale_amplitude (bool up)
|
|||
}
|
||||
|
||||
fraction = slider_position_to_gain (fraction);
|
||||
fraction = coefficient_to_dB (fraction);
|
||||
fraction = dB_to_coefficient (fraction);
|
||||
|
||||
if (up && fraction >= 2.0) {
|
||||
continue;
|
||||
|
|
|
@ -375,17 +375,17 @@ GainMeterBase::show_gain ()
|
|||
char buf[32];
|
||||
|
||||
float v = gain_adjustment.get_value();
|
||||
|
||||
|
||||
if (!_is_midi) {
|
||||
if (v == 0.0) {
|
||||
strcpy (buf, _("-inf"));
|
||||
} else {
|
||||
snprintf (buf, sizeof (buf), "%.1f", coefficient_to_dB (slider_position_to_gain (v)));
|
||||
snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain (v)));
|
||||
}
|
||||
} else {
|
||||
snprintf (buf, sizeof (buf), "%.1f", v);
|
||||
}
|
||||
|
||||
|
||||
gain_display.set_text (buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -803,7 +803,7 @@ public:
|
|||
if (val == 0.0) {
|
||||
snprintf (buf, sizeof (buf), "-inf");
|
||||
} else {
|
||||
snprintf (buf, sizeof (buf), "%.2f", coefficient_to_dB (val));
|
||||
snprintf (buf, sizeof (buf), "%.2f", accurate_coefficient_to_dB (val));
|
||||
}
|
||||
|
||||
_db_display.set_text (buf);
|
||||
|
|
|
@ -1428,23 +1428,23 @@ RouteUI::parameter_changed (string const & p)
|
|||
void
|
||||
RouteUI::step_gain_up ()
|
||||
{
|
||||
_route->set_gain (dB_to_coefficient (coefficient_to_dB (_route->gain_control()->get_value()) + 0.1), this);
|
||||
_route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.1), this);
|
||||
}
|
||||
|
||||
void
|
||||
RouteUI::page_gain_up ()
|
||||
{
|
||||
_route->set_gain (dB_to_coefficient (coefficient_to_dB (_route->gain_control()->get_value()) + 0.5), this);
|
||||
_route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.5), this);
|
||||
}
|
||||
|
||||
void
|
||||
RouteUI::step_gain_down ()
|
||||
{
|
||||
_route->set_gain (dB_to_coefficient (coefficient_to_dB (_route->gain_control()->get_value()) - 0.1), this);
|
||||
_route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.1), this);
|
||||
}
|
||||
|
||||
void
|
||||
RouteUI::page_gain_down ()
|
||||
{
|
||||
_route->set_gain (dB_to_coefficient (coefficient_to_dB (_route->gain_control()->get_value()) - 0.5), this);
|
||||
_route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.5), this);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,12 @@ static inline float dB_to_coefficient (float dB) {
|
|||
return dB > -318.8f ? pow (10.0f, dB * 0.05f) : 0.0f;
|
||||
}
|
||||
|
||||
static inline float coefficient_to_dB (float coeff) {
|
||||
static inline float fast_coefficient_to_dB (float coeff) {
|
||||
return 20.0f * fast_log10 (coeff);
|
||||
}
|
||||
|
||||
static inline float accurate_coefficient_to_dB (float coeff) {
|
||||
return 20.0f * log10 (coeff);
|
||||
}
|
||||
|
||||
#endif /* __ardour_dB_h__ */
|
||||
|
|
|
@ -197,7 +197,7 @@ PeakMeter::meter ()
|
|||
/* compute new visible value using falloff */
|
||||
|
||||
if (new_peak > 0.0) {
|
||||
new_peak = coefficient_to_dB (new_peak);
|
||||
new_peak = fast_coefficient_to_dB (new_peak);
|
||||
} else {
|
||||
new_peak = minus_infinity();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue