shithub: sox

Download patch

ref: 9e4c0adc28e558cd89181669c43ec8d92c7df4cd
parent: dd388d7b9611a79af627c010a3e6173e199019a3
author: cbagwell <cbagwell>
date: Fri Apr 2 21:09:46 EST 1999

Adding support for swap effect

--- a/Makefile.ami
+++ b/Makefile.ami
@@ -23,7 +23,7 @@
 ESRC	= avg.c band.c chorus.c copy.c cut.c deemphas.c dyn.c echo.c echos.c \
 	  flanger.c highp.c lowp.c map.c mask.c phaser.c pick.c \
 	  polyphas.c rate.c resample.c reverb.c reverse.c split.c \
-	  stat.c vibro.c 
+	  stat.c swap.c vibro.c 
 
 PSRC= sox.c
 
@@ -56,7 +56,7 @@
 EOBJ	= avg.o band.o chorus.o copy.o cut.o deemphas.o dyn.o echo.o echos.o \
 	  flanger.o highp.o lowp.o map.o mask.o phaser.o pick.o \
 	  polyphas.o rate.o resample.o reverb.o reverse.o split.o \
-	  stat.o vibro.o
+	  stat.o swap.o vibro.o
 
 ##SOUNDLIB is defined below
 LIBOBJS   = $(FOBJ) $(EOBJ) handlers.o libst.o misc.o getopt.o util.o
