shithub: sox

Download patch

ref: b09c8099b7afb39ad9ac5536c59d60c3cb35f430
parent: 07c9e25d46d23088cff6daa5c5bcbb60f7a9e478
author: cbagwell <cbagwell>
date: Wed Jun 30 23:03:07 EDT 1999

Fixed more compile problems, fixed *pass filters bug, Updated docs.

--- a/Changelog
+++ b/Changelog
@@ -44,6 +44,8 @@
   o Combined play and rec scripts to a single program to ease mantaince.
     Also added GNU style long-options (--help).  Careful, some options have
     change (but more logical).
+  o Fixed a very old silly bug were low/high/bandpass filters would
+    add some trash data to the end of the sound file.
 
 sox-12.15
 ---------
--- a/Makefile.unx
+++ b/Makefile.unx
@@ -151,7 +151,7 @@
 
 # For sound support using the ALSA driver then uncomment the following line.
 #
-# PLAYER_DEFINES = - DALSA_PLAYER
+# PLAYER_DEFINES = -DALSA_PLAYER
 
 # For sound support under SunOS and Solaris then uncomment the following line.
 #
@@ -184,8 +184,12 @@
 #
 # If your sysetem has unistd.h then you'll most like need to add 
 # HAVE_UNISTD_H to your misd defines.
-# MISC_DEFINES = - DHAVE_UNISTD_H
+# MISC_DEFINES = -DHAVE_UNISTD_H
 #
+# If your system has malloc.h then you'll most likely need to add
+# HAVE_MALLOC_H to your misd defines.
+# MSIC_DEFINS = -DHAVE_UNISTD_H
+#
 # Testing new improved rate code.  You can use the older version if ther
 # are problems.
 # MISC_DEFINES	= -DUSE_OLD_RATE
@@ -212,10 +216,14 @@
 # for those systems.
 # RANLIB    = true
 
+# Some systems (i.e. MacOsX Server) don't need a separate math library
+MATHLIB = -lm
+# MATHLIB = 
+
 ##############################################################################
 
 SOX_PRE_LIBS	= $(GSM_PRE_LIBS)
-SOX_POST_LIBS	= $(GSM_POST_LIBS) -lm
+SOX_POST_LIBS	= $(GSM_POST_LIBS) $(MATHLIB)
 SOX_INCLUDES	= $(GSM_INCLUDES)
 SOX_DEFINES	= $(GSM_DEFINES) $(PLAYER_DEFINES) \
   $(GETOPT_DEFINES) $(STRERR_DEFINES) $(MEMMOVE_DEFINES) \
--- a/README
+++ b/README
@@ -54,8 +54,7 @@
 popular "Guitar Effects" talked about in the same named FAQ available.
 
 The 'resample' and 'polyphase' effect does high-grade signal rate
-changes using real signal theory.  Yes, it's very slow.  There seems
-to be a small problem with aliasing with 'resample' currently.
+changes using real signal theory.  Yes, it's very slow.
 
 History:
 
--- a/configure
+++ b/configure
@@ -734,7 +734,7 @@
 		CFLAGS="$CFLAGS -D_HPUX_SOURCE"
 		;;
 
-	*next* )
+	*next*|*rhapsody* )
 		CFLAGS="$CFLAGS -DNeXT"
 		;;
 esac
@@ -1199,7 +1199,7 @@
 fi
 echo "$ac_t""$CPP" 1>&6
 
-for ac_hdr in getopt.h unistd.h
+for ac_hdr in getopt.h unistd.h malloc.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
@@ -1636,7 +1636,60 @@
 	CFLAGS="$CFLAGS -DFAST_ALAW_COMPRESSION"
 fi
 
