shithub: sox

Download patch

ref: 71b37b7c4f39520902a0e61e31a44f74c36d8598
parent: 829553d297fa56cb0f89ae959f87be048b54c9ad
author: cbagwell <cbagwell>
date: Thu Nov 18 14:46:15 EST 1999

Bug fixes and more configure support.

--- a/configure.in
+++ b/configure.in
@@ -122,11 +122,11 @@
 
 dnl Checks for header files.
 
-AC_CHECK_HEADERS(getopt.h unistd.h malloc.h)
+AC_CHECK_HEADERS(getopt.h unistd.h malloc.h byteswap.h)
 
 dnl Checks for library functions.
 
-AC_CHECK_FUNCS(getopt strerror memmove)
+AC_CHECK_FUNCS(getopt strerror memmove rand)
 
 dnl Checks for system services.
 
@@ -200,6 +200,10 @@
 fi
 if test "$oss_dsp" = yes
 then
+	if test "$ac_cv_dev_oss_dsp" = ""
+	then
+		AC_CHEKC_HEADERS(sys/soundcard.h machine/soundchare.h,)
+	fi
 	CFLAGS="$CFLAGS -DOSS_PLAYER"
 	NEED_OSS=1
 	PLAY_SUPPORT=1
@@ -240,6 +244,10 @@
 fi
 if test "$sun_audio" = yes
 then
+	if test "$ac_cv_dev_sun_audio" = ""
+	then
+		AC_CHEKC_HEADERS(sys/audioio.h, sun/audioio.h,)
+	fi
 	CFLAGS="$CFLAGS -DSUNAUDIO_PLAYER"
 	NEED_SUNAU=1
 	PLAY_SUPPORT=1
--- a/src/misc.c
+++ b/src/misc.c
@@ -160,7 +160,8 @@
 }
 
 
-/* Byte swappers */
+/* Byte swappers, use libc optimized macro's if possible */
+#ifndef HAVE_BYTESWAP_H
 
 unsigned short
 swapw(us)
@@ -169,6 +170,8 @@
 	return ((us >> 8) | (us << 8)) & 0xffff;
 }
 
+#endif
+
 ULONG
 swapl(ul)
 ULONG ul;
@@ -230,7 +233,6 @@
     return a * (b / st_gcd(a, b));
 }
 
-/* FIXME: Need to add to autoconf to check for random */
 #ifndef HAVE_RAND
 /* 
  * Portable random generator as defined by ANSI C Standard.
@@ -237,15 +239,15 @@
  * Don't ask me why not all C libraries include it.
  */
 
-static int rand_seed;
+static ULONG rand_seed = 1;
 
 int rand() {
 	rand_seed = (rand_seed * 1103515245L) + 12345L;
-	return ((rand_seed/65536L) % 32768L);
+	return ((ULONG)(rand_seed/65536L) % 32768L);
 }
 
 void srand(seed) 