--- a/Makefile.dos
+++ b/Makefile.dos
@@ -1,79 +1,73 @@
-# Sound Tools Makefile - builds libst.lib and sox.exe
-#
-#   Short and Sweat makefile - cbagwell@sprynet.com 9/28/98
-#   With a little editing this makefile should compile under both
-#   pre and post Borland 3.0.
-#
-#   Also some support for MS VC based on info from Mark Morgan Lloyd
-#   <markMLl.in@telemetry.co.uk> 1/24/99
-
-# Need object files to know what libst.lib depends on.  All .c files
-# are compiled from default rules of make.
-
-FOBJ	= 8svx.obj aiff.obj alsa.obj au.obj auto.obj cdr.obj cvsd.obj dat.obj \
-	  g711.obj g721.obj g723_24.obj g723_40.obj g72x.obj gsm.obj \
-	  hcom.obj maud.obj oss.obj raw.obj sbdsp.obj sf.obj smp.obj \
-	  sndrtool.obj sunaudio.obj tx16w.obj voc.obj wav.obj wve.obj
-
-EOBJ	= avg.obj band.obj chorus.obj copy.obj cut.obj deemphas.obj \
-	  dyn.obj echo.obj echos.obj flanger.obj highp.obj lowp.obj \
-          map.obj mask.obj phaser.obj pick.obj polyphas.obj \
-	  rate.obj resample.obj reverb.obj reverse.obj split.obj \
-	  stat.obj vibro.obj
-
-LIBOBJS   = $(FOBJ) $(EOBJ) handlers.obj libst.obj misc.obj getopt.obj util.obj
-
-
-# The following defines tell where compiler files are kept, not where
-# things should be installed like Unix usually specifies.
-BINDIR  = d:\tc\bin
-LIBDIR  = d:\tc\lib
-INCDIR  = d:\tc\include
-
-#BINDIR	= d:\bc\bin
-#LIBDIR	= d:\bc\lib
-#INCDIR	= d:\bc\include
-
-# Use the following if you don't really need to define paths.
-#BINDIR = .
-#LIBDIR = .
-#INCDIR = .
-
-
-# Standard Borland options for Huge Memory Mode (more than 64k for both
-# code and data), Word aligned, compile to Objects only, Speed and Jump
-# optimized.
-# -v is for debuging and -N is to add stack corruption detection code.
-# both add unneeded size to code.
-#
-# Pick one of the next two defines for pre/post Borland C 3.0
-CC      = $(BINDIR)\tcc
-#CC      = $(BINDIR)\bcc
-LDD	= $(BINDIR)\tlib
-CFLAGS  = -DDOS -DHAVE_GETOPT -D__STDC__=1 -a -c -mh -G -O -v -N
-LFLAGS  = -v -mh
-
-# MS VC needs the following. /AL uses large memory model.
-#CC	= cl
-#LDD	= lib
-#CFLAGS	= -DDOS -D__STDC__=1 -DHAVE_GETOPT -c -O /AL /Gt8192
-#LFLAGS	= /AL /Gt8192
-
-.c.obj:
-       $(CC) $(CFLAGS) -I$(INCDIR) -L$(LIBDIR) $*.c
-       $(LDD) libst -$* +$*
-
-all: sox.exe
-
-sox.exe: sox.obj libst.lib
-        $(CC) $(LFLAGS) -L$(LIBDIR) sox.obj libst.lib
-
-libst.lib: $(LIBOBJS)
-
-sox.obj: sox.c st.h
-        $(CC) $(CFLAGS) -I$(INCDIR) -L$(LIBDIR) $*.c
-
-clean:
-        del *.obj
-        del sox.exe
-        del libst.lib
+# Sound Tools Makefile - builds libst.lib and sox.exe
+#
+#   Short and Sweat makefile - cbagwell@sprynet.com 9/28/98
+#   With a little editing this makefile should compile under both
+#   pre and post Borland 3.0.
+#
+#   Also some support for MS VC based on info from Mark Morgan Lloyd
+#   <markMLl.in@telemetry.co.uk> 1/24/99
+
+# Need object files to know what libst.lib depends on.  All .c files
+# are compiled from default rules of make.
+
+FOBJ	= 8svx.obj aiff.obj alsa.obj au.obj auto.obj cdr.obj cvsd.obj dat.obj \
+	  g711.obj g721.obj g723_24.obj g723_40.obj g72x.obj gsm.obj \
+	  hcom.obj maud.obj oss.obj raw.obj sbdsp.obj sf.obj smp.obj \
+	  sndrtool.obj sunaudio.obj tx16w.obj voc.obj wav.obj wve.obj
+
+EOBJ	= avg.obj band.obj chorus.obj copy.obj cut.obj deemphas.obj \
+	  dyn.obj echo.obj echos.obj flanger.obj highp.obj lowp.obj \
+          map.obj mask.obj phaser.obj pick.obj polyphas.obj \
+	  rate.obj resample.obj reverb.obj reverse.obj split.obj \
+	  stat.obj swap.obj vibro.obj
+
+LIBOBJS   = $(FOBJ) $(EOBJ) handlers.obj libst.obj misc.obj getopt.obj util.obj
+
+
+# The following defines tell where compiler files are kept, not where
+# things should be installed like Unix usually specifies.
+BINDIR  = d:\tc\bin
+LIBDIR  = d:\tc\lib
+INCDIR  = d:\tc\include
+
+#BINDIR	= d:\bc\bin
+#LIBDIR	= d:\bc\lib
+#INCDIR	= d:\bc\include
+
+# Standard Borland options for Huge Memory Mode (more than 64k for both
+# code and data), Word aligned, compile to Objects only, Speed and Jump
+# optimized.
+# -v is for debuging and -N is to add stack corruption detection code.
+# both add unneeded size to code.
+#
+# Pick one of the next two defines for pre/post Borland C 3.0
+CC      = $(BINDIR)\tcc
+#CC      = $(BINDIR)\bcc
+LDD	= $(BINDIR)\tlib
+CFLAGS  = -DDOS -DHAVE_GETOPT -D__STDC__=1 -a -c -mh -G -O -v -N
+LFLAGS  = -v -mh
+
+# MS VC needs the following. /AL uses large memory model.
+#CC	= cl
+#LDD	= lib
+#CFLAGS	= -DDOS -D__STDC__=1 -DHAVE_GETOPT -c -O /AL /Gt8192
+#LFLAGS	= /AL /Gt8192
+
+.c.obj:
+       $(CC) $(CFLAGS) -I$(INCDIR) -L$(LIBDIR) $*.c
+       $(LDD) libst -$* +$*
+
+all: sox.exe
+
+sox.exe: sox.obj libst.lib
+        $(CC) $(LFLAGS) -L$(LIBDIR) sox.obj libst.lib
+
+libst.lib: $(LIBOBJS)
+
+sox.obj: sox.c st.h
+        $(CC) $(CFLAGS) -I$(INCDIR) -L$(LIBDIR) $*.c
+
+clean:
+        del *.obj
+        del sox.exe
+        del libst.lib
--- a/Makefile.os9
+++ b/Makefile.os9
@@ -27,7 +27,7 @@
 	  $(RDIR)/lowp.r $(RDIR)/map.r $(RDIR)/mask.r $(RDIR)/phaser.r \
 	  $(RDIR)/pick.r $(RDIR)/polyphas.r $(RDIR)/rate.r \
 	  $(RDIR)/resample.r $(RDIR)/reverb.r $(RDIR)/reverse.r \
