From b21e4d9a589c02bffed9a1793d9fc2dc52044c12 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 15 Feb 2010 21:23:24 +0100 Subject: replay_gain_state: moved code to replay_gain_tuple_scale() Moved (and renamed) the function calc_replay_gain_scale() to replay_gain_info.c. --- src/replay_gain_info.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/replay_gain_info.c') 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 +#include 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; +} -- cgit v1.2.3