-int seed;
+unsigned int seed;
 {
 	rand_seed = seed;
 }
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -194,8 +194,10 @@
   if (ct<=1) return ct;
   
   for (k=ct; k>1; ) {
-    int tmp, j;
-    j = rand() % k;
+    int tmp;
+    LONG j;
+    j = (LONG)rand() + ((LONG)rand()<<13); /* reasonably big */
+    j = j % k; /* non-negative! */
     k--;
     if (j != k) {
       tmp = m[k]; m[k]=m[j]; m[j]=tmp;
--- a/src/raw.c
+++ b/src/raw.c
@@ -292,7 +292,7 @@
 	 * only swap the buffer after its full.
 	 */
 	if (ft->swap)
-		swapn(p0, n);
+		swapn(ft->file.buf + ft->file.pos, n);
 	ft->file.pos += n;
 }
 
--- a/src/st.h
+++ b/src/st.h
@@ -13,6 +13,10 @@
 
 #include <stdio.h>
 
+#ifdef HAVE_BYTESWAP_H
+#include <byteswap.h>
+#endif
+
 /* FIXME: Move to seperate header */
 #ifdef __alpha__
 #include <sys/types.h>   /* To get defines for 32-bit integers */
@@ -239,10 +243,16 @@
 LONG rawread(P3(ft_t ft, LONG *buf, LONG nsamp));
 void rawwrite(P3(ft_t ft, LONG *buf, LONG nsamp));
 
-/* Utilities to byte-swap values */
+/* Utilities to byte-swap values, use libc optimized macro's if possible  */
+#ifdef HAVE_BYTESWAP_H
+#define swapw(x) bswap_16(x)
+#define swapl(x) bswap_32(x)
+#define swapf(x) (float)bswap_32((ULONG)(x))
+#else
 unsigned short swapw(P1(unsigned short us));		/* Swap short */
 ULONG  	       swapl(P1(ULONG ul));			/* Swap long */
 float  	       swapf(P1(float f));			/* Swap float */
+#endif
 double 	       swapd(P1(double d));			/* Swap double */
 
 void report(P2(char *, ...)),  warn(P2(char *, ...)),
--- a/test/README
+++ b/test/README
@@ -80,196 +80,3 @@
 adjusted data which the gnuplot will like.
 
 Modify the perl and gnuplot scripts to suit your needs.
-
-		SoX: Sound eXchange
-
-
-SoX (also known as Sound eXchange) translates sound samples between different
-file formats, and optionally performs various sound effects.  
-
-This release understands:
-
-  o Raw files in various binary formats
-  o Raw textual data
-  o Microsoft .WAV files
-    o PCM, u-law, a-law
-    o MS ADPCM (Read only)
-    o IMA ADPCM (Read only)
-  o MAUD files
-  o Sound Blaster .VOC files
-  o IRCAM SoundFile files
-  o SUN .au files
-    o PCM, u-law, a-law
-    o G7xx ADPCM files (read only)
-  o mutant DEC .au files
-  o Apple/SGI AIFF files
-  o CD-R (music CD format)
-  o Macintosh HCOM files
-  o Sounder files
-  o NeXT .snd files
-  o Soundtool (DOS) files
-  o Psion (palmtop) A-law files
-  o AVR files
-
-The sound effects include:
-
-  o Channel Averaging
-  o Band-pass filter
-  o Chorus effect
-  o Cut out loop samples
-  o Add an echo 
-  o Add a sequence of echos
-  o Apply a flanger effect
-  o Apply a high-pass filter
-  o Apply a low-pass filter
-  o Display a list of loops in a file
-  o Add masking noise to a signal
-  o Apply a phaser effect
-  o Convert from stereo to mono
-  o Change sampling rates using several different algorithms.
-  o Apply a reverb effect
-  o Reverse the sound samples (to search for Satanic messages ;-)
-  o Convert from mono to stereo
-  o Swap stereo channels
-  o Display general stats on a sound sample
-  o Add the world-famous Fender Vibro-Champ effect
-
-Big news! Lots of new effects have been added.  This includes most the
-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.
-
-History:
-
-This is the 12th release, Patchlevel 17 of the Sound Tools.
-SoX was originally written and maintained by Lance Norskog but
-unfortunetly he has stopped maintaining it since 1995.  I, Chris
-Bagwell (cbagwell@sprynet.com), have started maintaining it since
-1996 to the present.
-
-Caveats:
-
-SoX is intended as the Swiss Army knife of sound processing tools.  It 
-doesn't do anything very well, but sooner or later it comes in very handy.
-SoX is really only usable day-to-day if you hide the wacky options with 
-one-line shell scripts.
-
-Installing:
-
-Unless your using a precompiled binary version, you will need to compile
-SoX as described in the INSTALL file.  Please read that file for further
-instructions.
-
-Now, read TIPS, CHEAT.eft and CHEAT.  These give a background on how
-SoX deals with sound files and how to convert this format
-to that format, and apply various effects.
-
-SoX uses file suffices to determine the nature of a sound sample file.
-If it finds the suffix in its list, it uses the appropriate read
-or write handler to deal with that file.  You may override the suffix
-by giving a different type via the '-t type' argument.  See the manual
-page for more information.
-
-SoX has an auto-detect feature that attempts to figure out
-the nature of an unmarked sound sample.  It works very well.
-This feature is used if you specify '-t auto' for the file type.
-
-I hope to inspire the creation of a common base of sound processing
-tools for computer multimedia work, similar to the PBM toolkit for 
-image manipulation.
-
-Sound Tools may be used for any purpose.  Source distributions must
-must include the copyright notices, and (lack of) warranty information.
-Binary distributions must include acknowledgements to the creators.
-Files are copyright by their respective authors.
-
-If you have bug fixes/enhancements, please send it to me as I would like
-to coordinate the releases.  Please document your changes.  I don't 
-possess every kind of computer currently sold, and SoX is now beyond 
-the phase where I can understand and test most of your contributions.
-
-The majority of SoX features and source code are contributed
-by you the user.  Thank you very much for making SoX a success!
-
-	Creator:
-		Lance Norskog		thinman@meer.net (inactive currently)
-
-	Mantainer:
-		Chris Bagwell		cbagwell@sprynet.com
-
-	Contributors:
-		Juergen Mueller		jmueller@uia.ua.ac.be
-			chorus, echo, echos, flanger, phaser, and reverb
-			effects.
-		Guido Van Rossum	guido@cwi.nl
-			AU, AIFF, AUTO, HCOM, reverse,
-			many bug fixes
-		Jef Poskanzer		jef@well.sf.ca.us
-			original code for u-law and delay line
-		Bill Neisius		bill%solaria@hac2arpa.hac.com 
-			DOS port, 8SVX, Sounder, Soundtool formats
-			Apollo fixes, stat with auto-picker
-		Rick Richardson		rick@digibd.com
-			WAV and SB driver handlers, fixes
-		David Champion		dgc3@midway.uchicago.edu
-			Amiga port 
-		Pace Willisson		pace@blitz.com
-			Fixes for ESIX
-		Leigh Smith		leigh@psychokiller.dialix.oz.au
-			SMP and comment movement support.
-			AIFF Loop/MIDI support
-		David Sanderson		dws@ssec.wisc.edu
-			AIX3.1 fixes
-		Glenn Lewis		glewis@pcocd2.intel.com
-			AIFF chunking fixes
-		Brian Campbell		brianc@quantum.qnx.com
-			QNX port and 16-bit fixes
-		Chris Adams		gt8741@prism.gatech.edu
-			DOS port fixes
-		John Kohl		jtkohl@kolvir.elcr.ca.us
-			BSD386 port, VOC stereo support
-		Ken Kubo		ken@hmcvax.claremont.edu
-			VMS port, VOC stereo support
-		Frank Gadegast 		<phade@cs.tu-berlin.de>
-			Microsoft C 7.0 & C Borland 3.0 ports
-		David Elliot		<dce@scmc.sony.com>
-			CD-R format support
-		David Sears		<dns@essnj3.essnjay.com>
-			Linux support
-		Tom Littlejohn          <tlit@seq1.loc.gov>
-			Raw textual data
-		Boisy G. Pitre 		boisy@microware.com
-			OS9 port
-                Sun Microsystems, Guido Van Rossum
-		        CCITT G.711, G.721, G.723 implementation
-		Graeme Gill		graeme@labtam.labtam.oz.au
-			A-LAW format, Good .WAV handling,
-			avg channel expansion
-		Allen Grider		grider@hfsi.hfsi.com
-			VOC stereo mode, WAV file handling
-		Michel Fingerhut 	Michel.Fingerhut@ircam.fr
-			Upgrade 'sf' format to current IRCAM format.
-			Float file support.
-		Chris Knight
-			Achimedes Acorn support
-		Richard Caley 		R.Caley@ed.ac.uk
-			Psion WVE handler
-		Lutz Vieweg		lkv@mania.RoBIN.de
-			MAUD (Amiga) file handler
-		Tim Gardner		timg@tpi.com
-			Windows NT port for V7
-		Jimen Ching 		jiching@wiliki.eng.hawaii.edu
-			Libst porting bugs
-		Lauren Weinstein	lauren@vortex.com
-			DOS porting, scripts, professional use
-		Stan Brooks		stabro@megsinet.net
-			Rewrite of resample and polyphase code.
-			DSP filter effect.  Some test code/scripts.
-		Chris Bagwell		cbagwell@sprynet.com
-			OSS and Sun players, bugfixes, ADPCM support,
-			patch collection and maintance.
-		(your name could be here, too)
-		(I've probably lost a few, and several people fixed
-		 the same bugs.)
-