diff options
author | Max Kellermann <max@duempel.org> | 2010-02-15 21:23:24 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2010-02-15 21:23:24 +0100 |
commit | b21e4d9a589c02bffed9a1793d9fc2dc52044c12 (patch) | |
tree | 694936fb9629d3eecd06d258ead66b7b879fc29c /src | |
parent | eeef501ed865b4ef9e0c971829a39a98c7b81ee9 (diff) | |
download | mpd-b21e4d9a589c02bffed9a1793d9fc2dc52044c12.tar.gz mpd-b21e4d9a589c02bffed9a1793d9fc2dc52044c12.tar.xz mpd-b21e4d9a589c02bffed9a1793d9fc2dc52044c12.zip |
replay_gain_state: moved code to replay_gain_tuple_scale()
Moved (and renamed) the function calc_replay_gain_scale() to
replay_gain_info.c.
Diffstat (limited to 'src')
-rw-r--r-- | src/replay_gain_info.c | 17 | ||||
-rw-r--r-- | src/replay_gain_info.h | 3 | ||||
-rw-r--r-- | src/replay_gain_state.c | 20 |
3 files changed, 21 insertions, 19 deletions
diff --git a/src/replay_gain_info.c b/src/replay_gain_info.c index 676394c0f..ce9d84950 100644 --- a/src/replay_gain_info.c +++ b/src/replay_gain_info.c @@ -21,6 +21,7 @@ #include "replay_gain_info.h" #include <glib.h> +#include <math.h> struct replay_gain_info * replay_gain_info_new(void) @@ -46,3 +47,19 @@ replay_gain_info_free(struct replay_gain_info *info) { g_free(info); } + +float +replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp) +{ + float scale; + + scale = pow(10.0, tuple->gain / 20.0); + scale *= preamp; + if (scale > 15.0) + scale = 15.0; + + if (scale * tuple->peak > 1.0) + scale = 1.0 / tuple->peak; + + return scale; +} diff --git a/src/replay_gain_info.h b/src/replay_gain_info.h index 9a11a8965..9fcae22ab 100644 --- a/src/replay_gain_info.h +++ b/src/replay_gain_info.h @@ -57,4 +57,7 @@ replay_gain_tuple_defined(const struct replay_gain_tuple *tuple) return tuple->gain > 0.0; } +float +replay_gain_tuple_scale(const struct replay_gain_tuple *tuple, float preamp); + #endif diff --git a/src/replay_gain_state.c b/src/replay_gain_state.c index db77dc1e9..4d494c62d 100644 --- a/src/replay_gain_state.c +++ b/src/replay_gain_state.c @@ -24,7 +24,6 @@ #include <glib.h> #include <assert.h> -#include <math.h> struct replay_gain_state { float preamp, missing_preamp; @@ -60,22 +59,6 @@ replay_gain_state_free(struct replay_gain_state *state) g_free(state); } -static float -calc_replay_gain_scale(float gain, float peak, float preamp) -{ - float scale; - - scale = pow(10.0, gain / 20.0); - scale *= preamp; - if (scale > 15.0) - scale = 15.0; - - if (scale * peak > 1.0) { - scale = 1.0 / peak; - } - return (scale); -} - static void replay_gain_state_calc_scale(struct replay_gain_state *state) { @@ -90,8 +73,7 @@ replay_gain_state_calc_scale(struct replay_gain_state *state) g_debug("computing ReplayGain scale with gain %f, peak %f", tuple->gain, tuple->peak); - state->scale = calc_replay_gain_scale(tuple->gain, tuple->peak, - state->preamp); + state->scale = replay_gain_tuple_scale(tuple, state->preamp); } else state->scale = state->missing_preamp; } |