aboutsummaryrefslogtreecommitdiffstats
path: root/src/replay_gain_info.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/replay_gain_info.c17
1 files changed, 17 insertions, 0 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;
+}