shithub: sox

Download patch

ref: b248ac688bc7bbd4b5b169afd7e41860a2ebc8b0
parent: 2d317ca5f0ce70a3c90942ff5b784e60d6c3c467
author: robs <robs>
date: Fri May 22 15:02:29 EDT 2009

fix where fade is configured to truncate only

--- a/src/fade.c
+++ b/src/fade.c
@@ -114,6 +114,7 @@
 static int sox_fade_start(sox_effect_t * effp)
 {
     priv_t * fade = (priv_t *) effp->priv;
+    sox_bool truncate = sox_false;
 
     /* converting time values to samples */
     fade->in_start = 0;
@@ -130,7 +131,7 @@
                             &fade->out_stop, 't') == NULL)
           return lsx_usage(effp);
 
-        if (!fade->out_stop) {
+        if (!(truncate = !!fade->out_stop)) {
           fade->out_stop = effp->in_signal.length / effp->in_signal.channels;
           if (!fade->out_stop) {
             lsx_fail("cannot fade out: audio length is neither known nor given");
@@ -173,7 +174,8 @@
 
     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);
 
-    if (fade->in_start == fade->in_stop && fade->out_start == fade->out_stop)
+    if (fade->in_start == fade->in_stop && !truncate &&
+        fade->out_start == fade->out_stop)
       return SOX_EFF_NULL;
 
     return SOX_SUCCESS;