shithub: sox

Download patch

ref: e801680e7ffe47057e17bf507b128da1f1b36f43
parent: 5e07844aec00a226dc9a818710af6b1bc9b5acb4
parent: 1a257fd01a23018159c98eae49c757305bd00f23
author: Doug Cook <idigdoug@users.sourceforge.net>
date: Sat Dec 31 16:11:09 EST 2011

Merge branch 'master' of ssh://sox.git.sourceforge.net/gitroot/sox/sox

--- a/ChangeLog
+++ b/ChangeLog
@@ -67,6 +67,8 @@
   o Let the delay effect gracefully handle the special case that a delay can
     be more than the input length. [3055399] (Ulrich Klauer)
   o New hilbert and downsample effects. (Ulrich Klauer)
+  o Fix problem where fade would sometimes fail if specifying a fade-out
+    immediately after a fade-in. (robs)
 
 Misc:
 
--- a/sox.1
+++ b/sox.1
@@ -3086,7 +3086,7 @@
 .EE
 .na
 .TP
-\fBsinc\fR [\fB\-a\fI att\fR\^|\^\fB\-b\fI beta\fR] [\fB\-p\fI phase\fR\^|\^\fB\-M\fR\^|\^\fB\-I\fR\^|\^\fB\-L\fR] \:[\fB\-t\fI tbw\fR\^|\^\fB\-n\fI taps\fR] [\fIfreqHP\fR][\fB\-\fIfreqLP\fR [\fB\-t\fR tbw\^|\^\fB\-n\fR taps]]
+\fBsinc\fR [\fB\-a\fI att\fR\^|\^\fB\-b\fI beta\fR] [\fB\-p\fI phase\fR\^|\^\fB\-M\fR\^|\^\fB\-I\fR\^|\^\fB\-L\fR] \:[\fB\-t\fI tbw\fR\^|\^\fB\-n\fI taps\fR] [\fIfreqHP\fR]\:[\fB\-\fIfreqLP\fR [\fB\-t\fR tbw\^|\^\fB\-n\fR taps]]
 .ad
 Apply a sinc kaiser-windowed low-pass, high-pass, band-pass, or band-reject filter
 to the signal.
@@ -3093,8 +3093,17 @@
 The \fIfreqHP\fR and \fIfreqLP\fR parameters give the frequencies of the
 6dB points of a high-pass and low-pass filter that may be invoked
 individually, or together.  If both are
-given, then \fIfreqHP\fR < \fIfreqLP\fR creates a band-pass filter,
-\fIfreqHP\fR > \fIfreqLP\fR creates a band-reject filter.
+given, then \fIfreqHP\fR less than \fIfreqLP\fR creates a band-pass filter,
+\fIfreqHP\fR greater than \fIfreqLP\fR creates a band-reject filter.
+For example, the invocations
+.EX
+   sinc 3k
+   sinc -4k
+   sinc 3k-4k
+   sinc 4k-3k
+.EE
+create a high-pass, low-pass, band-pass, and band-reject filter
+respectively.
 .SP
 The default stop-band attenuation of 120dB can be overridden with
 \fB\-a\fR; alternatively, the kaiser-window `beta' parameter can be
--- a/src/fade.c
+++ b/src/fade.c
@@ -170,17 +170,19 @@
          */
         fade->out_stop = 0;
 
-    /* Sanity check for fade times vs total time */
-    if (fade->in_stop > fade->out_start && fade->out_start != 0)
-    { /* Fades too long */
-        lsx_fail("Fade: End of fade-in should not happen before beginning of fade-out");
-        return(SOX_EOF);
-    } /* endif fade time sanity */
+    if (fade->out_start) {              /* Sanity check */
+      if (fade->in_stop > fade->out_start)
+        --fade->in_stop;                /* 1 sample grace for rounding error. */
+      if (fade->in_stop > fade->out_start) {
+        lsx_fail("fade-out overlaps fade-in");
+        return SOX_EOF;
+      }
+    }
 
     fade->samplesdone = fade->in_start;
     fade->endpadwarned = 0;
 
-    lsx_debug("fade: in_start = %lu in_stop = %lu out_start = %lu out_stop = %lu", (unsigned long)fade->in_start, (unsigned long)fade->in_stop, (unsigned long)fade->out_start, (unsigned long)fade->out_stop);
+    lsx_debug("in_start = %lu in_stop = %lu out_start = %lu out_stop = %lu", (unsigned long)fade->in_start, (unsigned long)fade->in_stop, (unsigned long)fade->out_start, (unsigned long)fade->out_stop);
 
     if (fade->in_start == fade->in_stop && !truncate &&
         fade->out_start == fade->out_stop)
--- a/src/speed.c
+++ b/src/speed.c
@@ -63,7 +63,7 @@
 {
   static sox_effect_handler_t handler = {
     "speed", "factor[c]",
-	SOX_EFF_MCHAN | SOX_EFF_RATE | SOX_EFF_LENGTH,
+    SOX_EFF_MCHAN | SOX_EFF_RATE | SOX_EFF_LENGTH | SOX_EFF_MODIFY,
     getopts, start, lsx_flow_copy, 0, 0, 0, sizeof(priv_t)};
   return &handler;
 }