shithub: sox

Download patch

ref: af44d2269ad65899188779f1d1cb14fd8fa57e5b
parent: 378db3445bdaf21a623cd40c9dac44533a2faf35
author: robs <robs>
date: Mon Dec 29 10:46:54 EST 2008

rationalise effects' options interface (getopt compatible)

--- a/src/bend.c
+++ b/src/bend.c
@@ -109,7 +109,7 @@
   argc -= optind, argv += optind;
 
   p->bends = lsx_calloc(p->nbends = argc, sizeof(*p->bends));
-  return parse(effp, argv, 1e6);     /* No rate yet; parse with dummy */
+  return parse(effp, argv, 0.);     /* No rate yet; parse with dummy */
 }
 
 static int start(sox_effect_t * effp)
@@ -295,8 +295,8 @@
 sox_effect_handler_t const *sox_bend_effect_fn(void)
 {
   static sox_effect_handler_t handler = {
-    "bend", "[-f frame-rate(25)] [-o over-sample(16)] {delay,cents,duration}", SOX_EFF_GETOPT,
-    create, start, flow, 0, stop, kill, sizeof(priv_t)
+    "bend", "[-f frame-rate(25)] [-o over-sample(16)] {delay,cents,duration}",
+    0, create, start, flow, 0, stop, kill, sizeof(priv_t)
   };
   return &handler;
 }
--- a/src/biquad.c
+++ b/src/biquad.c
@@ -31,7 +31,7 @@
 static char const all_width_types[] = "hkboqs";
 
 
