shithub: sox

Download patch

ref: 51beed319b0d0ba2390b9284deb32fc79b7352e2
parent: 430ffc96aada94d90a4f95d5b5b52cac9f2dc849
author: cbagwell <cbagwell>
date: Wed Sep 5 12:06:01 EDT 2001

Fixig solaris bugs.  Adjusting soxmix.o rule to use vpath's.

--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -8,6 +8,7 @@
 
 SHELL = /bin/sh
 srcdir = @srcdir@
+VPATH	= @srcdir@
 prefix = @prefix@
 
 # Shell commands.
@@ -64,8 +65,6 @@
 
 LIBOBJS = $(FOBJ) $(EOBJ) handlers.o libst.o misc.o util.o getopt.o $(EXTRAOBJS)
 
-VPATH	= @srcdir@
-
 PLAY_0    =
 PLAY_1    = play
 
@@ -75,7 +74,7 @@
 	$(CC) $(LDFLAGS) -o sox sox.o $(LIBS)
 
 soxmix.o: sox.c
-	$(CC) $(CFLAGS) -DSOXMIX -c -o soxmix.o sox.c
+	$(CC) $(CFLAGS) -DSOXMIX -c -o soxmix.o $<
 
 soxmix: libst.a soxmix.o
 	$(CC) $(LDFLAGS) -o soxmix soxmix.o $(LIBS)
--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -16,7 +16,7 @@
 #include <math.h>   /* exp(), sqrt() */
 #include <limits.h> /* LONG_MAX */
 
-/* type used for computations. 
+/* type used for computations.
  */
 #ifndef DCSHIFT_FLOAT
 #define DCSHIFT_FLOAT float
@@ -25,24 +25,26 @@
 
 /* constants
  */
-#define ZERO	  ((DCSHIFT_FLOAT)(0.0e0))
+#define ZERO      ((DCSHIFT_FLOAT)(0.0e0))
 #define LOG_10_20 ((DCSHIFT_FLOAT)(0.1151292546497022842009e0))
-#define ONE	  ((DCSHIFT_FLOAT)(1.0e0))
-#define TWENTY	  ((DCSHIFT_FLOAT)(20.0e0))
+#define ONE       ((DCSHIFT_FLOAT)(1.0e0))
+#define TWENTY    ((DCSHIFT_FLOAT)(20.0e0))
 
-#define DCSHIFT_USAGE "Usage: dcshift shift [ limitergain ]\n" \
-"The peak limiter has a gain much less than 1.0 (ie 0.05 or 0.02) which is only\n" \
-"used on peaks to prevent clipping. (default is no limiter)"
+char *dcshift_usage = "Usage: dcshift shift [ limitergain ]\n"
+"The peak limiter has a gain much less than 1.0 (ie 0.05 or 0.02) which is only\n"
+"used on peaks to prevent clipping. (default is no limiter)";
 
+#define DCSHIFT_USAGE dcshift_usage
+
 typedef struct {
     DCSHIFT_FLOAT dcshift; /* DC shift. */
-    
+
     int uselimiter; /* boolean: are we using the limiter? */
     DCSHIFT_FLOAT limiterthreshhold;
     DCSHIFT_FLOAT limitergain; /* limiter gain. */
     int limited; /* number of limited values to report. */
     int totalprocessed;
-    
+
     int clipped;    /* number of clipped values to report. */
 } * dcs_t;
 
@@ -49,42 +51,42 @@
 /*
  * Process options: dcshift (float) type (amplitude, power, dB)
  */
-int st_dcshift_getopts(effp, n, argv) 
+int st_dcshift_getopts(effp, n, argv)
 eff_t effp;
 int n;
 char **argv;
 {
-    dcs_t dcs = (dcs_t) effp->priv; 
+    dcs_t dcs = (dcs_t) effp->priv;
     dcs->dcshift = ONE; /* default is no change */
     dcs->uselimiter = 0; /* default is no limiter */
-  
+
     if (n < 1)
     {
-	st_fail(DCSHIFT_USAGE);
-	return ST_EOF;
+        st_fail(DCSHIFT_USAGE);
+        return ST_EOF;
     }
 
     if (n && (!sscanf(argv[0], DCSHIFT_FLOAT_SCAN, &dcs->dcshift)))
     {
-	st_fail(DCSHIFT_USAGE);
-	return ST_EOF;
+        st_fail(DCSHIFT_USAGE);
+        return ST_EOF;
     }
 
     if (n>1)
     {
-    	if (!sscanf(argv[1], DCSHIFT_FLOAT_SCAN, &dcs->limitergain))
-    	{
-  		st_fail(DCSHIFT_USAGE);
-		return ST_EOF;  		
-    	}
-    	
-    	dcs->uselimiter = 1; /* ok, we'll use it */
-    	/* The following equation is derived so that there is no discontinuity in output amplitudes */
-    	/* and a LONG_MAX input always maps to a LONG_MAX output when the limiter is activated. */
-    	/* (NOTE: There **WILL** be a discontinuity in the slope of the output amplitudes when using the limiter.) */
-    	dcs->limiterthreshhold = LONG_MAX * (ONE - (fabs(dcs->dcshift) - dcs->limitergain));
+        if (!sscanf(argv[1], DCSHIFT_FLOAT_SCAN, &dcs->limitergain))
+        {
+                st_fail(DCSHIFT_USAGE);
+                return ST_EOF;
+        }
+
+        dcs->uselimiter = 1; /* ok, we'll use it */
+        /* The following equation is derived so that there is no discontinuity in output amplitudes */
+        /* and a LONG_MAX input always maps to a LONG_MAX output when the limiter is activated. */
+        /* (NOTE: There **WILL** be a discontinuity in the slope of the output amplitudes when using the limiter.) */
+        dcs->limiterthreshhold = LONG_MAX * (ONE - (fabs(dcs->dcshift) - dcs->limitergain));
     }
-    
+
     return ST_SUCCESS;
 }
 