-LIBS="$LIBS -L. -lst -lm"
+LIBS="$LIBS -L. -lst"
+
+
+echo $ac_n "checking for pow in -lm""... $ac_c" 1>&6
+echo "configure:1644: checking for pow in -lm" >&5
+ac_lib_var=`echo m'_'pow | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lm  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1652 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char pow();
+
+int main() {
+pow()
+; return 0; }
+EOF
+if { (eval echo configure:1663: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+  LIBS="-lm $LIBS"
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+if test "$ac_cv_lib_m" = yes
+then
+	LIBS="$LIBS -lm"
+fi
 
 
 
--- a/configure.in
+++ b/configure.in
@@ -72,7 +72,7 @@
 		CFLAGS="$CFLAGS -D_HPUX_SOURCE"
 		;;
 
-	*next* )
+	*next*|*rhapsody* )
 		CFLAGS="$CFLAGS -DNeXT"
 		;;
 esac
@@ -102,7 +102,7 @@
 
 dnl Checks for header files.
 
-AC_CHECK_HEADERS(getopt.h unistd.h)
+AC_CHECK_HEADERS(getopt.h unistd.h malloc.h)
 
 dnl Checks for library functions.
 
@@ -239,7 +239,15 @@
 	CFLAGS="$CFLAGS -DFAST_ALAW_COMPRESSION"
 fi
 
-LIBS="$LIBS -L. -lst -lm"
+LIBS="$LIBS -L. -lst"
+
+dnl Check if math library is needed.
+
+AC_CHECK_LIB(m, pow)
+if test "$ac_cv_lib_m" = yes
+then
+	LIBS="$LIBS -lm"
+fi
 
 AC_SUBST(NEED_OSS)
 AC_SUBST(NEED_SUNAU)
--- a/sox.1
+++ b/sox.1
@@ -9,7 +9,7 @@
 .if t .sp .5v
 .if n .sp
 ..
-.TH SoX 1 "March 5, 1999"
+.TH SoX 1 "June 28, 1999"
 .SH NAME
 sox \- Sound eXchange : universal sound sample translator
 .SH SYNOPSIS
@@ -501,7 +501,7 @@
 copy
 Copy the input file to the output file.
 This is the default effect if both files have the same 
-sampling rate, or the rates are "close".
+sampling rate.
 .TP 10
 cut \fIloopnumber
 Extract loop #N from a sample.
@@ -607,7 +607,8 @@
 via linear interpolation to the Least Common Multiple
 of the two sampling rates.
 This is the default effect 
-if the two files have different sampling rates.
+if the two files have different sampling rates and the preview options
+was specified.
 This is fast but noisy:
 the spectrum of the original sound will be shifted upwards
 and duplicated faintly when up-translating by a multiple.
@@ -619,7 +620,7 @@
 If you are wondering which of
 .B Sox's
 rate changing effects to ues, you will want to read a
-detailed analysis of all of them at http://usa.ece.cmu.edu/Sox/
+detailed analysis of all of them at http://eakaw2.et.tu-dresden.de/~andreas/resample/resample.html
 .TP 10
 resample [ \fIrolloff\fR [ \fIbeta\fR ] ]
 Translate input sampling rate to output sampling rate
@@ -637,6 +638,8 @@
 which is rather conservative with respect to aliasing.  Lower beta
 and higher rolloff values preserve more high frequency signal energy,
 but introduce measurable artifacts.
+This is the default effect 
+if the two files have different sampling rates.
 .TP 10
 reverb \fIgain-out delay \fR[ \fIdelay ... \fR]
 Add reverbation to a sound sample.  Each delay is given 
--- a/sox.txt
+++ b/sox.txt
@@ -61,7 +61,7 @@
 
 
 
-			  March 5, 1999				1
+			  June 28, 1999				1
 
 
 
@@ -127,7 +127,7 @@
 
 
 
-			  March 5, 1999				2
+			  June 28, 1999				2
 
 
 
@@ -193,7 +193,7 @@
 
 
 
-			  March 5, 1999				3
+			  June 28, 1999				3
 
 
 
@@ -259,7 +259,7 @@
 
 
 
-			  March 5, 1999				4
+			  June 28, 1999				4
 
 
 
@@ -325,7 +325,7 @@
 
 
 
-			  March 5, 1999				5
+			  June 28, 1999				5
 
 
 
@@ -391,7 +391,7 @@
 
 
 
-			  March 5, 1999				6
+			  June 28, 1999				6
 
 
 
@@ -457,7 +457,7 @@
 
 
 
-			  March 5, 1999				7
+			  June 28, 1999				7
 
 
 
@@ -479,7 +479,7 @@
 
        copy	 Copy the input file to the output file.  This is
 		 the default effect if both files have	the  same
-		 sampling rate, or the rates are "close".
+		 sampling rate.
 
        cut loopnumber
 		 Extract loop #N from a sample.
@@ -523,7 +523,7 @@
 
 
 
-			  March 5, 1999				8
+			  June 28, 1999				8
 
 
 
@@ -589,7 +589,7 @@
 
 
 
-			  March 5, 1999				9
+			  June 28, 1999				9
 
 
 
@@ -600,16 +600,18 @@
 
 		 Common Multiple of the two sampling rates.  This
 		 is the default effect if the two files have dif-
-		 ferent sampling rates.	 This is fast but  noisy:
-		 the  spectrum	of  the	 original  sound  will be
-		 shifted upwards and duplicated faintly when  up-
-		 translating  by a multiple.  Lerp-ing is accept-
-		 able for cheap 8-bit sound hardware, but for CD-
-		 quality  sound	 you  should  instead  use either
-		 resample or polyphase.	  If  you  are	wondering
-		 which of Sox's rate changing effects to ues, you
-		 will want to read a detailed analysis of all  of
-		 them at http://usa.ece.cmu.edu/Sox/
+		 ferent sampling rates and  the	 preview  options
+		 was  specified.   This	 is  fast  but noisy: the
+		 spectrum of the original sound will  be  shifted
+		 upwards and duplicated faintly when up-translat-
+		 ing by a multiple.  Lerp-ing is  acceptable  for
+		 cheap	8-bit  sound hardware, but for CD-quality
+		 sound you should instead use either resample  or
+		 polyphase.   If you are wondering which of Sox's
+		 rate changing effects to ues, you will	 want  to
+		 read  a  detailed  analysis  of  all  of them at
+		 http://eakaw2.et.tu-dresden.de/~andreas/resam-
+		 ple/resample.html
 
        resample [ rolloff [ beta ] ]
 		 Translate input sampling rate to output sampling
@@ -628,7 +630,9 @@
 		 which is rather  conservative	with  respect  to
 		 aliasing.   Lower beta and higher rolloff values
 		 preserve more high frequency signal energy,  but
-		 introduce measurable artifacts.
+		 introduce  measurable	artifacts.   This  is the
+		 default effect if the two files  have	different
+		 sampling rates.
 
        reverb gain-out delay [ delay ... ]
 		 Add  reverbation  to a sound sample.  Each delay
@@ -648,14 +652,10 @@
        stat [ debug | -v ]
 		 Do  a	statistical  check on the input file, and
 		 print results on the standard error file.   stat
-		 may  copy  the file untouched from input to out-
-		 put, if you select an output file.  The  "Volume
-		 Adjustment:"  field  in the statistics gives you
-		 the argument to the -v number	which  will  make
 
 
 
-			  March 5, 1999			       10
+			  June 28, 1999			       10
 
 
 
@@ -664,6 +664,10 @@
 SoX(1)							   SoX(1)
 
 
+		 may  copy  the file untouched from input to out-
+		 put, if you select an output file.  The  "Volume
+		 Adjustment:"  field  in the statistics gives you
+		 the argument to the -v number	which  will  make
 		 the sample as loud as possible without clipping.
 		 There is an  optional	parameter  -v  that  will
 		 print out the "Volume Adjustment:" field's value
@@ -713,15 +717,11 @@
        The  echoplex  effect  is:  Copyright  (C)  1989	 by   Jef
        Poskanzer.
 
-       Permission to use, copy, modify, and distribute this soft-
-       ware and its documentation for any purpose and without fee
-       is  hereby  granted,  provided  that  the  above copyright
-       notice appear in all copies and that both  that	copyright
-       notice  and  this  permission  notice appear in supporting
+       Permission  to  use,  copy,  modify,  and  distribute this
 
 
 
-			  March 5, 1999			       11
+			  June 28, 1999			       11
 
 
 
@@ -730,6 +730,10 @@
 SoX(1)							   SoX(1)
 
 
+       software and its documentation for any purpose and without
+       fee  is	hereby granted, provided that the above copyright
+       notice appear in all copies and that both  that	copyright
+       notice  and  this  permission  notice appear in supporting
        documentation.  This software is provided "as is"  without
        express or implied warranty.
 
@@ -783,10 +787,6 @@
 
 
 
-
-
-
-
-			  March 5, 1999			       12
+			  June 28, 1999			       12
 
 
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -16,6 +16,10 @@
 #include <unistd.h>	/* For SEEK_* defines if not found in stdio */
 #endif
 
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
 #include "st.h"
 
 /* Private data used by writer */
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -101,7 +101,7 @@
 
 install: sox
 	if [ -f $(BINDIR)/rec ] ; then $(RM) $(BINDIR)/rec; fi
-        if [ -f $(MANDIR)/man1/rec.1 ]; then $(RM) $(MANDIR)/man1/rec.1; fi
+	if [ -f $(MANDIR)/man1/rec.1 ]; then $(RM) $(MANDIR)/man1/rec.1; fi
 	$(INSTALL) -c -m 755 sox play $(BINDIR)
 	$(INSTALL) -c -m 644 sox.1 play.1 $(MANDIR)/man1
 	ln -s $(BINDIR)/play $(BINDIR)/rec
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -44,6 +44,10 @@
 #include <unistd.h>	/* For SEEK_* defines if not found in stdio */
 #endif
 
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
 #include "st.h"
 
 /* Private data used by writer */
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -13,7 +13,9 @@
  * based on info grabed from aplay.c in alsa-utils package.
  */
 
+#ifdef HAVE_MALLOC_H
 #include <malloc.h>
+#endif
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
--- a/src/au.c
+++ b/src/au.c
@@ -22,6 +22,9 @@
 #include "st.h"
 #include "g72x.h"
 #include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 
 /* Magic numbers used in Sun and NeXT audio files */
 #define SUN_MAGIC 	0x2e736e64		/* Really '.snd' */
--- a/src/band.c
+++ b/src/band.c
@@ -114,6 +114,8 @@
 		band->out1 = d;
 		*obuf++ = d;
 	}
+	*isamp = len;
+	*osamp = len;
 }
 
 /*
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -63,6 +63,9 @@
  */
 
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <math.h>
 #include <string.h>
 #include "st.h"
--- a/src/echo.c
+++ b/src/echo.c
@@ -56,6 +56,9 @@
  */
 
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <math.h>
 #include "st.h"
 
--- a/src/echos.c
+++ b/src/echos.c
@@ -47,6 +47,9 @@
  */
 
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <math.h>
 #include "st.h"
 
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -53,6 +53,9 @@
  */
 
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <math.h>
 #include <string.h>
 #include "st.h"
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -23,11 +23,9 @@
 
 #include "st.h"
 #include <string.h>
-
-#ifdef __STDC__
 #include <stdlib.h>
-#else
-IMPORT char *malloc(), *realloc();
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
 #endif
 
 /* Dictionary entry for Huffman (de)compression */
--- a/src/highp.c
+++ b/src/highp.c
@@ -91,6 +91,8 @@
 		*obuf++ = d * 65536L;
 	}
 	highp->out1 = d;
+	*isamp = len;
+	*osamp = len;
 }
 
 /*
--- a/src/lowp.c
+++ b/src/lowp.c
@@ -88,6 +88,8 @@
 		lowp->in1 = l;
 		*obuf++ = d * 65536L;
 	}
+	*isamp = len;
+	*osamp = len;
 }
 
 /*
--- a/src/oss.c
+++ b/src/oss.c
@@ -20,7 +20,9 @@
  * SBLAST patches by John T. Kohl.
  */
 
+#ifdef HAVE_MALLOC_H
 #include <malloc.h>
+#endif
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -56,6 +56,9 @@
  */
 
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <math.h>
 #include <string.h>
 #include "st.h"
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -16,6 +16,9 @@
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include "st.h"
 
 typedef struct _list {
--- a/src/raw.c
+++ b/src/raw.c
@@ -22,7 +22,11 @@
 #include "st.h"
 #include "libst.h"
 
+#ifdef HAVE_MALLOC_H
 #include <malloc.h>
+#endif
+
+#include <stdlib.h>
 
 void rawstartread(ft) 
 ft_t ft;
--- a/src/resample.c
+++ b/src/resample.c
@@ -30,6 +30,9 @@
 */
 #include <math.h>
 #include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include "st.h"
 
 /* resample includes */
@@ -122,7 +125,7 @@
 	else if (resample->beta < 1.0)
 	        fail("resample: beta factor (%f) no good, should be >= 1.0", 
 			resample->beta);
-	fprintf(stderr, "resample opts: %f, %f\n", 
+	report("resample opts: %f, %f\n", 
 		resample->rolloff, resample->beta);
 }
 
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -93,6 +93,9 @@
  */
 
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <math.h>
 #include "st.h"
 
--- a/src/sf.c
+++ b/src/sf.c
@@ -25,6 +25,9 @@
 #endif
 #include <string.h>
 #include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 
 /* Private data for SF file */
 typedef struct sfstuff {
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -44,7 +44,7 @@
  * Prepare processing.
  * Do all initializations.
  */
-skeleff_start(effp)
+void skeleff_start(effp)
 eff_t effp;
 {
     if (effp->outinfo.channels == 1)
--- a/src/sox.c
+++ b/src/sox.c
@@ -32,6 +32,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>		/* for malloc() */
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <errno.h>
 #include <sys/types.h>		/* for fstat() */
 #include <sys/stat.h>		/* for fstat() */
@@ -766,7 +769,7 @@
 			    efftabR[1].name = effp->name;
 		    efftab[1].outinfo.rate = informat.info.rate;
 		    efftab[1].outinfo.channels = informat.info.channels;
-		    efftab[2].name = "rate";
+		    efftab[2].name = "resample";
 		    efftab[3].name = "avg";
 		} else {
 		    neffects = 3;
@@ -781,7 +784,7 @@
 		    neffects = 3;
 		    efftab[1].name = effp->name;
 		    efftab[1].outinfo.rate = informat.info.rate;
-		    efftab[2].name = "rate";
+		    efftab[2].name = "resample";
 		    if (informat.info.channels == 2)
 			    efftabR[2].name = "rate";
 		} else {
--- a/src/st.h
+++ b/src/st.h
@@ -243,6 +243,14 @@
 double         rdouble(P1(ft_t ft));
 void           wdouble(P2(ft_t ft, double d));
 
+/* raw routines are used by so many people their prototypes are defined
+ * here for convience.
+ */
+void rawstartread(P1(ft_t ft));
+void rawstartwrite(P1(ft_t ft));
+void rawstopread(P1(ft_t ft));
+void rawstopwrite(P1(ft_t ft));
+
 /* Utilities to byte-swap values */
 unsigned short swapw(P1(unsigned short us));		/* Swap short */
 ULONG  	       swapl(P1(ULONG ul));			/* Swap long */
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -26,6 +26,9 @@
 #include <malloc.h>
 #include <unistd.h>
 #include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <fcntl.h>
 #include "st.h"
 #include "libst.h"
--- a/src/swap.c
+++ b/src/swap.c
@@ -52,7 +52,7 @@
  * Prepare processing.
  * Do all initializations.
  */
-swap_start(effp)
+void swap_start(effp)
 eff_t effp;
 {
     if (effp->outinfo.channels == 1)
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -26,6 +26,9 @@
 
 #include <math.h>
 #include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include "st.h"
 
 /* Private data for Vibro effect */
--- a/src/wav.c
+++ b/src/wav.c
@@ -59,6 +59,9 @@
 
 #include <string.h>		/* Included for strncmp */
 #include <stdlib.h>		/* Included for malloc and free */
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
 #include <stdio.h>
 
 #ifdef HAVE_UNISTD_H