[MPlayer-dev-eng] [PATCH] Audio balance feature

Zuxy Meng zuxy.meng at gmail.com
Sun Jun 17 11:02:28 CEST 2007


Hi,

2007/6/17, Reimar Doeffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> Hello,
> On Sun, Jun 17, 2007 at 04:30:29PM +0800, Zuxy Meng wrote:
> > 2007/6/17, Reimar Doeffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> > > The description is wrong, and I'd name it just AF_CONTROL_BALANCE, there
> > > is no reason to keep it af_pan specific forever.
> >
> > The description will be corrected. As for the name, currently it's a
> > filter specific control, and the tradition is to prepend the filter
> > name. Were u suggesting making it a general control option like
> > AF_CONTROL_REINIT or AF_CONTROL_POSTCREATE?
>
> Hm. No, I guess it's okay then, I thought the volume control name was
> more general, but it is not either. We can still change it if ever we
> get a reason to.

OK. Updated af_pan patch attached.

-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
-------------- next part --------------
Index: libaf/af_pan.c
===================================================================
--- libaf/af_pan.c	?????? 23567??
+++ libaf/af_pan.c	????????????
@@ -111,7 +111,24 @@
   case AF_CONTROL_PAN_NOUT | AF_CONTROL_GET:
     *(int*)arg = af->data->nch;
     return AF_OK;
+  case AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET:{
+    float val = *(float*)arg;
+    if (s->nch)
+      return AF_ERROR;
+    if (af->data->nch >= 2) {
+      s->level[0][0] = min(1.f, 1.f - val);
+      s->level[0][1] = max(0.f, val);
+      s->level[1][0] = max(0.f, -val);
+      s->level[1][1] = min(1.f, 1.f + val);
+    }
+    return AF_OK;
   }
+  case AF_CONTROL_PAN_BALANCE | AF_CONTROL_GET:
+    if (s->nch)
+      return AF_ERROR;
+    *(float*)arg = s->level[0][1] - s->level[1][0];
+    return AF_OK;
+  }
   return AF_UNKNOWN;
 }
 
Index: libaf/control.h
===================================================================
--- libaf/control.h	?????? 23567??
+++ libaf/control.h	????????????
@@ -193,6 +193,8 @@
 // Number of outputs from pan, arg is int*
 #define AF_CONTROL_PAN_NOUT	 	0x00001B00 | AF_CONTROL_FILTER_SPECIFIC
  
+// Balance, arg is float*
+#define AF_CONTROL_PAN_BALANCE	 	0x00002500 | AF_CONTROL_FILTER_SPECIFIC
 
 // Set equalizer gain, arg is a control_ext with a float* 
 #define AF_CONTROL_EQUALIZER_GAIN 	0x00001C00 | AF_CONTROL_FILTER_SPECIFIC


More information about the MPlayer-dev-eng mailing list