shithub: sox

Download patch

ref: 3466e693fbb673e9c446acf8027086be378d905c
parent: 6f85907e5db992972475c203f633be7bf3e2a688
author: robs <robs>
date: Sat Sep 13 11:52:39 EDT 2008

fix noiseprof pass-through

--- a/ChangeLog
+++ b/ChangeLog
@@ -44,6 +44,7 @@
     band-width and aliasing now configurable.  (robs)
   o New -b option for the norm effect; can be used to fix stereo
     imbalance.  (robs)
+  o Fix broken audio pass-through with noiseprof effect.  (robs)
 
 Other new features:
 
@@ -70,7 +71,8 @@
 Internal improvements:
 
   o Fixed all compiler warnings (with gcc 4.3.1, 64-bit arch.).  (robs)
-  o Updates to internal effects chain API.
+  o Updates to internal effects chain API.  (cbagwell)
+  o Retire old FFT routines (speeds up noisered effect).  (robs)
 
 
 sox-14.1.0	2008-7-29
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -114,40 +114,30 @@
 static int sox_noiseprof_flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_sample_t *obuf,
                     size_t *isamp, size_t *osamp)
 {
-    priv_t * data = (priv_t *) effp->priv;
-    size_t samp = min(*isamp, *osamp);
-    size_t tracks = effp->in_signal.channels;
-    size_t track_samples = samp / tracks;
-    int ncopy = 0;
-    size_t i;
+  priv_t * p = (priv_t *) effp->priv;
+  size_t samp = min(*isamp, *osamp), dummy = 0; /* No need to clip count */
+  size_t chans = effp->in_signal.channels;
+  size_t i, j, n = min(samp / chans, WINDOWSIZE - p->bufdata);
 
-    /* FIXME: Make this automatic for all effects */
-    assert(effp->in_signal.channels == effp->out_signal.channels);
+  memcpy(obuf, ibuf, n * chans); /* Pass on audio unaffected */
+  *isamp = *osamp = n * chans;
 
-    /* How many samples per track to analyze? */
-    ncopy = min(track_samples, WINDOWSIZE-data->bufdata);
+  /* Collect data for every channel. */
+  for (i = 0; i < chans; i ++) {
+    chandata_t * chan = &(p->chandata[i]);
+    for (j = 0; j < n; j ++)
+      chan->window[j + p->bufdata] =
+        SOX_SAMPLE_TO_FLOAT_32BIT(ibuf[i + j * chans], dummy);
+    if (n + p->bufdata == WINDOWSIZE)
+      collect_data(chan);
+  }
 
-    /* Collect data for every channel. */
-    for (i = 0; i < tracks; i ++) {
-        chandata_t* chan = &(data->chandata[i]);
-        int j;
-        for (j = 0; j < ncopy; j ++) {
-            chan->window[j+data->bufdata] =
-                SOX_SAMPLE_TO_FLOAT_32BIT(ibuf[i+j*tracks], effp->clips);
-        }
-        if (ncopy + data->bufdata == WINDOWSIZE)
-            collect_data(chan);
-    }
+  p->bufdata += n;
+  assert(p->bufdata <= WINDOWSIZE);
+  if (p->bufdata == WINDOWSIZE)
+    p->bufdata = 0;
 
-    data->bufdata += ncopy;
-    assert(data->bufdata <= WINDOWSIZE);
-    if (data->bufdata == WINDOWSIZE)
-        data->bufdata = 0;
-
-    memcpy(obuf, ibuf, ncopy*tracks);
-    *isamp = *osamp = ncopy*tracks;
-
-    return (SOX_SUCCESS);
+  return SOX_SUCCESS;
 }
 
 /*