@@ -95,18 +97,18 @@
 eff_t effp;
 {
     dcs_t dcs = (dcs_t) effp->priv;
-    
+
     if (effp->outinfo.channels != effp->ininfo.channels)
     {
-	st_warn("DCSHIFT cannot handle different channels (in=%d, out=%d)"
-	     " use avg or pan", effp->ininfo.channels, effp->outinfo.channels);
+        st_warn("DCSHIFT cannot handle different channels (in=%d, out=%d)"
+             " use avg or pan", effp->ininfo.channels, effp->outinfo.channels);
     }
 
     if (effp->outinfo.rate != effp->ininfo.rate)
     {
-	st_fail("DCSHIFT cannot handle different rates (in=%ld, out=%ld)"
-	     " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
-	return ST_EOF;
+        st_fail("DCSHIFT cannot handle different rates (in=%ld, out=%ld)"
+             " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
+        return ST_EOF;
     }
 
     dcs->clipped = 0;
@@ -124,13 +126,13 @@
 {
     if (v > LONG_MAX)
     {
-	 dcs->clipped++;
-	 return LONG_MAX;
+         dcs->clipped++;
+         return LONG_MAX;
     }
     else if (v < -LONG_MAX)
     {
-	dcs->clipped++;
-	return -LONG_MAX;
+        dcs->clipped++;
+        return -LONG_MAX;
     }
     /* else */
     return (LONG) v;
@@ -154,50 +156,50 @@
     register DCSHIFT_FLOAT limiterthreshhold = dcs->limiterthreshhold;
     register DCSHIFT_FLOAT sample;
     register LONG len;
-    
+
     len = MIN(*osamp, *isamp);
 
     /* report back dealt with amount. */
     *isamp = len; *osamp = len;
-    
+
     if (dcs->uselimiter)
     {
-	dcs->totalprocessed += len;
-	
-	for (;len>0; len--)
-	    {
-	    	sample = *ibuf++;
-	    	
-	    	if (sample > limiterthreshhold && dcshift > 0)
-	    	{
-	    		sample =  (sample - limiterthreshhold) * limitergain / (LONG_MAX - limiterthreshhold) + limiterthreshhold + dcshift;
-	    		dcs->limited++;
-	    	}
-	    	else if (sample < -limiterthreshhold && dcshift < 0)
-	    	{
-	    		sample =  (sample + limiterthreshhold) * limitergain / (LONG_MAX - limiterthreshhold) - limiterthreshhold + dcshift;
-	    		dcs->limited++;
-	    	}
-	    	else
-	    	{
-	    		sample = dcshift * LONG_MAX + sample;
-	    	}
+        dcs->totalprocessed += len;
 
-		*obuf++ = clip(dcs, sample);
-	    }
+        for (;len>0; len--)
+            {
+                sample = *ibuf++;
+
+                if (sample > limiterthreshhold && dcshift > 0)
+                {
+                        sample =  (sample - limiterthreshhold) * limitergain / (LONG_MAX - limiterthreshhold) + limiterthreshhold + dcshift;
+                        dcs->limited++;
+                }
+                else if (sample < -limiterthreshhold && dcshift < 0)
+                {
+                        sample =  (sample + limiterthreshhold) * limitergain / (LONG_MAX - limiterthreshhold) - limiterthreshhold + dcshift;
+                        dcs->limited++;
+                }
+                else
+                {
+                        sample = dcshift * LONG_MAX + sample;
+                }
+
+                *obuf++ = clip(dcs, sample);
+            }
     }
     else
     {
-    	/* quite basic, with clipping */
-    	for (;len>0; len--)
-		*obuf++ = clip(dcs, dcshift * LONG_MAX + *ibuf++);
+        /* quite basic, with clipping */
+        for (;len>0; len--)
+                *obuf++ = clip(dcs, dcshift * LONG_MAX + *ibuf++);
     }
     return ST_SUCCESS;
 }
 
 /*
- * Do anything required when you stop reading samples.  
- * Don't close input file! 
+ * Do anything required when you stop reading samples.
+ * Don't close input file!
  */
 int st_dcshift_stop(effp)
 eff_t effp;
@@ -206,21 +208,21 @@
 
     if (dcs->limited)
     {
-	st_warn("DCSHIFT limited %d values (%d percent).", 
-	     dcs->limited, (int) (dcs->limited * 100.0 / dcs->totalprocessed));
+        st_warn("DCSHIFT limited %d values (%d percent).",
+             dcs->limited, (int) (dcs->limited * 100.0 / dcs->totalprocessed));
     }
-    if (dcs->clipped) 
+    if (dcs->clipped)
     {
-    	if (dcs->dcshift > 0)
-    	{
-	     st_warn("DCSHIFT clipped %d values, dcshift=%f too high...", 
-	          dcs->clipped, dcs->dcshift);
-	}
-    	else
-    	{
-	     st_warn("DCSHIFT clipped %d values, dcshift=%f too low...", 
-	          dcs->clipped, dcs->dcshift);
-	}
+        if (dcs->dcshift > 0)
+        {
+             st_warn("DCSHIFT clipped %d values, dcshift=%f too high...",
+                  dcs->clipped, dcs->dcshift);
+        }
+        else
+        {
+             st_warn("DCSHIFT clipped %d values, dcshift=%f too low...",
+                  dcs->clipped, dcs->dcshift);
+        }
     }
     return ST_SUCCESS;
 }