shithub: sox

Download patch

ref: c9d24fa2815962a3cacc2825abe7b5a49fe03978
parent: f82246b0f974f21408219c993584a2ca41b282d9
author: robs <robs>
date: Sat Feb 16 18:28:14 EST 2008

added option normalise across all channels or normalise individual channels

--- a/src/normalise.c
+++ b/src/normalise.c
@@ -21,6 +21,7 @@
 #include <string.h>
 
 typedef struct norm {
+  sox_bool      individual;
   double        norm0;    /* Multiplier to take to 0dB FSD */
   double        level;    /* Multiplier to take to 'level' */
   sox_sample_t  min, max;
@@ -35,6 +36,7 @@
   priv_t p = (priv_t)effp->priv;
   char dummy;
 
+  if (argc && !strcmp(*argv, "-i")) p->individual = sox_true, ++argv, --argc;
   if (argc > 1 || (argc == 1 &&
         (sscanf(*argv, "%lf%c", &p->level, &dummy) != 1 || p->level > 0)))
     return sox_usage(effp);
@@ -46,6 +48,8 @@
 {
   priv_t p = (priv_t)effp->priv;
 
+  if (!p->individual)
+    effp->flows = 1;
   p->norm0 = p->max = p->min = 0;
   p->tmp_file = tmpfile();
   if (p->tmp_file == NULL) {
@@ -106,7 +110,7 @@
 sox_effect_handler_t const * sox_norm_effect_fn(void)
 {
   static sox_effect_handler_t handler = {
-    "norm", "[level]", 0, create, start, flow, drain, stop, NULL
+    "norm", "[-i] [level]", 0, create, start, flow, drain, stop, NULL
   };
   return &handler;
 }