shithub: sox

Download patch

ref: 9bf3db0fa61449854b79338fbe425e53a413e74c
parent: 3b9c8b433a68777af5f8c758779a818019c0085a
author: robs <robs>
date: Tue Apr 14 15:12:19 EDT 2009

may as well expose the biquad engine

--- a/src/biquad.c
+++ b/src/biquad.c
@@ -58,7 +58,7 @@
 }
 
 
-int lsx_biquad_start(sox_effect_t * effp)
+static int start(sox_effect_t * effp)
 {
   priv_t * p = (priv_t *)effp->priv;
   /* Simplify: */
@@ -68,6 +68,17 @@
   p->a2 /= p->a0;
   p->a1 /= p->a0;
 
+  p->o2 = p->o1 = p->i2 = p-> i1 = 0;
+  return SOX_SUCCESS;
+}
+
+
+int lsx_biquad_start(sox_effect_t * effp)
+{
+  priv_t * p = (priv_t *)effp->priv;
+
+  start(effp);
+
   if (effp->global_info->plot == sox_plot_octave) {
     printf(
       "%% GNU Octave file (may also work with MATLAB(R) )\n"
@@ -107,7 +118,6 @@
       , p->b0, p->b1, p->b2, p->a1, p->a2);
     return SOX_EOF;
   }
-  p->o2 = p->o1 = p->i2 = p-> i1 = 0;
   return SOX_SUCCESS;
 }
 
@@ -124,4 +134,25 @@
     *obuf++ = SOX_ROUND_CLIP_COUNT(o0, effp->clips);
   }
   return SOX_SUCCESS;
+}
+
+static int create(sox_effect_t * effp, int argc, char * * argv)
+{
+  priv_t             * p = (priv_t *)effp->priv;
+  double             * d = &p->b0;
+  char               c;
+
+  --argc, ++argv;
+  if (argc == 6)
+    for (; argc && sscanf(*argv, "%lf%c", d, &c) == 1; --argc, ++argv, ++d);
+  return argc? lsx_usage(effp) : SOX_SUCCESS;
+}
+
+sox_effect_handler_t const * lsx_biquad_effect_fn(void)
+{
+  static sox_effect_handler_t handler = {
+    "biquad", "b0 b1 b2 a0 a1 a2", 0,
+    create, start, lsx_biquad_flow, NULL, NULL, NULL, sizeof(priv_t)
+  };
+  return &handler;
 }
--- a/src/effects.h
+++ b/src/effects.h
@@ -21,6 +21,7 @@
   EFFECT(bandreject)
   EFFECT(bass)
   EFFECT(bend)
+  EFFECT(biquad)
   EFFECT(chorus)
   EFFECT(channels)
   EFFECT(compand)