shithub: sox

Download patch

ref: 9f37c16370f1d2c856be3820dd69a8387ad99bef
parent: 28aa893ed1c280992d6fadb949db5d2221d91a48
author: cbagwell <cbagwell>
date: Thu Sep 8 22:04:00 EDT 2005

Fixed noisered to warn during clipping instead of aborting.

--- a/Changelog
+++ b/Changelog
@@ -13,6 +13,8 @@
     is required for NetBSD/powerpc.
   o When seek()ing in AIFF, SMP, and WAV handlers, remaining samples were
     incorrectly computed based on bytes and not samples.  Jukka
+  o Changed noisered effect to just warn during clipping instead
+    of aborting.  Ian Turner
 
 sox-12.17.8
 -----------
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -223,7 +223,16 @@
     if (!first) {
         for (j = 0; j < use; j ++) {
             float s = chan->window[j] + chan->lastwindow[WINDOWSIZE/2 + j];
-            assert(s >= -1 && s <= 1);
+            if (s < -1 || s > 1) {
+                float news;
+                if (s > 1)
+                    news = 1;
+                else
+                    news = -1;
+
+                st_warn("noisered: Output clipped from %f to %f.\n",
+                        s, news);
+            }
             obuf[chan_num + num_chans * j] =
                 ST_FLOAT_DWORD_TO_SAMPLE(s);
         }
--- a/src/st.h
+++ b/src/st.h
@@ -80,7 +80,7 @@
     st_size_t    start;          /* first sample */
     st_size_t    length;         /* length */
     unsigned int count;          /* number of repeats, 0=forever */
-    char         type;           /* 0=no, 1=forward, 2=forward/back */
+    signed char  type;           /* 0=no, 1=forward, 2=forward/back */
 } st_loopinfo_t;
 
 /* Instrument parameters */
@@ -92,7 +92,7 @@
     char MIDInote;       /* for unity pitch playback */
     char MIDIlow, MIDIhi;/* MIDI pitch-bend range */
     char loopmode;       /* semantics of loop data */
-    char nloops;         /* number of active loops (max ST_MAX_NLOOPS) */
+    signed char nloops;  /* number of active loops (max ST_MAX_NLOOPS) */
 } st_instrinfo_t;
 
 /* Loop modes, upper 4 bits mask the loop blass, lower 4 bits describe */