shithub: sox

Download patch

ref: fd5fd8eedefbf7722c684c6e5c2689024cf7dfe6
parent: 374f9408a0468eb756887e0e7aef5955836f628f
author: robs <robs>
date: Mon Jul 14 04:40:00 EDT 2008

Can now fade out to EOF without giving file-length (if it can
be determined from the input file header)

--- a/ChangeLog
+++ b/ChangeLog
@@ -8,7 +8,7 @@
 sox-14.1.0	2008-TBD
 ----------
 
-Previously deprecated features that are removed in this release:
+Previously deprecated features that have been removed in this release:
 
   Deprec-  Feature    [O(ption)]
   ated in  [F(ormat)] [E(ffect)]   Replacement
@@ -21,7 +21,7 @@
   13.0.0   E vibro                 ~= tremolo
   13.0.0   F auto                  Becomes internal only
 
-Previously deprecated features to be removed in future:
+Previously deprecated features (to be removed in future):
 
   Deprec-  Feature    [O(ption)]                           Removal
   ated in  [F(ormat)] [E(ffect)]   Replacement             due after
@@ -29,7 +29,7 @@
   14.0.0   E stretch               ~= tempo                2008-09-11
   14.0.0   E pitch                 ~= key                  2008-09-11
 
-Newly deprecated features to be removed in future:
+Newly deprecated features (to be removed in future):
 
   Deprec-  Feature    [O(ption)]                           Removal
   ated in  [F(ormat)] [E(ffect)]   Replacement             due after
@@ -85,6 +85,8 @@
   o New `spectrogram' effect; creates a PNG (if built with PNG lib).  (robs)
   o `synth' can now sweep linearly and squarely (as well as
     exponentially).  (robs)
+  o Can now `fade' out to EOF without giving file-length (if it can
+    be determined from the input file header).  (robs)
   o Fix synth max. level setting for some output encodings.  (robs)
   o Fix crash on 64-bit arch. with tempo & key effects.  (Sami Liedes)
   o `gain' alias for the vol effect.  (robs)
--- a/soxeffect.7
+++ b/soxeffect.7
@@ -393,6 +393,10 @@
 No fade-out is performed if
 .I stop-time
 is not specified.
+If the file length can be determined from the input file header and length-changing effects are not in effect, then \fB0\fR may be specified for
+.I stop-time
+to indicate the usual case of a fade-out that ends at the end of the input
+audio stream.
 .SP
 All times can be specified in either periods of time or sample counts.
 To specify time periods use the format hh:mm:ss.frac format.  To specify
--- a/src/fade.c
+++ b/src/fade.c
@@ -129,6 +129,14 @@
                             &fade->out_stop, 't') == NULL)
           return lsx_usage(effp);
 
+        if (!fade->out_stop) {
+          fade->out_stop = effp->in_signal.length;
+          if (!fade->out_stop) {
+            sox_fail("cannot fade out: audio length is neither known nor given");
+            return SOX_EOF;
+          }
+        }
+
         /* See if user wants to fade out. */
         if (fade->out_start_str)
         {
--- a/src/sox.c
+++ b/src/sox.c
@@ -1666,9 +1666,14 @@
   if (sox_globals.verbosity > 2)
     display_SoX_version(stderr);
 
-  /* Make sure we got at least the required # of input filenames */
   input_count = file_count ? file_count - 1 : 0;
-  if (input_count < (is_serial(combine_method) ? 1 : 2))
+
+  /* Allow e.g. known length processing in this case */
+  if (combine_method == sox_sequence && input_count == 1)
+    combine_method = sox_concatenate;
+
+  /* Make sure we got at least the required # of input filenames */
+  if (input_count < is_serial(combine_method ? 1 : 2))
     usage("Not enough input filenames specified");
 
   /* Check for misplaced input/output-specific options */