changeset 4314:e548627b2004

EQ pregain works. nobody uses it though
author Eugene Zagidullin <e.asphyx@gmail.com>
date Mon, 03 Mar 2008 22:13:27 +0300
parents 772de6f365cf
children c942eaef7bc6
files src/audacious/equalizer_flow.c
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/equalizer_flow.c	Sun Mar 02 22:04:03 2008 +0300
+++ b/src/audacious/equalizer_flow.c	Mon Mar 03 22:13:27 2008 +0300
@@ -20,6 +20,7 @@
 /*#define AUD_DEBUG*/
 
 #include <glib.h>
+#include <math.h>
 #include "main.h"
 #include "plugin.h"
 #include "flow.h"
@@ -81,14 +82,27 @@
 {
     int i;
     af_control_ext_t ctl;
+    gfloat b[10];
+    gfloat adj = 0.0;
     AUDDBG("\n");
     
     if(eq == NULL) {
         eq = g_malloc(sizeof(af_instance_t));
         equalizer_open(eq);
     }
-    
-    ctl.arg = bands;
+
+    for(i = 0; i < 10; i++)
+        b[i] = bands[i] + pre;
+
+    for(i = 0; i < 10; i++)
+        if(fabsf(b[i]) > fabsf(adj)) adj = b[i];
+
+    if(fabsf(adj) > EQUALIZER_MAX_GAIN) {
+        adj = adj > 0.0 ? EQUALIZER_MAX_GAIN - adj : -EQUALIZER_MAX_GAIN - adj;
+        for(i = 0; i < 10; i++) b[i] += adj;
+    }
+
+    ctl.arg = b;
     for(i = 0; i < AF_NCH; i++) {
         ctl.ch = i;
         eq->control(eq, AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET, &ctl);