-int lsx_biquad_getopts(sox_effect_t * effp, int n, char **argv,
+int lsx_biquad_getopts(sox_effect_t * effp, int argc, char **argv,
     int min_args, int max_args, int fc_pos, int width_pos, int gain_pos,
     char const * allowed_width_types, filter_t filter_type)
 {
@@ -38,12 +38,13 @@
   priv_t * p = (priv_t *)effp->priv;
   char width_type = *allowed_width_types;
   char dummy, * dummy_p;     /* To check for extraneous chars. */
+  --argc, ++argv;
 
   p->filter_type = filter_type;
-  if (n < min_args || n > max_args ||
-      (n > fc_pos    && ((p->fc = lsx_parse_frequency(argv[fc_pos], &dummy_p)) <= 0 || *dummy_p)) ||
-      (n > width_pos && ((unsigned)(sscanf(argv[width_pos], "%lf%c %c", &p->width, &width_type, &dummy)-1) > 1 || p->width <= 0)) ||
-      (n > gain_pos  && sscanf(argv[gain_pos], "%lf %c", &p->gain, &dummy) != 1) ||
+  if (argc < min_args || argc > max_args ||
+      (argc > fc_pos    && ((p->fc = lsx_parse_frequency(argv[fc_pos], &dummy_p)) <= 0 || *dummy_p)) ||
+      (argc > width_pos && ((unsigned)(sscanf(argv[width_pos], "%lf%c %c", &p->width, &width_type, &dummy)-1) > 1 || p->width <= 0)) ||
+      (argc > gain_pos  && sscanf(argv[gain_pos], "%lf %c", &p->gain, &dummy) != 1) ||
       !strchr(allowed_width_types, width_type) || (width_type == 's' && p->width > 1))
     return lsx_usage(effp);
   p->width_type = strchr(all_width_types, width_type) - all_width_types;
--- a/src/biquads.c
+++ b/src/biquads.c
@@ -65,77 +65,77 @@
 typedef biquad_t priv_t;
 
 
-static int hilo1_getopts(sox_effect_t * effp, int n, char **argv) {
-  return lsx_biquad_getopts(effp, n, argv, 1, 1, 0, 1, 2, "",
+static int hilo1_getopts(sox_effect_t * effp, int argc, char **argv) {
+  return lsx_biquad_getopts(effp, argc, argv, 1, 1, 0, 1, 2, "",
       *effp->handler.name == 'l'? filter_LPF_1 : filter_HPF_1);
 }
 
 
-static int hilo2_getopts(sox_effect_t * effp, int n, char **argv) {
+static int hilo2_getopts(sox_effect_t * effp, int argc, char **argv) {
   priv_t * p = (priv_t *)effp->priv;
-  if (n != 0 && strcmp(argv[0], "-1") == 0)
-    return hilo1_getopts(effp, n - 1, argv + 1);
-  if (n != 0 && strcmp(argv[0], "-2") == 0)
-    ++argv, --n;
+  if (argc > 1 && strcmp(argv[1], "-1") == 0)
+    return hilo1_getopts(effp, argc - 1, argv + 1);
+  if (argc > 1 && strcmp(argv[1], "-2") == 0)
+    ++argv, --argc;
   p->width = sqrt(0.5); /* Default to Butterworth */
-  return lsx_biquad_getopts(effp, n, argv, 1, 2, 0, 1, 2, "qohk",
+  return lsx_biquad_getopts(effp, argc, argv, 1, 2, 0, 1, 2, "qohk",
       *effp->handler.name == 'l'? filter_LPF : filter_HPF);
 }
 
 
-static int bandpass_getopts(sox_effect_t * effp, int n, char **argv) {
+static int bandpass_getopts(sox_effect_t * effp, int argc, char **argv) {
   filter_t type = filter_BPF;
-  if (n != 0 && strcmp(argv[0], "-c") == 0)
-    ++argv, --n, type = filter_BPF_CSG;
-  return lsx_biquad_getopts(effp, n, argv, 2, 2, 0, 1, 2, "hkqob", type);
+  if (argc > 1 && strcmp(argv[1], "-c") == 0)
+    ++argv, --argc, type = filter_BPF_CSG;
+  return lsx_biquad_getopts(effp, argc, argv, 2, 2, 0, 1, 2, "hkqob", type);
 }
 
 
-static int bandrej_getopts(sox_effect_t * effp, int n, char **argv) {
-  return lsx_biquad_getopts(effp, n, argv, 2, 2, 0, 1, 2, "hkqob", filter_notch);
+static int bandrej_getopts(sox_effect_t * effp, int argc, char **argv) {
+  return lsx_biquad_getopts(effp, argc, argv, 2, 2, 0, 1, 2, "hkqob", filter_notch);
 }
 
 
-static int allpass_getopts(sox_effect_t * effp, int n, char **argv) {
+static int allpass_getopts(sox_effect_t * effp, int argc, char **argv) {
   filter_t type = filter_APF;
   int m;
-  if (n != 0 && strcmp(argv[0], "-1") == 0)
-    ++argv, --n, type = filter_AP1;
-  else if (n != 0 && strcmp(argv[0], "-2") == 0)
-    ++argv, --n, type = filter_AP2;
+  if (argc > 1 && strcmp(argv[1], "-1") == 0)
+    ++argv, --argc, type = filter_AP1;
+  else if (argc > 1 && strcmp(argv[1], "-2") == 0)
+    ++argv, --argc, type = filter_AP2;
   m = 1 + (type == filter_APF);
-  return lsx_biquad_getopts(effp, n, argv, m, m, 0, 1, 2, "hkqo", type);
+  return lsx_biquad_getopts(effp, argc, argv, m, m, 0, 1, 2, "hkqo", type);
 }
 
 
-static int tone_getopts(sox_effect_t * effp, int n, char **argv) {
+static int tone_getopts(sox_effect_t * effp, int argc, char **argv) {
   priv_t * p = (priv_t *)effp->priv;
   p->width = 0.5;
   p->fc = *effp->handler.name == 'b'? 100 : 3000;
-  return lsx_biquad_getopts(effp, n, argv, 1, 3, 1, 2, 0, "shkqo",
+  return lsx_biquad_getopts(effp, argc, argv, 1, 3, 1, 2, 0, "shkqo",
       *effp->handler.name == 'b'?  filter_lowShelf: filter_highShelf);
 }
 
 
-static int equalizer_getopts(sox_effect_t * effp, int n, char **argv) {
-  return lsx_biquad_getopts(effp, n, argv, 3, 3, 0, 1, 2, "qohk", filter_peakingEQ);
+static int equalizer_getopts(sox_effect_t * effp, int argc, char **argv) {
+  return lsx_biquad_getopts(effp, argc, argv, 3, 3, 0, 1, 2, "qohk", filter_peakingEQ);
 }
 
 
-static int band_getopts(sox_effect_t * effp, int n, char **argv) {
+static int band_getopts(sox_effect_t * effp, int argc, char **argv) {
   filter_t type = filter_BPF_SPK;
-  if (n != 0 && strcmp(argv[0], "-n") == 0)
-    ++argv, --n, type = filter_BPF_SPK_N;
-  return lsx_biquad_getopts(effp, n, argv, 1, 2, 0, 1, 2, "hkqo", type);
+  if (argc > 1 && strcmp(argv[1], "-n") == 0)
+    ++argv, --argc, type = filter_BPF_SPK_N;
+  return lsx_biquad_getopts(effp, argc, argv, 1, 2, 0, 1, 2, "hkqo", type);
 }
 
 
-static int deemph_getopts(sox_effect_t * effp, int n, char **argv) {
+static int deemph_getopts(sox_effect_t * effp, int argc, char **argv) {
   priv_t * p = (priv_t *)effp->priv;
   p->fc    = 5283;
   p->width = 0.4845;
   p->gain  = -9.477;
-  return lsx_biquad_getopts(effp, n, argv, 0, 0, 0, 1, 2, "s", filter_deemph);
+  return lsx_biquad_getopts(effp, argc, argv, 0, 0, 0, 1, 2, "s", filter_deemph);
 }
 
 
@@ -143,7 +143,7 @@
   priv_t * p = (priv_t *)effp->priv;
   p->filter_type = filter_riaa;
   (void)argv;
-  return argc? lsx_usage(effp) : SOX_SUCCESS;
+  return --argc? lsx_usage(effp) : SOX_SUCCESS;
 }
 
 
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -89,20 +89,21 @@
 /*
  * Process options
  */
-static int sox_chorus_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_chorus_getopts(sox_effect_t * effp, int argc, char **argv)
 {
         priv_t * chorus = (priv_t *) effp->priv;
         int i;
+  --argc, ++argv;
 
         chorus->num_chorus = 0;
         i = 0;
 
-        if ( ( n < 7 ) || (( n - 2 ) % 5 ) )
+        if ( ( argc < 7 ) || (( argc - 2 ) % 5 ) )
           return lsx_usage(effp);
 
         sscanf(argv[i++], "%f", &chorus->in_gain);
         sscanf(argv[i++], "%f", &chorus->out_gain);
-        while ( i < n ) {
+        while ( i < argc ) {
                 if ( chorus->num_chorus > MAX_CHORUS )
                 {
                         lsx_fail("chorus: to many delays, use less than %i delays", MAX_CHORUS);
--- a/src/compand.c
+++ b/src/compand.c
@@ -60,7 +60,7 @@
   int delay_buf_full;       /* Shows buffer situation (important for drain) */
 } priv_t;
 
-static int getopts(sox_effect_t * effp, int n, char * * argv)
+static int getopts(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * l = (priv_t *) effp->priv;
   char * s;
@@ -67,7 +67,8 @@
   char dummy;     /* To check for extraneous chars. */
   unsigned pairs, i, j, commas;
 
-  if (n < 2 || n > 5)
+  --argc, ++argv;
+  if (argc < 2 || argc > 5)
     return lsx_usage(effp);
 
   /* Start by checking the attack and decay rates */
@@ -95,7 +96,7 @@
     }
   }
 
-  if (!lsx_compandt_parse(&l->transfer_fn, argv[1], n>2 ? argv[2] : 0))
+  if (!lsx_compandt_parse(&l->transfer_fn, argv[1], argc>2 ? argv[2] : 0))
     return SOX_EOF;
 
   /* Set the initial "volume" to be attibuted to the input channels.
@@ -103,7 +104,7 @@
      result if the user has seleced a long attack time */
   for (i = 0; i < l->expectedChannels; ++i) {
     double init_vol_dB = 0;
-    if (n > 3 && sscanf(argv[3], "%lf %c", &init_vol_dB, &dummy) != 1) {
+    if (argc > 3 && sscanf(argv[3], "%lf %c", &init_vol_dB, &dummy) != 1) {
       lsx_fail("syntax error trying to read initial volume");
       return SOX_EOF;
     } else if (init_vol_dB > 0) {
@@ -114,7 +115,7 @@
   }
 
   /* If there is a delay, store it. */
-  if (n > 4 && sscanf(argv[4], "%lf %c", &l->delay, &dummy) != 1) {
+  if (argc > 4 && sscanf(argv[4], "%lf %c", &l->delay, &dummy) != 1) {
     lsx_fail("syntax error trying to read delay value");
     return SOX_EOF;
   } else if (l->delay < 0) {
--- a/src/contrast.c
+++ b/src/contrast.c
@@ -23,6 +23,7 @@
 {
   priv_t * p = (priv_t *)effp->priv;
   p->contrast = 75;
+  --argc, ++argv;
   do {NUMERIC_PARAMETER(contrast, 0, 100)} while (0);
   p->contrast /= 750; /* shift range to 0 to 0.1333, default 0.1 */
   return argc? lsx_usage(effp) : SOX_SUCCESS;
--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -25,19 +25,20 @@
 /*
  * Process options: dcshift (double) type (amplitude, power, dB)
  */
-static int sox_dcshift_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_dcshift_getopts(sox_effect_t * effp, int argc, char **argv)
 {
     priv_t * dcs = (priv_t *) effp->priv;
     dcs->dcshift = 1.0; /* default is no change */
     dcs->uselimiter = 0; /* default is no limiter */
 
-    if (n < 1)
+  --argc, ++argv;
+    if (argc < 1)
       return lsx_usage(effp);
 
-    if (n && (!sscanf(argv[0], "%lf", &dcs->dcshift)))
+    if (argc && (!sscanf(argv[0], "%lf", &dcs->dcshift)))
       return lsx_usage(effp);
 
-    if (n>1)
+    if (argc>1)
     {
         if (!sscanf(argv[1], "%lf", &dcs->limitergain))
           return lsx_usage(effp);
--- a/src/delay.c
+++ b/src/delay.c
@@ -42,9 +42,10 @@
   size_t delay, max_samples = 0;
   unsigned i;
 
+  --argc, ++argv;
   p->argv = lsx_calloc(p->argc = argc, sizeof(*p->argv));
   for (i = 0; i < p->argc; ++i) {
-    char const * next = lsx_parsesamples(96000., p->argv[i] = lsx_strdup(argv[i]), &delay, 't');
+    char const * next = lsx_parsesamples(1e5, p->argv[i] = lsx_strdup(argv[i]), &delay, 't');
     if (!next || *next) {
       kill(effp);
       return lsx_usage(effp);
--- a/src/dither.c
+++ b/src/dither.c
@@ -270,7 +270,7 @@
     "\n           modified-e-weighted, improved-e-weighted, gesemann,"
     "\n           shibata, low-shibata, high-shibata."
     "\n  depth    Noise depth; 0.5 to 1; default 1",
-    SOX_EFF_GETOPT | SOX_EFF_PREC, getopts, start, flow, 0, 0, 0, sizeof(priv_t)
+    SOX_EFF_PREC, getopts, start, flow, 0, 0, 0, sizeof(priv_t)
   };
   return &handler;
 }
--- a/src/echo.c
+++ b/src/echo.c
@@ -67,20 +67,21 @@
 /*
  * Process options
  */
-static int sox_echo_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_echo_getopts(sox_effect_t * effp, int argc, char **argv)
 {
         priv_t * echo = (priv_t *) effp->priv;
         int i;
 
+  --argc, ++argv;
         echo->num_delays = 0;
 
-        if ((n < 4) || (n % 2))
+        if ((argc < 4) || (argc % 2))
           return lsx_usage(effp);
 
         i = 0;
         sscanf(argv[i++], "%f", &echo->in_gain);
         sscanf(argv[i++], "%f", &echo->out_gain);
-        while (i < n) {
+        while (i < argc) {
                 if ( echo->num_delays >= MAX_ECHOS )
                         lsx_fail("echo: to many delays, use less than %i delays",
                                 MAX_ECHOS);
--- a/src/echos.c
+++ b/src/echos.c
@@ -62,7 +62,7 @@
 /*
  * Process options
  */
-static int sox_echos_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_echos_getopts(sox_effect_t * effp, int argc, char **argv)
 {
         priv_t * echos = (priv_t *) effp->priv;
         int i;
@@ -69,13 +69,14 @@
 
         echos->num_delays = 0;
 
-        if ((n < 4) || (n % 2))
+  --argc, ++argv;
+        if ((argc < 4) || (argc % 2))
           return lsx_usage(effp);
 
         i = 0;
         sscanf(argv[i++], "%f", &echos->in_gain);
         sscanf(argv[i++], "%f", &echos->out_gain);
-        while (i < n) {
+        while (i < argc) {
                 /* Linux bug and it's cleaner. */
                 sscanf(argv[i++], "%f", &echos->delay[echos->num_delays]);
                 sscanf(argv[i++], "%f", &echos->decay[echos->num_delays]);
--- a/src/effects.c
+++ b/src/effects.c
@@ -60,7 +60,7 @@
 /* Check that no parameters have been given */
 static int default_getopts(sox_effect_t * effp, int argc, char **argv UNUSED)
 {
-  return argc? lsx_usage(effp) : SOX_SUCCESS;
+  return --argc? lsx_usage(effp) : SOX_SUCCESS;
 }
 
 /* Partially initialise the effect structure; signal info will come later */
@@ -86,11 +86,13 @@
 {
   int result, callers_optind = optind, callers_opterr = opterr;
 
-  if (effp->handler.flags & SOX_EFF_GETOPT)
-    --argv, ++argc; /* FIXME: push this processing back up the stack */
+  char * * argv2 = lsx_malloc((argc + 1) * sizeof(*argv2));
+  argv2[0] = (char *)effp->handler.name;
+  memcpy(argv2 + 1, argv, argc * sizeof(*argv2));
   optind = 1, opterr = 0;
-  result = effp->handler.getopts(effp, argc, (char * *)argv);
+  result = effp->handler.getopts(effp, argc + 1, argv2);
   optind = callers_optind, opterr = callers_opterr;
+  free(argv2);
   return result;
 } /* sox_effect_options */
 
--- a/src/example0.c
+++ b/src/example0.c
@@ -56,19 +56,19 @@
    * samples; in this case, we use the built-in handler that inputs
    * data from an audio file */
   e = sox_create_effect(sox_find_effect("input"));
-  args[0] = (char *)in, assert(e->handler.getopts(e, 1, args) == SOX_SUCCESS);
+  args[0] = (char *)in, assert(sox_effect_options(e, 1, args) == SOX_SUCCESS);
   /* This becomes the first `effect' in the chain */
   assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
 
   /* Create the `vol' effect, and initialise it with the desired parameters: */
   e = sox_create_effect(sox_find_effect("vol"));
-  args[0] = "3dB", assert(e->handler.getopts(e, 1, args) == SOX_SUCCESS);
+  args[0] = "3dB", assert(sox_effect_options(e, 1, args) == SOX_SUCCESS);
   /* Add the effect to the end of the effects processing chain: */
   assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
 
   /* Create the `flanger' effect, and initialise it with default parameters: */
   e = sox_create_effect(sox_find_effect("flanger"));
-  assert(e->handler.getopts(e, 0, NULL) == SOX_SUCCESS);
+  assert(sox_effect_options(e, 0, NULL) == SOX_SUCCESS);
   /* Add the effect to the end of the effects processing chain: */
   assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
 
@@ -76,7 +76,7 @@
    * samples; in this case, we use the built-in handler that outputs
    * data to an audio file */
   e = sox_create_effect(sox_find_effect("output"));
-  args[0] = (char *)out, assert(e->handler.getopts(e, 1, args) == SOX_SUCCESS);
+  args[0] = (char *)out, assert(sox_effect_options(e, 1, args) == SOX_SUCCESS);
   assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
 
   /* Flow samples through the effects processing chain until EOF is reached */
--- a/src/example1.c
+++ b/src/example1.c
@@ -133,13 +133,13 @@
 
   /* Create the `vol' effect, and initialise it with the desired parameters: */
   e = sox_create_effect(sox_find_effect("vol"));
-  assert(e->handler.getopts(e, 1, vol) == SOX_SUCCESS);
+  assert(sox_effect_options(e, 1, vol) == SOX_SUCCESS);
   /* Add the effect to the end of the effects processing chain: */
   assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
 
   /* Create the `flanger' effect, and initialise it with default parameters: */
   e = sox_create_effect(sox_find_effect("flanger"));
-  assert(e->handler.getopts(e, 0, NULL) == SOX_SUCCESS);
+  assert(sox_effect_options(e, 0, NULL) == SOX_SUCCESS);
   /* Add the effect to the end of the effects processing chain: */
   assert(sox_add_effect(chain, e, &in->signal, &in->signal) == SOX_SUCCESS);
 
--- a/src/fade.c
+++ b/src/fade.c
@@ -41,14 +41,15 @@
  * The 'info' fields are not yet filled in.
  */
 
-static int sox_fade_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_fade_getopts(sox_effect_t * effp, int argc, char **argv)
 {
 
     priv_t * fade = (priv_t *) effp->priv;
     char t_char[2];
     int t_argno;
+  --argc, ++argv;
 
-    if (n < 1 || n > 4)
+    if (argc < 1 || argc > 4)
          return lsx_usage(effp);
 
     /* because sample rate is unavailable at this point we store the
@@ -61,7 +62,7 @@
         fade->out_fadetype = *t_char;
 
         argv++;
-        n--;
+        argc--;
     }
     else
     {
@@ -78,7 +79,7 @@
 
     fade->out_start_str = fade->out_stop_str = 0;
 
-    for (t_argno = 1; t_argno < n && t_argno < 3; t_argno++)
+    for (t_argno = 1; t_argno < argc && t_argno < 3; t_argno++)
     {
         /* See if there is fade-in/fade-out times/curves specified. */
         if(t_argno == 1)
--- a/src/filter.c
+++ b/src/filter.c
@@ -161,15 +161,16 @@
 /*
  * Process options
  */
-static int sox_filter_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_filter_getopts(sox_effect_t * effp, int argc, char **argv)
 {
         priv_t * f = (priv_t *) effp->priv;
+  --argc, ++argv;
 
         f->beta = 16;  /* Kaiser window, beta 16 */
         f->Nwin = 128;
 
         f->freq0 = f->freq1 = 0;
-        if (n >= 1) {
+        if (argc >= 1) {
                 char *p;
                 p = argv[0];
                 if (*p != '-') {
@@ -185,7 +186,7 @@
         if (f->freq0 == 0 && f->freq1 == 0)
           return lsx_usage(effp);
 
-        if ((n >= 2) && !sscanf(argv[1], "%ld", &f->Nwin))
+        if ((argc >= 2) && !sscanf(argv[1], "%ld", &f->Nwin))
           return lsx_usage(effp);
         else if (f->Nwin < 4) {
                 lsx_fail("filter: window length (%ld) <4 is too short", f->Nwin);
@@ -192,7 +193,7 @@
                 return (SOX_EOF);
         }
 
-        if ((n >= 3) && !sscanf(argv[2], "%lf", &f->beta))
+        if ((argc >= 3) && !sscanf(argv[2], "%lf", &f->beta))
           return lsx_usage(effp);
 
         lsx_debug("filter opts: %g-%g, window-len %ld, beta %f", f->freq0, f->freq1, f->Nwin, f->beta);
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -62,6 +62,7 @@
 static int getopts(sox_effect_t * effp, int argc, char *argv[])
 {
   priv_t * p = (priv_t *) effp->priv;
+  --argc, ++argv;
 
   /* Set non-zero defaults: */
   p->delay_depth  = 2;
--- a/src/input.c
+++ b/src/input.c
@@ -22,7 +22,7 @@
 static int getopts(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
-  if (argc != 1 || !(p->file = (sox_format_t *)argv[0]) || p->file->mode != 'r')
+  if (argc != 2 || !(p->file = (sox_format_t *)argv[1]) || p->file->mode != 'r')
     return SOX_EOF;
   return SOX_SUCCESS;
 }
--- a/src/ladspa.c
+++ b/src/ladspa.c
@@ -81,7 +81,7 @@
 /*
  * Process options
  */
-static int sox_ladspa_getopts(sox_effect_t *effp, int n, char **argv)
+static int sox_ladspa_getopts(sox_effect_t *effp, int argc, char **argv)
 {
   priv_t * l_st = (priv_t *)effp->priv;
   char *path;
@@ -88,14 +88,15 @@
   union {LADSPA_Descriptor_Function fn; lt_ptr ptr;} ltptr;
   unsigned long index = 0, i;
   double arg;
+  --argc, ++argv;
 
   l_st->input_port = ULONG_MAX;
   l_st->output_port = ULONG_MAX;
 
   /* Get module name */
-  if (n >= 1) {
+  if (argc >= 1) {
     l_st->name = argv[0];
-    n--; argv++;
+    argc--; argv++;
   }
 
   /* Load module */
@@ -126,7 +127,7 @@
 
   /* If more than one plugin, or first argument is not a number, try
      to use first argument as plugin label. */
-  if (n > 0 && (ltptr.fn(1UL) != NULL || !sscanf(argv[0], "%lf", &arg))) {
+  if (argc > 0 && (ltptr.fn(1UL) != NULL || !sscanf(argv[0], "%lf", &arg))) {
     while (l_st->desc && strcmp(l_st->desc->Label, argv[0]) != 0)
       l_st->desc = ltptr.fn(++index);
     if (l_st->desc == NULL) {
@@ -133,7 +134,7 @@
       lsx_fail("no plugin called `%s' found", argv[0]);
       return SOX_EOF;
     } else
-      n--; argv++;
+      argc--; argv++;
   }
 
   /* Scan the ports to check there's one input and one output */
@@ -166,7 +167,7 @@
         l_st->output_port = i;
       }
     } else {                    /* Control port */
-      if (n == 0) {
+      if (argc == 0) {
         if (!LADSPA_IS_HINT_HAS_DEFAULT(l_st->desc->PortRangeHints[i].HintDescriptor)) {
           lsx_fail("not enough arguments for control ports");
           return SOX_EOF;
@@ -178,13 +179,13 @@
           return lsx_usage(effp);
         l_st->control[i] = (LADSPA_Data)arg;
         lsx_debug("argument for port %lu is %f", i, l_st->control[i]);
-        n--; argv++;
+        argc--; argv++;
       }
     }
   }
 
   /* Stop if we have any unused arguments */
-  return n? lsx_usage(effp) : SOX_SUCCESS;
+  return argc? lsx_usage(effp) : SOX_SUCCESS;
 }
 
 /*
--- a/src/loudness.c
+++ b/src/loudness.c
@@ -33,6 +33,7 @@
   p->delta = -10;
   p->start = 65;
   p->n = 1023;
+  --argc, ++argv;
   do {                    /* break-able block */
     NUMERIC_PARAMETER(delta,-50 , 15) /* FIXME expand range */
     NUMERIC_PARAMETER(start, 50 , 75) /* FIXME expand range */
--- a/src/lowfir.c
+++ b/src/lowfir.c
@@ -15,6 +15,12 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+/* This is W.I.P. hence marked SOX_EFF_DEPRECATED for now.
+ * Need to add other filter types (and rename file), and add a decent
+ * user interface.  When this is done, it should be a more user-friendly
+ * & more capable version of the `filter' effect.
+ */
+
 #include "sox_i.h"
 #include "dft_filter.h"
 #include <string.h>
@@ -33,6 +39,7 @@
   double * h;
   int i;
   b->filter_ptr = &b->filter;
+  --argc, ++argv;
   do {                    /* break-able block */
     NUMERIC_PARAMETER(Fp, 0, 100);
     NUMERIC_PARAMETER(Fc, 0, 100);
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -160,23 +160,24 @@
       return SOX_SUCCESS;
 }
 
-static int getopts(sox_effect_t * effp, int n, char **argv)
+static int getopts(sox_effect_t * effp, int argc, char **argv)
 {
   char *subargv[6], *cp;
   size_t subargc, i, len;
 
   priv_t * c = (priv_t *) effp->priv;
+  --argc, ++argv;
 
   c->band_buf1 = c->band_buf2 = c->band_buf3 = 0;
   c->band_buf_len = 0;
 
   /* how many bands? */
-  if (! (n&1)) {
-    lsx_fail("mcompand accepts only an odd number of arguments:\n"
+  if (! (argc&1)) {
+    lsx_fail("mcompand accepts only an odd number of arguments:\argc"
             "  mcompand quoted_compand_args [crossover_freq quoted_compand_args [...]");
     return SOX_EOF;
   }
-  c->nBands = (n+1)>>1;
+  c->nBands = (argc+1)>>1;
 
   c->bands = lsx_calloc(c->nBands, sizeof(comp_band_t));
 
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -38,11 +38,12 @@
 /*
  * Process options
  */
-static int getopts(sox_effect_t * effp, int n, char **argv)
+static int getopts(sox_effect_t * effp, int argc, char **argv)
 {
     priv_t * mixer = (priv_t *) effp->priv;
     double* pans = &mixer->sources[0][0];
     int i;
+  --argc, ++argv;
 
     for (i = 0;  i < 16;  i++)
         pans[i] = 0.0;
@@ -52,7 +53,7 @@
     /* Parse parameters.  Since we don't yet know the number of */
     /* input and output channels, we'll record the information for */
     /* later. */
-    if (n == 1) {
+    if (argc == 1) {
         if      (!strcmp(argv[0], "-l")) mixer->mix = 'l';
         else if (!strcmp(argv[0], "-r")) mixer->mix = 'r';
         else if (!strcmp(argv[0], "-f")) mixer->mix = 'f';
@@ -82,7 +83,7 @@
             mixer->num_pans = commas + 1;
         }
     }
-    else if (n == 0) {
+    else if (argc == 0) {
         mixer->mix = MIX_CENTER;
     }
     else
@@ -538,10 +539,11 @@
   return &handler;
 }
 
-static int oops_getopts(sox_effect_t * effp, int argc, char * * argv UNUSED)
+static int oops_getopts(sox_effect_t * effp, int argc, char * * argv)
 {
-  char * args[] = {"1,1,-1,-1"};
-  return argc? lsx_usage(effp) : sox_mixer_effect_fn()->getopts(effp, (int)array_length(args), args);
+  char * args[] = {0, "1,1,-1,-1"};
+  args[0] = argv[0];
+  return --argc? lsx_usage(effp) : sox_mixer_effect_fn()->getopts(effp, (int)array_length(args), args);
 }
 
 sox_effect_handler_t const * sox_oops_effect_fn(void)
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -42,13 +42,14 @@
 /*
  * Get the filename, if any. We don't open it until sox_noiseprof_start.
  */
-static int sox_noiseprof_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_noiseprof_getopts(sox_effect_t * effp, int argc, char **argv)
 {
     priv_t * data = (priv_t *) effp->priv;
+  --argc, ++argv;
 
-    if (n == 1) {
+    if (argc == 1) {
         data->output_filename = argv[0];
-    } else if (n > 1)
+    } else if (argc > 1)
       return lsx_usage(effp);
 
     return (SOX_SUCCESS);
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -60,6 +60,7 @@
 static int sox_noisered_getopts(sox_effect_t * effp, int argc, char **argv)
 {
   priv_t * p = (priv_t *) effp->priv;
+  --argc, ++argv;
 
   if (argc > 0) {
     p->profile_filename = argv[0];
--- a/src/normalise.c
+++ b/src/normalise.c
@@ -31,6 +31,7 @@
 static int create(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
+  --argc, ++argv;
   if (argc && !strcmp(*argv, "-i")) p->individual = sox_true, ++argv, --argc;
   if (argc && !strcmp(*argv, "-b")) p->balance = sox_true, ++argv, --argc;
   do {NUMERIC_PARAMETER(level, -100, 0)} while (0);
--- a/src/output.c
+++ b/src/output.c
@@ -22,7 +22,7 @@
 static int getopts(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
-  if (argc != 1 || !(p->file = (sox_format_t *)argv[0]) || p->file->mode != 'w')
+  if (argc != 2 || !(p->file = (sox_format_t *)argv[1]) || p->file->mode != 'w')
     return SOX_EOF;
   return SOX_SUCCESS;
 }
--- a/src/overdrive.c
+++ b/src/overdrive.c
@@ -24,6 +24,7 @@
 static int create(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
+  --argc, ++argv;
   p->gain = p->colour = 20;
   do {
     NUMERIC_PARAMETER(gain, 0, 100)
--- a/src/pad.c
+++ b/src/pad.c
@@ -55,11 +55,12 @@
   return SOX_SUCCESS;
 }
 
-static int create(sox_effect_t * effp, int n, char * * argv)
+static int create(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
-  p->pads = lsx_calloc(p->npads = n, sizeof(*p->pads));
-  return parse(effp, argv, 96000.); /* No rate yet; parse with dummy */
+  --argc, ++argv;
+  p->pads = lsx_calloc(p->npads = argc, sizeof(*p->pads));
+  return parse(effp, argv, 1e5); /* No rate yet; parse with dummy */
 }
 
 static int start(sox_effect_t * effp)
--- a/src/pan.c
+++ b/src/pan.c
@@ -37,13 +37,14 @@
 /*
  * Process options
  */
-static int sox_pan_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_pan_getopts(sox_effect_t * effp, int argc, char **argv)
 {
     priv_t * pan = (priv_t *) effp->priv;
+  --argc, ++argv;
 
     pan->direction = 0.0; /* default is no change */
 
-    if (n && (!sscanf(argv[0], "%lf", &pan->direction) ||
+    if (argc && (!sscanf(argv[0], "%lf", &pan->direction) ||
               pan->direction < -1.0 || pan->direction > 1.0))
       return lsx_usage(effp);
 
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -69,6 +69,7 @@
   p->decay     = .4;
   p->mod_speed = .5;
 
+  --argc, ++argv;
   do { /* break-able block */
     NUMERIC_PARAMETER(in_gain  , .0, 1)
     NUMERIC_PARAMETER(out_gain , .0, 1e9)
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -59,15 +59,16 @@
 /*
  * Process options
  */
-static int sox_poly_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_poly_getopts(sox_effect_t * effp, int argc, char **argv)
 {
   priv_t * rate = (priv_t *) effp->priv;
+  --argc, ++argv;
 
   rate->win_type = 0;           /* 0: nuttall, 1: hamming */
   rate->win_width = 1024;
   rate->cutoff = 0.95;
 
-  while (n >= 2) {
+  while (argc >= 2) {
     /* Window type check */
     if(!strcmp(argv[0], "-w")) {
       if(!strcmp(argv[1], "ham"))
@@ -75,7 +76,7 @@
       if(!strcmp(argv[1], "nut"))
         rate->win_type = 0;
       argv += 2;
-      n -= 2;
+      argc -= 2;
       continue;
     }
 
@@ -83,7 +84,7 @@
     if(!strcmp(argv[0], "-width")) {
         rate->win_width = atoi(argv[1]);
       argv += 2;
-      n -= 2;
+      argc -= 2;
       continue;
     }
 
@@ -91,7 +92,7 @@
     if(!strcmp(argv[0], "-cutoff")) {
       rate->cutoff = atof(argv[1]);
       argv += 2;
-      n -= 2;
+      argc -= 2;
       continue;
     }
 
--- a/src/rabbit.c
+++ b/src/rabbit.c
@@ -41,6 +41,7 @@
 {
   priv_t * r = (priv_t *) effp->priv;
   char dummy;     /* To check for extraneous chars. */
+  --argc, ++argv;
 
   r->converter_type = SRC_SINC_BEST_QUALITY;
 
--- a/src/rate.c
+++ b/src/rate.c
@@ -539,8 +539,7 @@
 sox_effect_handler_t const * sox_rate_effect_fn(void)
 {
   static sox_effect_handler_t handler = {
-    "rate", 0, SOX_EFF_RATE | SOX_EFF_GETOPT,
-    create, start, flow, drain, stop, 0, sizeof(priv_t)
+    "rate", 0, SOX_EFF_RATE, create, start, flow, drain, stop, 0, sizeof(priv_t)
   };
   static char const * lines[] = {
     "[-q|-l|-m|-h|-v] [override-options] RATE[k]",
--- a/src/remix.c
+++ b/src/remix.c
@@ -101,6 +101,7 @@
 static int create(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
+  --argc, ++argv;
   if (argc && !strcmp(*argv, "-m")) p->mode = manual   , ++argv, --argc;
   if (argc && !strcmp(*argv, "-a")) p->mode = automatic, ++argv, --argc;
   if (argc && !strcmp(*argv, "-p")) p->mix_power = sox_true, ++argv, --argc;
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -28,6 +28,7 @@
 {
   priv_t * p = (priv_t *)effp->priv;
   p->num_repeats = 1;
+  --argc, ++argv;
   do {NUMERIC_PARAMETER(num_repeats, 0, UINT_MAX - 1)} while (0);
   return argc? lsx_usage(effp) : SOX_SUCCESS;
 }
--- a/src/resample.c
+++ b/src/resample.c
@@ -130,9 +130,10 @@
 /*
  * Process options
  */
-static int getopts(sox_effect_t * effp, int n, char **argv)
+static int getopts(sox_effect_t * effp, int argc, char **argv)
 {
         priv_t * r = (priv_t *) effp->priv;
+  --argc, ++argv;
 
         /* These defaults are conservative with respect to aliasing. */
         r->rolloff = 0.80;
@@ -140,26 +141,26 @@
         r->quadr = 0;
         r->Nmult = 45;
 
-        if (n >= 1) {
+        if (argc >= 1) {
                 if (!strcmp(argv[0], "-qs")) {
                         r->quadr = 1;
-                        n--; argv++;
+                        argc--; argv++;
                 }
                 else if (!strcmp(argv[0], "-q")) {
                         r->rolloff = 0.875;
                         r->quadr = 1;
                         r->Nmult = 75;
-                        n--; argv++;
+                        argc--; argv++;
                 }
                 else if (!strcmp(argv[0], "-ql")) {
                         r->rolloff = 0.94;
                         r->quadr = 1;
                         r->Nmult = 149;
-                        n--; argv++;
+                        argc--; argv++;
                 }
         }
 
-        if ((n >= 1) && (sscanf(argv[0], "%lf", &r->rolloff) != 1)) {
+        if ((argc >= 1) && (sscanf(argv[0], "%lf", &r->rolloff) != 1)) {
           return lsx_usage(effp);
         } else if ((r->rolloff <= 0.01) || (r->rolloff >= 1.0)) {
           lsx_fail("rolloff factor (%f) no good, should be 0.01<x<1.0", r->rolloff);
@@ -167,7 +168,7 @@
         }
 
 
-        if ((n >= 2) && !sscanf(argv[1], "%lf", &r->beta)) {
+        if ((argc >= 2) && !sscanf(argv[1], "%lf", &r->beta)) {
           return lsx_usage(effp);
         } else if (r->beta <= 2.0) {
         	r->beta = 0;
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -176,6 +176,7 @@
   p->reverberance = p->hf_damping = 50; /* Set non-zero defaults */
   p->stereo_depth = p->room_scale = 100;
 
+  --argc, ++argv;
   p->wet_only = argc && (!strcmp(*argv, "-w") || !strcmp(*argv, "--wet-only"))
     && (--argc, ++argv, sox_true);
   do {  /* break-able block */
--- a/src/silence.c
+++ b/src/silence.c
@@ -76,22 +76,23 @@
     silence->rms_sum = 0;
 }
 
-static int sox_silence_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_silence_getopts(sox_effect_t * effp, int argc, char **argv)
 {
     priv_t *   silence = (priv_t *) effp->priv;
     int parse_count;
+  --argc, ++argv;
 
     /* check for option switches */
     silence->leave_silence = sox_false;
-    if (n > 0)
+    if (argc > 0)
     {
         if (!strcmp("-l", *argv)) {
-            n--; argv++;
+            argc--; argv++;
             silence->leave_silence = sox_true;
         }
     }
 
-    if (n < 1)
+    if (argc < 1)
       return lsx_usage(effp);
 
     /* Parse data related to trimming front side */
@@ -104,12 +105,12 @@
         return(SOX_EOF);
     }
     argv++;
-    n--;
+    argc--;
 
     if (silence->start_periods > 0)
     {
         silence->start = sox_true;
-        if (n < 2)
+        if (argc < 2)
           return lsx_usage(effp);
 
         /* We do not know the sample rate so we can not fully
@@ -131,14 +132,14 @@
             silence->start_unit = '%';
 
         argv++; argv++;
-        n--; n--;
+        argc--; argc--;
     }
 
     silence->stop = sox_false;
     /* Parse data needed for trimming of backside */
-    if (n > 0)
+    if (argc > 0)
     {
-        if (n < 3)
+        if (argc < 3)
           return lsx_usage(effp);
         if (sscanf(argv[0], "%d", &silence->stop_periods) != 1)
           return lsx_usage(effp);
@@ -151,7 +152,7 @@
             silence->restart = 0;
         silence->stop = sox_true;
         argv++;
-        n--;
+        argc--;
 
         /* We do not know the sample rate so we can not fully
          * parse the duration info yet.  So save argument off
@@ -172,7 +173,7 @@
             silence->stop_unit = '%';
 
         argv++; argv++;
-        n--; n--;
+        argc--; argc--;
     }
 
     /* Error checking */
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -29,14 +29,16 @@
  * initialization now: effp->in_signal & effp->out_signal are not
  * yet filled in.
  */
-static int getopts(sox_effect_t * effp, int n, char UNUSED **argv)
+static int getopts(sox_effect_t * effp, int argc, char UNUSED **argv)
 {
   priv_t * UNUSED p = (priv_t *)effp->priv;
 
-  if (n && n != 1)
+  if (argc != 2)
     return lsx_usage(effp);
 
-  return SOX_SUCCESS;
+  p->localdata = atoi(argv[1]);
+
+  return p->localdata > 0 ? SOX_SUCCESS : SOX_EOF;
 }
 
 /*
--- a/src/sox.h
+++ b/src/sox.h
@@ -451,7 +451,6 @@
 #define SOX_EFF_MCHAN    16          /* Effect can handle multi-channel */
 #define SOX_EFF_NULL     32          /* Effect does nothing */
 #define SOX_EFF_DEPRECATED 64        /* Effect is living on borrowed time */
-#define SOX_EFF_GETOPT   128         /* FIXME eliminate: Effect uses getopt */
 
 typedef enum {sox_plot_off, sox_plot_octave, sox_plot_gnuplot} sox_plot_t;
 typedef struct sox_effect sox_effect_t;
--- a/src/spectrogram.c
+++ b/src/spectrogram.c
@@ -494,8 +494,7 @@
 sox_effect_handler_t const * sox_spectrogram_effect_fn(void)
 {
   static sox_effect_handler_t handler = {
-    "spectrogram", NULL, SOX_EFF_GETOPT,
-    getopts, start, flow, drain, stop, NULL, sizeof(priv_t)};
+    "spectrogram", 0, 0, getopts, start, flow, drain, stop, 0, sizeof(priv_t)};
   static char const * lines[] = {
     "[options]",
     "\t-x num\tX-axis pixels/second, default 100",
--- a/src/speed.c
+++ b/src/speed.c
@@ -28,12 +28,13 @@
   double factor;
 } priv_t;
 
-static int getopts(sox_effect_t * effp, int n, char * * argv)
+static int getopts(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *) effp->priv;
   sox_bool is_cents = sox_false;
 
-  if (n == 1) {
+  --argc, ++argv;
+  if (argc == 1) {
     char c, dummy;
     int scanned = sscanf(*argv, "%lf%c %c", &p->factor, &c, &dummy);
     if (scanned == 1 || (scanned == 2 && c == 'c')) {
--- a/src/splice.c
+++ b/src/splice.c
@@ -125,11 +125,12 @@
   return SOX_SUCCESS;
 }
 
-static int create(sox_effect_t * effp, int n, char * * argv)
+static int create(sox_effect_t * effp, int argc, char * * argv)
 {
   priv_t * p = (priv_t *)effp->priv;
-  p->splices = lsx_calloc(p->nsplices = n, sizeof(*p->splices));
-  return parse(effp, argv, 96000.); /* No rate yet; parse with dummy */
+  --argc, ++argv;
+  p->splices = lsx_calloc(p->nsplices = argc, sizeof(*p->splices));
+  return parse(effp, argv, 1e5); /* No rate yet; parse with dummy */
 }
 
 static int start(sox_effect_t * effp)
--- a/src/stat.c
+++ b/src/stat.c
@@ -40,7 +40,7 @@
 /*
  * Process options
  */
-static int sox_stat_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_stat_getopts(sox_effect_t * effp, int argc, char **argv)
 {
   priv_t * stat = (priv_t *) effp->priv;
 
@@ -49,15 +49,16 @@
   stat->srms = 0;
   stat->fft = 0;
 
-  for (; n > 0; n--, argv++) {
+  --argc, ++argv;
+  for (; argc > 0; argc--, argv++) {
     if (!(strcmp(*argv, "-v")))
       stat->volume = 1;
     else if (!(strcmp(*argv, "-s"))) {
-      if (n <= 1) {
+      if (argc <= 1) {
         lsx_fail("-s option: invalid argument");
         return SOX_EOF;
       }
-      n--, argv++;              /* Move to next argument. */
+      argc--, argv++;              /* Move to next argument. */
       if (!sscanf(*argv, "%lf", &stat->scale)) {
         lsx_fail("-s option: invalid argument");
         return SOX_EOF;
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -56,25 +56,26 @@
 /*
  * Process options
  */
-static int getopts(sox_effect_t * effp, int n, char **argv)
+static int getopts(sox_effect_t * effp, int argc, char **argv)
 {
   priv_t * p = (priv_t *) effp->priv;
+  --argc, ++argv;
 
   /* default options */
   p->factor = 1.0; /* default is no change */
   p->window = DEFAULT_STRETCH_WINDOW;
 
-  if (n > 0 && !sscanf(argv[0], "%lf", &p->factor)) {
+  if (argc > 0 && !sscanf(argv[0], "%lf", &p->factor)) {
     lsx_fail("error while parsing factor");
     return lsx_usage(effp);
   }
 
-  if (n > 1 && !sscanf(argv[1], "%lf", &p->window)) {
+  if (argc > 1 && !sscanf(argv[1], "%lf", &p->window)) {
     lsx_fail("error while parsing window size");
     return lsx_usage(effp);
   }
 
-  if (n > 2) {
+  if (argc > 2) {
     switch (argv[2][0]) {
     case 'l':
     case 'L':
@@ -89,7 +90,7 @@
   p->shift = (p->factor <= 1.0) ?
     DEFAULT_FAST_SHIFT_RATIO: DEFAULT_SLOW_SHIFT_RATIO;
 
-  if (n > 3 && !sscanf(argv[3], "%lf", &p->shift)) {
+  if (argc > 3 && !sscanf(argv[3], "%lf", &p->shift)) {
     lsx_fail("error while parsing shift ratio");
     return lsx_usage(effp);
   }
@@ -108,7 +109,7 @@
   if (p->fading > 0.5)
     p->fading = 0.5;
 
-  if (n > 4 && !sscanf(argv[4], "%lf", &p->fading)) {
+  if (argc > 4 && !sscanf(argv[4], "%lf", &p->fading)) {
     lsx_fail("error while parsing fading ratio");
     return lsx_usage(effp);
   }
--- a/src/swap.c
+++ b/src/swap.c
@@ -23,17 +23,18 @@
  * Don't do initialization now.
  * The 'info' fields are not yet filled in.
  */
-static int sox_swap_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_swap_getopts(sox_effect_t * effp, int argc, char **argv)
 {
     priv_t * swap = (priv_t *) effp->priv;
+  --argc, ++argv;
 
     swap->order[0] = swap->order[1] = swap->order[2] = swap->order[3] = 0;
-    if (n)
+    if (argc)
     {
         swap->def_opts = 0;
-        if (n != 2 && n != 4)
+        if (argc != 2 && argc != 4)
           return lsx_usage(effp);
-        else if (n == 2)
+        else if (argc == 2)
         {
             sscanf(argv[0],"%d",&swap->order[0]);
             sscanf(argv[1],"%d",&swap->order[1]);
--- a/src/synth.c
+++ b/src/synth.c
@@ -267,6 +267,7 @@
   priv_t * synth = (priv_t *) effp->priv;
   channel_t master, * chan = &master;
   int argn = 0;
+  --argc, ++argv;
 
   /* Get duration if given (if first arg starts with digit) */
   if (argc && (isdigit((int)argv[argn][0]) || argv[argn][0] == '.')) {
@@ -273,7 +274,7 @@
     synth->length_str = lsx_malloc(strlen(argv[argn]) + 1);
     strcpy(synth->length_str, argv[argn]);
     /* Do a dummy parse of to see if it will fail */
-    if (lsx_parsesamples(9e9, synth->length_str, &synth->samples_to_do, 't') == NULL)
+    if (lsx_parsesamples(0., synth->length_str, &synth->samples_to_do, 't') == NULL)
       return lsx_usage(effp);
     argn++;
   }
--- a/src/tempo.c
+++ b/src/tempo.c
@@ -300,7 +300,7 @@
 {
   static sox_effect_handler_t handler = {
     "tempo", "[-q] factor [segment-ms [search-ms [overlap-ms]]]",
-    SOX_EFF_MCHAN | SOX_EFF_LENGTH | SOX_EFF_GETOPT,
+    SOX_EFF_MCHAN | SOX_EFF_LENGTH,
     getopts, start, flow, drain, stop, NULL, sizeof(priv_t)
   };
   return &handler;
@@ -311,7 +311,7 @@
 static int pitch_getopts(sox_effect_t * effp, int argc, char **argv)
 {
   double d;
-  char dummy, arg[100], **argv2 = malloc(argc * sizeof(*argv2));
+  char dummy, arg[100], **argv2 = lsx_malloc(argc * sizeof(*argv2));
   int result, pos = (argc > 1 && !strcmp(argv[1], "-q"))? 2 : 1;
 
   if (argc <= pos || sscanf(argv[pos], "%lf %c", &d, &dummy) != 1)
--- a/src/tremolo.c
+++ b/src/tremolo.c
@@ -17,21 +17,22 @@
 
 #include "sox_i.h"
 
-static int getopts(sox_effect_t * effp, int n, char * * argv)
+static int getopts(sox_effect_t * effp, int argc, char * * argv)
 {
   double speed, depth = 40;
   char dummy;     /* To check for extraneous chars. */
   char offset[100];
-  char * args[] = {"sine", "fmod", 0, 0, "25"};
+  char * args[] = {0, "sine", "fmod", 0, 0, "25"};
 
-  if (n < 1 || n > 2 ||
-      sscanf(argv[0], "%lf %c", &speed, &dummy) != 1 || speed < 0 ||
-      (n > 1 && sscanf(argv[1], "%lf %c", &depth, &dummy) != 1) ||
+  if (argc < 2 || argc > 3 ||
+      sscanf(argv[1], "%lf %c", &speed, &dummy) != 1 || speed < 0 ||
+      (argc > 2 && sscanf(argv[2], "%lf %c", &depth, &dummy) != 1) ||
       depth <= 0 || depth > 100)
     return lsx_usage(effp);
-  args[2] = argv[0];
+  args[0] = argv[0];
+  args[3] = argv[1];
   sprintf(offset, "%g", 100 - depth / 2);
-  args[3] = offset;
+  args[4] = offset;
   return sox_synth_effect_fn()->getopts(effp, (int)array_length(args), args);
 }
 
--- a/src/trim.c
+++ b/src/trim.c
@@ -26,14 +26,15 @@
 /*
  * Process options
  */
-static int sox_trim_getopts(sox_effect_t * effp, int n, char **argv)
+static int sox_trim_getopts(sox_effect_t * effp, int argc, char **argv)
 {
     priv_t * trim = (priv_t *) effp->priv;
+  --argc, ++argv;
 
     /* Do not know sample rate yet so hold off on completely parsing
      * time related strings.
      */
-    switch (n) {
+    switch (argc) {
         case 2:
             trim->length_str = lsx_malloc(strlen(argv[1])+1);
             strcpy(trim->length_str,argv[1]);
--- a/src/vol.c
+++ b/src/vol.c
@@ -42,6 +42,7 @@
   char *    type_ptr = type_string;
   char      dummy;             /* To check for extraneous chars. */
   sox_bool  have_type;
+  --argc, ++argv;
 
   vol->gain = 1;               /* Default is no change. */
   vol->uselimiter = sox_false; /* Default is no limiter. */
@@ -184,11 +185,12 @@
 
 static int gain_getopts(sox_effect_t * effp, int argc, char * * argv)
 {
-  char * args[] = {0, "dB"};
+  char * args[] = {0, 0, "dB"};
 
-  if (argc != 1)
+  if (argc != 2)
     return lsx_usage(effp);
   args[0] = argv[0];
+  args[1] = argv[1];
   return sox_vol_effect_fn()->getopts(effp, (int)array_length(args), args);
 }