-	  $(RDIR)/split.r $(RDIR)/stat.r $(RDIR)/vibro.r
+	  $(RDIR)/split.r $(RDIR)/stat.r $(RDIR)/swap.r $(RDIR)/vibro.r
 
 
 LIBOBJS	=	$(FOBJ) $(EOBJ) $(RDIR)/handlers.r $(RDIR)/libst.r \
--- a/Makefile.unx
+++ b/Makefile.unx
@@ -34,7 +34,7 @@
 ESRC	= avg.c band.c chorus.c copy.c cut.c deemphas.c dyn.c echo.c echos.c \
 	  flanger.c highp.c lowp.c map.c mask.c phaser.c pick.c \
 	  polyphas.c rate.c resample.c reverb.c reverse.c split.c \
-	  stat.c vibro.c 
+	  stat.c swap.c vibro.c 
 
 PSRC	= sox.c
 
@@ -75,7 +75,7 @@
 EOBJ	= avg.o band.o chorus.o copy.o cut.o deemphas.o dyn.o echo.o echos.o \
 	  flanger.o highp.o lowp.o map.o mask.o phaser.o pick.o \
 	  polyphas.o rate.o resample.o reverb.o reverse.o split.o \
-	  stat.o vibro.o
+	  stat.o swap.o vibro.o
 
 SOUNDLIB = libst.a
 LIBOBJS = $(FOBJ) $(EOBJ) handlers.o libst.o misc.o util.o getopt.o
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -46,7 +46,7 @@
 ESRC	= avg.c band.c chorus.c copy.c cut.c deemphas.c dyn.c echo.c echos.c \
 	  flanger.c highp.c lowp.c map.c mask.c phaser.c pick.c \
 	  polyphas.c rate.c resample.c reverb.c reverse.c split.c \
-	  stat.c vibro.c 
+	  stat.c swap.c vibro.c 
 
 OSSSRC_0    =
 OSSSRC_1    = oss.c
@@ -67,7 +67,7 @@
 EOBJ	= avg.o band.o chorus.o copy.o cut.o deemphas.o dyn.o echo.o echos.o \
 	  flanger.o highp.o lowp.o map.o mask.o phaser.o pick.o \
 	  polyphas.o rate.o resample.o reverb.o reverse.o split.o \
-	  stat.o vibro.o
+	  stat.o swap.o vibro.o
 
 OSSOBJ_0    =
 OSSOBJ_1    = oss.o
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -517,16 +517,6 @@
 extern void poly_drain();
 extern void poly_stop();
 
-extern void split_getopts();
-extern void split_start();
-extern void split_flow();
-extern void split_stop();
-
-extern void stat_getopts();
-extern void stat_start();
-extern void stat_flow();
-extern void stat_stop();
-
 extern void rate_getopts();
 extern void rate_start();
 extern void rate_flow();
@@ -550,6 +540,22 @@
 extern void reverse_drain();
 extern void reverse_stop();
 
+extern void split_getopts();
+extern void split_start();
+extern void split_flow();
+extern void split_stop();
+
+extern void stat_getopts();
+extern void stat_start();
+extern void stat_flow();
+extern void stat_stop();
+
+extern void swap_getopts();
+extern void swap_start();
+extern void swap_flow();
+extern void swap_drain();
+extern void swap_stop();
+
 extern void vibro_getopts();
 extern void vibro_start();
 extern void vibro_flow();
@@ -624,6 +630,8 @@
 		split_getopts, split_start, split_flow, null_drain,split_stop},
 	{"stat", EFF_MCHAN | EFF_REPORT | EFF_RATE | EFF_CHAN,
 		stat_getopts, stat_start, stat_flow, null_drain, stat_stop},
+	{"swap", EFF_MCHAN,
+		swap_getopts, swap_start, swap_flow, swap_drain, swap_stop},
 	{"vibro", 0, 
 		vibro_getopts, vibro_start, vibro_flow, null_drain, nothing},
 	{0, 0, 0, 0, 0, 0, 0}
--- a/src/swap.c
+++ b/src/swap.c
@@ -84,6 +84,7 @@
 	    obuf[0] = ibuf[1];
 	    obuf[1] = ibuf[0];
 	    /* Advance buffer by 2 samples */
+	    ibuf += 2;
 	    obuf += 2;
 	}
 	
@@ -113,6 +114,7 @@
 	    obuf[2] = ibuf[swap->order[2]];
 	    obuf[3] = ibuf[swap->order[3]];
 	    /* Advance buffer by 2 samples */
+	    ibuf += 4;
 	    obuf += 4;
 	}
 	*isamp = len * 4;
@@ -119,6 +121,7 @@
 	*osamp = len * 4;
 	
 	break;
+    }
 }
 
 /*