diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-10-08 14:40:09 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-10-08 14:40:09 +0000 |
commit | 8738b689e037c5db3d57bd071812b38e9875d141 (patch) | |
tree | 911777f381a0bd0ec1a5f2a7d5d28887987d1f5b /libs | |
parent | aee0eabca4fbf8dbf8f2ed45cc9697a5704bb6fc (diff) |
accurate dB/log patch from Carl, back-ported from 3.0
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5756 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/dB.h | 6 | ||||
-rw-r--r-- | libs/ardour/io.cc | 2 | ||||
-rw-r--r-- | libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc | 2 | ||||
-rw-r--r-- | libs/surfaces/tranzport/show.cc | 2 |
4 files changed, 8 insertions, 4 deletions
diff --git a/libs/ardour/ardour/dB.h b/libs/ardour/ardour/dB.h index b67e581067..b4a9688f56 100644 --- a/libs/ardour/ardour/dB.h +++ b/libs/ardour/ardour/dB.h @@ -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.f * log10 (coeff); +} + #endif /* __ardour_dB_h__ */ diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index 596d3f9402..f0a0cece19 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -2545,7 +2545,7 @@ IO::meter () /* compute new visible value using falloff */ if (new_peak > 0.0f) { - new_peak = coefficient_to_dB (new_peak); + new_peak = fast_coefficient_to_dB (new_peak); } else { new_peak = -INFINITY; } diff --git a/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc b/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc index 5b413273ea..8693c0cd30 100644 --- a/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc +++ b/libs/surfaces/frontier/tranzport/tranzport_control_protocol.cc @@ -361,7 +361,7 @@ TranzportControlProtocol::show_track_gain () gain_t g = route_get_gain (0); if ((g != last_track_gain) || lcd_isdamaged(0,9,8)) { char buf[16]; - snprintf (buf, sizeof (buf), "%6.1fdB", coefficient_to_dB (route_get_effective_gain (0))); + snprintf (buf, sizeof (buf), "%6.1fdB", accurate_coefficient_to_dB (route_get_effective_gain (0))); print (0, 9, buf); last_track_gain = g; } diff --git a/libs/surfaces/tranzport/show.cc b/libs/surfaces/tranzport/show.cc index 30f4de3b57..04e641ea8e 100644 --- a/libs/surfaces/tranzport/show.cc +++ b/libs/surfaces/tranzport/show.cc @@ -390,7 +390,7 @@ TranzportControlProtocol::show_track_gain () gain_t g = route_get_gain (0); if ((g != last_track_gain) || lcd_isdamaged(0,12,8)) { char buf[16]; - snprintf (buf, sizeof (buf), "%6.1fdB", coefficient_to_dB (route_get_effective_gain (0))); + snprintf (buf, sizeof (buf), "%6.1fdB", accurate_coefficient_to_dB (route_get_effective_gain (0))); print (0, 12, buf); last_track_gain = g; } |