shithub: sox

Download patch

ref: 2c40db71bb9507b0b549e3208f01f978d6ce9b6a
parent: 88c8553442a1bfad77eb52aa96ac08837918bda5
author: robs <robs>
date: Sun May 13 02:11:35 EDT 2007

Cleaner inheritence implementation

--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -176,7 +176,7 @@
 	  mixer.c noiseprof.c noisered.c noisered.h pad.c pan.c		\
 	  phaser.c pitch.c polyphas.c rabbit.c rate.c repeat.c		\
 	  resample.c reverb.c reverse.c silence.c skeleff.c speed.c	\
-	  stat.c stretch.c swap.c synth.c synth.h tremolo.c trim.c	\
+	  stat.c stretch.c swap.c synth.c tremolo.c trim.c	\
 	  vibro.c vol.c
 
 libsox_la_SOURCES = $(effects) adpcms.c adpcms.h aiff.c aiff.h cvsd.c cvsd.h cvsdfilt.h \
--- a/src/synth.h
+++ /dev/null
@@ -1,4 +1,0 @@
-#include "sox_i.h"
-int sox_synth_getopts(eff_t, int, char * *);
-int sox_synth_start(eff_t);
-int sox_synth_flow(eff_t, sox_ssample_t const *, sox_ssample_t *, sox_size_t *, sox_size_t *);
--- a/src/tremolo.c
+++ b/src/tremolo.c
@@ -16,7 +16,7 @@
 
 /* Effect: tremolo  (c) 2007 robs@users.sourceforge.net */
 
-#include "synth.h"
+#include "sox_i.h"
 
 static int getopts(eff_t effp, int n, char * * argv) 
 {
@@ -23,7 +23,7 @@
   double speed, depth = 40;
   char dummy;     /* To check for extraneous chars. */
   char offset[100];
-  char * synth_args[] = {"sine", "fmod", 0, 0};
+  char * args[] = {"sine", "fmod", 0, 0};
 
   if (n < 1 || n > 2 ||
       sscanf(argv[0], "%lf %c", &speed, &dummy) != 1 || speed < 0 ||
@@ -32,17 +32,18 @@
     sox_fail(effp->h->usage);
     return SOX_EOF;
   }
-  synth_args[2] = argv[0];
+  args[2] = argv[0];
   sprintf(offset, "%g", 100 - depth / 2);
-  synth_args[3] = offset;
-  return sox_synth_getopts(effp, array_length(synth_args), synth_args);
+  args[3] = offset;
+  return sox_synth_effect_fn()->getopts(effp, array_length(args), args);
 }
 
 sox_effect_t const * sox_tremolo_effect_fn(void)
 {
-  static sox_effect_t driver = {
-    "tremolo", "Usage: tremolo speed_Hz [depth_percent];", SOX_EFF_MCHAN,
-    getopts, sox_synth_start, sox_synth_flow, 0, 0, 0,
-  };
+  static sox_effect_t driver;
+  driver = *sox_synth_effect_fn();
+  driver.name = "tremolo";
+  driver.usage = "Usage: tremolo speed_Hz [depth_percent]";
+  driver.getopts = getopts;
   return &driver;
 }
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -16,7 +16,7 @@
 
 /* Effect: "vibro" (= tremolo)  (c) 2007 robs@users.sourceforge.net */
 
-#include "synth.h"
+#include "sox_i.h"
 
 static int getopts(eff_t effp, int n, char * * argv) 
 {
@@ -23,7 +23,7 @@
   double speed, depth = 0.5;
   char dummy;     /* To check for extraneous chars. */
   char offset[100];
-  char * synth_args[] = {"sine", "fmod", 0, 0};
+  char * args[] = {"sine", "fmod", 0, 0};
 
   if (n < 1 || n > 2 ||
       sscanf(argv[0], "%lf %c", &speed, &dummy) != 1 || speed < 0 ||
@@ -32,17 +32,19 @@
     sox_fail(effp->h->usage);
     return SOX_EOF;
   }
-  synth_args[2] = argv[0];
+  args[2] = argv[0];
   sprintf(offset, "%g", 100 - 50 * depth);
-  synth_args[3] = offset;
-  return sox_synth_getopts(effp, array_length(synth_args), synth_args);
+  args[3] = offset;
+  return sox_synth_effect_fn()->getopts(effp, array_length(args), args);
 }
 
 sox_effect_t const * sox_vibro_effect_fn(void)
 {
-  static sox_effect_t driver = {
-    "vibro", "Usage: vibro speed [depth]", SOX_EFF_MCHAN | SOX_EFF_DEPRECATED,
-    getopts, sox_synth_start, sox_synth_flow, 0, 0, 0,
-  };
+  static sox_effect_t driver;
+  driver = *sox_synth_effect_fn();
+  driver.name = "vibro";
+  driver.usage = "Usage: vibro speed [depth]";
+  driver.getopts = getopts;
+  driver.flags |= SOX_EFF_DEPRECATED;
   return &driver;
 }