shithub: sox

Download patch

ref: 677e7cebedd3ac9340ab37535a17ac705c3ffc30
parent: a5669f9fe646b82de46ca7dffe1a9f4e0e91353b
author: rrt <rrt>
date: Tue Feb 20 12:51:38 EST 2007

st -> sox

--- a/Makefile.am
+++ b/Makefile.am
@@ -7,8 +7,8 @@
 
 # man pages are not considered to be sources, so need to add "dist_"
 # prefix to ensure they are added to the distribution.
-dist_man_MANS = sox.1 soxexam.7 libst.3
-EXTRA_DIST = sox.txt soxexam.txt libst.txt
+dist_man_MANS = sox.1 soxexam.7 libsox.3
+EXTRA_DIST = sox.txt soxexam.txt libsox.txt
 
 play.1 rec.1: sox.1
 	$(RM) $@ && $(LN_S) $< $@
@@ -17,13 +17,13 @@
 .1.txt .3.txt .7.txt:
 	tbl $(srcdir)/$< | nroff -man | col -b > $@
 
-txt: sox.txt soxexam.txt libst.txt
+txt: sox.txt soxexam.txt libsox.txt
 
 # Rule for making PDF man pages
 .1.pdf .3.pdf .7.pdf:
 	tbl $(srcdir)/$< | groff -man -Tps | ps2pdf - $@
 
-pdf: sox.pdf soxexam.pdf libst.pdf
+pdf: sox.pdf soxexam.pdf libsox.pdf
 
 install-data-hook:
 	cd $(DESTDIR)$(mandir)/man1 && $(RM) play.1 && $(LN_S) sox.1 play.1
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
 AM_INIT_AUTOMAKE
 
 dnl create a config.h file (Automake will add -DHAVE_CONFIG_H)
-AM_CONFIG_HEADER(src/stconfig.h)
+AM_CONFIG_HEADER(src/soxconfig.h)
 
 dnl Check we have the right srcdir
 AC_CONFIG_SRCDIR(sox.1)
@@ -179,9 +179,9 @@
 AC_SUBST(SAMPLERATE_LIBS)
 
 dnl Generate output files.
-AX_CREATE_STDINT_H(src/ststdint.h)
+AX_CREATE_STDINT_H(src/soxstdint.h)
 AC_CONFIG_FILES(Makefile src/Makefile src/libgsm/Makefile
-		amr-wb/Makefile src/libst-config)
+		amr-wb/Makefile src/libsox-config)
 AC_OUTPUT
 
 if test "$found_libgsm" = "yes"; then
--- /dev/null
+++ b/libsox.3
@@ -1,0 +1,269 @@
+'\" t
+'\" The line above instructs most `man' programs to invoke tbl
+'\"
+'\" Separate paragraphs; not the same as PP which resets indent level.
+.de SP
+.if t .sp .5
+.if n .sp
+..
+'\"
+'\" Replacement em-dash for nroff (default is too short).
+.ie n .ds m " - 
+.el .ds m \(em
+'\"
+'\" Placeholder macro for if longer nroff arrow is needed.
+.ds RA \(->
+'\"
+'\" Decimal point set slightly raised
+.ds d \v'-.15m'.\v'+.15m'
+'\"
+.TH ST 3 "January 31, 2007"
+.SH NAME
+libsox\*mSoX\*mAudio file-format and effect library
+.SH SYNOPSIS
+.nf
+.B #include <st.h>
+.P
+.B ft_t sox_open_input(const char *\fIpath\fB, const sox_signalinfo_t *\fIinfo\fB, const char *\fIfiletype\fB);
+.P
+.B ft_t sox_open_output(const char *\fIpath\fB, const sox_signalinfo_t *\fIinfo\fB, const char *\fIfiletype\fB, const char *\fIcomment\fB);
+.P
+.B sox_ssize_t sox_read(ft_t \fIft\fB, sox_sample_t *\fIbuf\fB, sox_ssize_t \fIlen\fB);
+.P
+.B sox_ssize_t sox_write(ft_t \fIft\fB, sox_sample_t *\fIbuf\fB, sox_ssize_t \fIlen\fB);
+.P
+.B int sox_close(ft_t \fIft\fB);
+.P
+.B int sox_seek(ft_t \fIft\fB, sox_size_t \fIoffset\fB, int \fIwhence\fB);
+.P
+.B cc \fIfile.c\fB -o \fIfile \f-lsox
+.fi
+.SH DESCRIPTION
+.I libsox
+is a library of sound sample file format readers/writers and sound
+effects processors. It is mainly developed for use by SoX but is
+useful for any sound application.
+.P
+\fBsox_open_input\fR function opens the file for reading whose name is
+the string pointed to by \fIpath\fR and associates an ft_t with it. If
+\fIinfo\fR is non-NULL then it will be used to specify the data format
+of the input file. This is normally only needed for headerless audio
+files since the information is not stored in the file. If
+\fIfiletype\fR is non-NULL then it will be used to specify the file
+type. If this is not specified then the file type is attempted to be
+derived by looking at the file header and/or the filename extension. A
+special name of "-" can be used to read data from stdin.
+.P
+\fBsox_open_output\fR function opens the file for writing whose name is
+the string pointed to by \fIpath\fR and associates an ft_t with it. If
+\fIinfo\fR is non-NULL then it will be used to specify the data format
+of the output file. Since most file formats can write data in
+different data formats, this generally has to be specified. The info
+structure from the input format handler can be specified to copy data
+over in the same format. If \fIcomment\fR is non-NULL, it will be
+written in the file header for formats that support comments. If
+\fIfiletype\fR is non-NULL then it will be used to specify the file
+type. If this is not specified then the file type is attempted to be
+derived by looking at the filename extension. A special name of "-"
+can be used to write data to stdout.
+.P
+The function \fBsox_read\fR reads \fIlen\fR samples in to \fIbuf\fR
+using the format handler specified by \fIft\fR. All data read is
+converted to 32-bit signed samples before being placed in to
+\fIbuf\fR. The value of \fIlen\fR is specified in total samples. If
+its value is not evenly divisable by the number of channels, undefined
+behavior will occur.
+.P
+The function \fBsox_write\fR writes \fIlen\fR samples from \fIbuf\fR
+using the format handler specified by \fIft\fR. Data in \fIbuf\fR must
+be 32-bit signed samples and will be converted during the write
+process. The value of \fIlen\fR is specified in total samples. If its
+value is not evenly divisable by the number of channels, undefined
+behavior will occur.
+.P
+The \fBsox_close\fR function dissociates the named \fIft_t\fR from its
+underlying file or set of functions. If the format handler was being
+used for output, any buffered data is written first.
+.P
+SoX includes skeleton C files to assist you in writing new
+formats (skelform.c) and effects (skeleff.c). sox.c itself is a good
+starting point for new programs. Note that new formats can often just
+deal with the header and then use raw.c's routines for reading and
+writing.
+.SH RETURN VALUE
+Upon successful completion \fBsox_open_input\fR and
+\fBsox_open_output\fR return a ft_t (which is a pointer). Otherwise,
+NULL is returned. TODO: Need a what to return reason for failures.
+Currently, relies on sox_warn to print information.
+.P
+\fBsox_read\fR and \fBsox_write\fR return the number of samples
+successfully read or written. If an error occurs, or the end-of-file
+is reached, the return value is a short item count or SOX_EOF. TODO:
+\fBsox_read\fR does not distiguish between end-of-ifle and error. Need
+an feof() and ferror() concept to determine which occured.
+.P
+Upon successful completion \fBsox_close\fR returns 0. Otherwise, SOX_EOF
+is returned. In either case, any further access (including another
+call to \fBsox_close\fR()) to the handler results in undefined
+behavior. TODO: Need a way to return reason for failures. Currently,
+relies on sox_warn to print information.
+.P
+Upon successful completion \fBsox_seek\fR returns 0. Otherwise, SOX_EOF
+is returned. TODO Need to set a global error and implement sox_tell.
+.SH ERRORS
+TODO
+.SH INTERNALS
+SoX's formats and effects operate on an internal buffer format of
+signed 32-bit longs. The data processing routines are called with
+buffers of these samples, and buffer sizes which refer to the number
+of samples processed, not the number of bytes. File readers translate
+the input samples to signed 32-bit integers and return the number of
+samples read. For example, data in linear signed byte format is
+left-shifted 24 bits.
+.P
+This does cause problems in processing the data.  
+For example:
+.br
+	*obuf++ = (*ibuf++ + *ibuf++)/2;
+.br
+would
+.I not
+mix down left and right channels into one monophonic channel,
+because the resulting samples would overflow 32 bits.
+Instead, the ``avg'' effects must use:
+.br
+	*obuf++ = *ibuf++/2 + *ibuf++/2;
+.br
+.P
+Stereo data is stored with the left and right speaker data in
+successive samples.
+Quadraphonic data is stored in this order: 
+left front, right front, left rear, right rear.
+.SH FORMATS
+A 
+.I format 
+is responsible for translating between sound sample files
+and an internal buffer.  The internal buffer is store in signed longs
+with a fixed sampling rate.  The 
+.I format
+operates from two data structures:
+a format structure, and a private structure.
+.P
+The format structure contains a list of control parameters for
+the sample: sampling rate, data size (8, 16, or 32 bits),
+encoding (unsigned, signed, floating point, etc.), number of sound channels.
+It also contains other state information: whether the sample file
+needs to be byte-swapped, whether sox_seek() will work, its suffix,
+its file stream pointer, its 
+.I format
+pointer, and the 
+.I private
+structure for the 
+.I format .
+.P
+The 
+.I private 
+area is just a preallocated data array for the 
+.I format
+to use however it wishes.  
+It should have a defined data structure
+and cast the array to that structure.  
+See voc.c for the use of a private data area.  
+Voc.c has to track the number of samples it 
+writes and when finishing, seek back to the beginning of the file
+and write it out.
+The private area is not very large.
+The ``echo'' effect has to malloc() a much larger area for its
+delay line buffers.
+.P
+A 
+.I format
+has 6 routines:
+.TP 20
+startread
+Set up the format parameters, or read in
+a data header, or do what needs to be done.
+.TP 20
+read
+Given a buffer and a length: 
+read up to that many samples, 
+transform them into signed long integers,
+and copy them into the buffer.
+Return the number of samples actually read.
+.TP 20
+stopread
+Do what needs to be done.
+.TP 20
+startwrite
+Set up the format parameters, or write out 
+a data header, or do what needs to be done.
+.TP 20
+write
+Given a buffer and a length: 
+copy that many samples out of the buffer,
+convert them from signed longs to the appropriate
+data, and write them to the file.
+If it can't write out all the samples,
+fail.
+.TP 20
+stopwrite
+Fix up any file header, or do what needs to be done.
+.SH EFFECTS
+An effects loop has one input and one output stream.
+It has 5 routines.
+.TP 20
+getopts
+is called with a character string argument list for the effect.
+.TP 20
+start
+is called with the signal parameters for the input and output
+streams.
+.TP 20 
+flow
+is called with input and output data buffers,
+and (by reference) the input and output data buffer sizes.
+It processes the input buffer into the output buffer,
+and sets the size variables to the numbers of samples
+actually processed.
+It is under no obligation to read from the input buffer or
+write to the output buffer during the same call.  If the
+call returns SOX_EOF then this should be used as an indication
+that this effect will no longer read any data and can be used
+to switch to drain mode sooner.
+.TP 20 
+drain
+is called after there are no more input data samples.
+If the effect wishes to generate more data samples
+it copies the generated data into a given buffer
+and returns the number of samples generated.
+If it fills the buffer, it will be called again, etc.
+The echo effect uses this to fade away.
+.TP 20
+stop
+is called when there are no more input samples to process.
+.I stop
+may generate output samples on its own.
+See echo.c for how to do this, 
+and see that what it does is absolutely bogus.
+.SH BUGS
+This manual page is both incomplete and out of date.
+.SH SEE ALSO
+.BR sox (1),
+.BR soxexam (7)
+.SH LICENSE
+Copyright 1991 Lance Norskog and Sundry Contributors.
+Copyright 1998\-2007 by Chris Bagwell and SoX Contributors.
+.SP
+This library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1, or (at your option)
+any later version.
+.SP
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
+.SH AUTHORS
+Chris Bagwell (cbagwell@users.sourceforge.net).
+Other authors and contributors are listed in the AUTHORS file that
+is distributed with the source code.
--- a/libst.3
+++ /dev/null
@@ -1,269 +1,0 @@
-'\" t
-'\" The line above instructs most `man' programs to invoke tbl
-'\"
-'\" Separate paragraphs; not the same as PP which resets indent level.
-.de SP
-.if t .sp .5
-.if n .sp
-..
-'\"
-'\" Replacement em-dash for nroff (default is too short).
-.ie n .ds m " - 
-.el .ds m \(em
-'\"
-'\" Placeholder macro for if longer nroff arrow is needed.
-.ds RA \(->
-'\"
-'\" Decimal point set slightly raised
-.ds d \v'-.15m'.\v'+.15m'
-'\"
-.TH ST 3 "January 31, 2007"
-.SH NAME
-libst\*mSound Tools\*mAudio file-format and effect library
-.SH SYNOPSIS
-.nf
-.B #include <st.h>
-.P
-.B ft_t st_open_input(const char *\fIpath\fB, const st_signalinfo_t *\fIinfo\fB, const char *\fIfiletype\fB);
-.P
-.B ft_t st_open_output(const char *\fIpath\fB, const st_signalinfo_t *\fIinfo\fB, const char *\fIfiletype\fB, const char *\fIcomment\fB);
-.P
-.B st_ssize_t st_read(ft_t \fIft\fB, st_sample_t *\fIbuf\fB, st_ssize_t \fIlen\fB);
-.P
-.B st_ssize_t st_write(ft_t \fIft\fB, st_sample_t *\fIbuf\fB, st_ssize_t \fIlen\fB);
-.P
-.B int st_close(ft_t \fIft\fB);
-.P
-.B int st_seek(ft_t \fIft\fB, st_size_t \fIoffset\fB, int \fIwhence\fB);
-.P
-.B cc \fIfile.c\fB -o \fIfile \fBlibst.a
-.fi
-.SH DESCRIPTION
-.I Sound\ Tools
-is a library of sound sample file format readers/writers and sound
-effects processors. It is mainly developed for use by SoX but is
-useful for any sound application.
-.P
-\fBst_open_input\fR function opens the file for reading whose name is
-the string pointed to by \fIpath\fR and associates an ft_t with it. If
-\fIinfo\fR is non-NULL then it will be used to specify the data format
-of the input file. This is normally only needed for headerless audio
-files since the information is not stored in the file. If
-\fIfiletype\fR is non-NULL then it will be used to specify the file
-type. If this is not specified then the file type is attempted to be
-derived by looking at the file header and/or the filename extension. A
-special name of "-" can be used to read data from stdin.
-.P
-\fBst_open_output\fR function opens the file for writing whose name is
-the string pointed to by \fIpath\fR and associates an ft_t with it. If
-\fIinfo\fR is non-NULL then it will be used to specify the data format
-of the output file. Since most file formats can write data in
-different data formats, this generally has to be specified. The info
-structure from the input format handler can be specified to copy data
-over in the same format. If \fIcomment\fR is non-NULL, it will be
-written in the file header for formats that support comments. If
-\fIfiletype\fR is non-NULL then it will be used to specify the file
-type. If this is not specified then the file type is attempted to be
-derived by looking at the filename extension. A special name of "-"
-can be used to write data to stdout.
-.P
-The function \fBst_read\fR reads \fIlen\fR samples in to \fIbuf\fR
-using the format handler specified by \fIft\fR. All data read is
-converted to 32-bit signed samples before being placed in to
-\fIbuf\fR. The value of \fIlen\fR is specified in total samples. If
-its value is not evenly divisable by the number of channels, undefined
-behavior will occur.
-.P
-The function \fBst_write\fR writes \fIlen\fR samples from \fIbuf\fR
-using the format handler specified by \fIft\fR. Data in \fIbuf\fR must
-be 32-bit signed samples and will be converted during the write
-process. The value of \fIlen\fR is specified in total samples. If its
-value is not evenly divisable by the number of channels, undefined
-behavior will occur.
-.P
-The \fBst_close\fR function dissociates the named \fIft_t\fR from its
-underlying file or set of functions. If the format handler was being
-used for output, any buffered data is written first.
-.P
-SoX includes skeleton C files to assist you in writing new
-formats (skelform.c) and effects (skeleff.c). sox.c itself is a good
-starting point for new programs. Note that new formats can often just
-deal with the header and then use raw.c's routines for reading and
-writing.
-.SH RETURN VALUE
-Upon successful completion \fBst_open_input\fR and
-\fBst_open_output\fR return a ft_t (which is a pointer). Otherwise,
-NULL is returned. TODO: Need a what to return reason for failures.
-Currently, relies on st_warn to print information.
-.P
-\fBst_read\fR and \fBst_write\fR return the number of samples
-successfully read or written. If an error occurs, or the end-of-file
-is reached, the return value is a short item count or ST_EOF. TODO:
-\fBst_read\fR does not distiguish between end-of-ifle and error. Need
-an feof() and ferror() concept to determine which occured.
-.P
-Upon successful completion \fBst_close\fR returns 0. Otherwise, ST_EOF
-is returned. In either case, any further access (including another
-call to \fBst_close\fR()) to the handler results in undefined
-behavior. TODO: Need a way to return reason for failures. Currently,
-relies on st_warn to print information.
-.P
-Upon successful completion \fBst_seek\fR returns 0. Otherwise, ST_EOF
-is returned. TODO Need to set a global error and implement st_tell.
-.SH ERRORS
-TODO
-.SH INTERNALS
-SoX's formats and effects operate on an internal buffer format of
-signed 32-bit longs. The data processing routines are called with
-buffers of these samples, and buffer sizes which refer to the number
-of samples processed, not the number of bytes. File readers translate
-the input samples to signed 32-bit integers and return the number of
-samples read. For example, data in linear signed byte format is
-left-shifted 24 bits.
-.P
-This does cause problems in processing the data.  
-For example:
-.br
-	*obuf++ = (*ibuf++ + *ibuf++)/2;
-.br
-would
-.I not
-mix down left and right channels into one monophonic channel,
-because the resulting samples would overflow 32 bits.
-Instead, the ``avg'' effects must use:
-.br
-	*obuf++ = *ibuf++/2 + *ibuf++/2;
-.br
-.P
-Stereo data is stored with the left and right speaker data in
-successive samples.
-Quadraphonic data is stored in this order: 
-left front, right front, left rear, right rear.
-.SH FORMATS
-A 
-.I format 
-is responsible for translating between sound sample files
-and an internal buffer.  The internal buffer is store in signed longs
-with a fixed sampling rate.  The 
-.I format
-operates from two data structures:
-a format structure, and a private structure.
-.P
-The format structure contains a list of control parameters for
-the sample: sampling rate, data size (8, 16, or 32 bits),
-encoding (unsigned, signed, floating point, etc.), number of sound channels.
-It also contains other state information: whether the sample file
-needs to be byte-swapped, whether st_seek() will work, its suffix,
-its file stream pointer, its 
-.I format
-pointer, and the 
-.I private
-structure for the 
-.I format .
-.P
-The 
-.I private 
-area is just a preallocated data array for the 
-.I format
-to use however it wishes.  
-It should have a defined data structure
-and cast the array to that structure.  
-See voc.c for the use of a private data area.  
-Voc.c has to track the number of samples it 
-writes and when finishing, seek back to the beginning of the file
-and write it out.
-The private area is not very large.
-The ``echo'' effect has to malloc() a much larger area for its
-delay line buffers.
-.P
-A 
-.I format
-has 6 routines:
-.TP 20
-startread
-Set up the format parameters, or read in
-a data header, or do what needs to be done.
-.TP 20
-read
-Given a buffer and a length: 
-read up to that many samples, 
-transform them into signed long integers,
-and copy them into the buffer.
-Return the number of samples actually read.
-.TP 20
-stopread
-Do what needs to be done.
-.TP 20
-startwrite
-Set up the format parameters, or write out 
-a data header, or do what needs to be done.
-.TP 20
-write
-Given a buffer and a length: 
-copy that many samples out of the buffer,
-convert them from signed longs to the appropriate
-data, and write them to the file.
-If it can't write out all the samples,
-fail.
-.TP 20
-stopwrite
-Fix up any file header, or do what needs to be done.
-.SH EFFECTS
-An effects loop has one input and one output stream.
-It has 5 routines.
-.TP 20
-getopts
-is called with a character string argument list for the effect.
-.TP 20
-start
-is called with the signal parameters for the input and output
-streams.
-.TP 20 
-flow
-is called with input and output data buffers,
-and (by reference) the input and output data buffer sizes.
-It processes the input buffer into the output buffer,
-and sets the size variables to the numbers of samples
-actually processed.
-It is under no obligation to read from the input buffer or
-write to the output buffer during the same call.  If the
-call returns ST_EOF then this should be used as an indication
-that this effect will no longer read any data and can be used
-to switch to drain mode sooner.
-.TP 20 
-drain
-is called after there are no more input data samples.
-If the effect wishes to generate more data samples
-it copies the generated data into a given buffer
-and returns the number of samples generated.
-If it fills the buffer, it will be called again, etc.
-The echo effect uses this to fade away.
-.TP 20
-stop
-is called when there are no more input samples to process.
-.I stop
-may generate output samples on its own.
-See echo.c for how to do this, 
-and see that what it does is absolutely bogus.
-.SH BUGS
-This manual page is both incomplete and out of date.
-.SH SEE ALSO
-.BR sox (1),
-.BR soxexam (7)
-.SH LICENSE
-Copyright 1991 Lance Norskog and Sundry Contributors.
-Copyright 1998\-2007 by Chris Bagwell and SoX Contributors.
-.SP
-This library is free software; you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 2.1, or (at your option)
-any later version.
-.SP
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Lesser General Public License for more details.
-.SH AUTHORS
-Chris Bagwell (cbagwell@users.sourceforge.net).
-Other authors and contributors are listed in the AUTHORS file that
-is distributed with the source code.
--- a/sox.1
+++ b/sox.1
@@ -57,7 +57,7 @@
 device and if invoked as `rec', the default sound device is used as an
 input source.
 .SP
-The heart of SoX is a library called `Sound Tools'.  Those interested in
+The heart of SoX is a library called libsox.  Those interested in
 extending SoX or using it in other programs should refer to the Sound
 Tools manual page:
 .BR libst (3).
--- a/src/.cvsignore
+++ b/src/.cvsignore
@@ -1,6 +1,6 @@
 Makefile Makefile.in
-libst-config
-stconfig.h.in stconfig.h ststdint.h
+libsox-config
+soxconfig.h.in soxconfig.h soxstdint.h
 .deps
 stamp-h1
 .libs *.lo *.la
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -2,7 +2,7 @@
  * Amiga 8SVX format handler: W V Neisius, February 1992
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <math.h>
 #include <errno.h>
@@ -20,13 +20,13 @@
         FILE *ch[4];
 }*svx_t;
 
-static void svxwriteheader(ft_t, st_size_t);
+static void svxwriteheader(ft_t, sox_size_t);
 
 /*======================================================================*/
 /*                         8SVXSTARTREAD                                */
 /*======================================================================*/
 
-static int st_svxstartread(ft_t ft)
+static int sox_svxstartread(ft_t ft)
 {
         svx_t p = (svx_t ) ft->priv;
 
@@ -43,60 +43,60 @@
 
         if (! ft->seekable)
         {
-                st_fail_errno(ft,ST_EINVAL,"8svx input file must be a file, not a pipe");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EINVAL,"8svx input file must be a file, not a pipe");
+                return (SOX_EOF);
         }
         rate = 0;
         channels = 1;
 
         /* read FORM chunk */
-        if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "FORM", 4) != 0)
+        if (sox_reads(ft, buf, 4) == SOX_EOF || strncmp(buf, "FORM", 4) != 0)
         {
-                st_fail_errno(ft, ST_EHDR, "Header did not begin with magic word 'FORM'");
-                return(ST_EOF);
+                sox_fail_errno(ft, SOX_EHDR, "Header did not begin with magic word 'FORM'");
+                return(SOX_EOF);
         }
-        st_readdw(ft, &totalsize);
-        if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "8SVX", 4) != 0)
+        sox_readdw(ft, &totalsize);
+        if (sox_reads(ft, buf, 4) == SOX_EOF || strncmp(buf, "8SVX", 4) != 0)
         {
-                st_fail_errno(ft, ST_EHDR, "'FORM' chunk does not specify '8SVX' as type");
-                return(ST_EOF);
+                sox_fail_errno(ft, SOX_EHDR, "'FORM' chunk does not specify '8SVX' as type");
+                return(SOX_EOF);
         }
 
         /* read chunks until 'BODY' (or end) */
-        while (st_reads(ft, buf, 4) == ST_SUCCESS && strncmp(buf,"BODY",4) != 0) {
+        while (sox_reads(ft, buf, 4) == SOX_SUCCESS && strncmp(buf,"BODY",4) != 0) {
                 if (strncmp(buf,"VHDR",4) == 0) {
-                        st_readdw(ft, &chunksize);
+                        sox_readdw(ft, &chunksize);
                         if (chunksize != 20)
                         {
-                                st_fail_errno(ft, ST_EHDR, "VHDR chunk has bad size");
-                                return(ST_EOF);
+                                sox_fail_errno(ft, SOX_EHDR, "VHDR chunk has bad size");
+                                return(SOX_EOF);
                         }
-                        st_seeki(ft,12,SEEK_CUR);
-                        st_readw(ft, &rate);
-                        st_seeki(ft,1,SEEK_CUR);
-                        st_readbuf(ft, buf,1,1);
+                        sox_seeki(ft,12,SEEK_CUR);
+                        sox_readw(ft, &rate);
+                        sox_seeki(ft,1,SEEK_CUR);
+                        sox_readbuf(ft, buf,1,1);
                         if (buf[0] != 0)
                         {
-                                st_fail_errno(ft, ST_EFMT, "Unsupported data compression");
-                                return(ST_EOF);
+                                sox_fail_errno(ft, SOX_EFMT, "Unsupported data compression");
+                                return(SOX_EOF);
                         }
-                        st_seeki(ft,4,SEEK_CUR);
+                        sox_seeki(ft,4,SEEK_CUR);
                         continue;
                 }
 
                 if (strncmp(buf,"ANNO",4) == 0) {
-                        st_readdw(ft, &chunksize);
+                        sox_readdw(ft, &chunksize);
                         if (chunksize & 1)
                                 chunksize++;
                         chunk_buf = (char *) xmalloc(chunksize + 2);
-                        if (st_readbuf(ft, chunk_buf,1,(size_t)chunksize)
+                        if (sox_readbuf(ft, chunk_buf,1,(size_t)chunksize)
                                         != chunksize)
                         {
-                                st_fail_errno(ft, ST_EHDR, "Couldn't read all of header");
-                                return(ST_EOF);
+                                sox_fail_errno(ft, SOX_EHDR, "Couldn't read all of header");
+                                return(SOX_EOF);
                         }
                         chunk_buf[chunksize] = '\0';
-                        st_debug("%s",chunk_buf);
+                        sox_debug("%s",chunk_buf);
                         free(chunk_buf);
 
                         continue;
@@ -103,18 +103,18 @@
                 }
 
                 if (strncmp(buf,"NAME",4) == 0) {
-                        st_readdw(ft, &chunksize);
+                        sox_readdw(ft, &chunksize);
                         if (chunksize & 1)
                                 chunksize++;
                         chunk_buf = (char *) xmalloc(chunksize + 1);
-                        if (st_readbuf(ft, chunk_buf,1,(size_t)chunksize)
+                        if (sox_readbuf(ft, chunk_buf,1,(size_t)chunksize)
                                         != chunksize)
                         {
-                                st_fail_errno(ft, ST_EHDR, "Couldn't read all of header");
-                                return(ST_EOF);
+                                sox_fail_errno(ft, SOX_EHDR, "Couldn't read all of header");
+                                return(SOX_EOF);
                         }
                         chunk_buf[chunksize] = '\0';
-                        st_debug("%s",chunk_buf);
+                        sox_debug("%s",chunk_buf);
                         free(chunk_buf);
 
                         continue;
@@ -121,13 +121,13 @@
                 }
 
                 if (strncmp(buf,"CHAN",4) == 0) {
-                        st_readdw(ft, &chunksize);
+                        sox_readdw(ft, &chunksize);
                         if (chunksize != 4)
                         {
-                                st_fail_errno(ft, ST_EHDR, "Couldn't read all of header");
-                                return(ST_EOF);
+                                sox_fail_errno(ft, SOX_EHDR, "Couldn't read all of header");
+                                return(SOX_EOF);
                         }
-                        st_readdw(ft, &channels);
+                        sox_readdw(ft, &channels);
                         channels = (channels & 0x01) +
                                         ((channels & 0x02) >> 1) +
                                         ((channels & 0x04) >> 2) +
@@ -137,10 +137,10 @@
                 }
 
                 /* some other kind of chunk */
-                st_readdw(ft, &chunksize);
+                sox_readdw(ft, &chunksize);
                 if (chunksize & 1)
                         chunksize++;
-                st_seeki(ft,chunksize,SEEK_CUR);
+                sox_seeki(ft,chunksize,SEEK_CUR);
                 continue;
 
         }
@@ -147,53 +147,53 @@
 
         if (rate == 0)
         {
-                st_fail_errno(ft, ST_ERATE, "Invalid sample rate");
-                return(ST_EOF);
+                sox_fail_errno(ft, SOX_ERATE, "Invalid sample rate");
+                return(SOX_EOF);
         }
         if (strncmp(buf,"BODY",4) != 0)
         {
-                st_fail_errno(ft, ST_EHDR, "BODY chunk not found");
-                return(ST_EOF);
+                sox_fail_errno(ft, SOX_EHDR, "BODY chunk not found");
+                return(SOX_EOF);
         }
-        st_readdw(ft, &(p->nsamples));
+        sox_readdw(ft, &(p->nsamples));
 
         ft->length = p->nsamples;
         ft->signal.channels = channels;
         ft->signal.rate = rate;
-        ft->signal.encoding = ST_ENCODING_SIGN2;
-        ft->signal.size = ST_SIZE_BYTE;
+        ft->signal.encoding = SOX_ENCODING_SIGN2;
+        ft->signal.size = SOX_SIZE_BYTE;
 
         /* open files to channels */
         p->ch[0] = ft->fp;
-        chan1_pos = st_tell(ft);
+        chan1_pos = sox_tell(ft);
 
         for (i = 1; i < channels; i++) {
                 if ((p->ch[i] = fopen(ft->filename, "rb")) == NULL)
                 {
-                        st_fail_errno(ft,errno,"Can't open channel file '%s'",
+                        sox_fail_errno(ft,errno,"Can't open channel file '%s'",
                                 ft->filename);
-                        return(ST_EOF);
+                        return(SOX_EOF);
                 }
 
                 /* position channel files */
                 if (fseeko(p->ch[i],chan1_pos,SEEK_SET))
                 {
-                    st_fail_errno (ft,errno,"Can't position channel %d",i);
-                    return(ST_EOF);
+                    sox_fail_errno (ft,errno,"Can't position channel %d",i);
+                    return(SOX_EOF);
                 }
                 if (fseeko(p->ch[i],p->nsamples/channels*i,SEEK_CUR))
                 {
-                    st_fail_errno (ft,errno,"Can't seek channel %d",i);
-                    return(ST_EOF);
+                    sox_fail_errno (ft,errno,"Can't seek channel %d",i);
+                    return(SOX_EOF);
                 }
         }
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*======================================================================*/
 /*                         8SVXREAD                                     */
 /*======================================================================*/
-static st_size_t st_svxread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
+static sox_size_t sox_svxread(ft_t ft, sox_sample_t *buf, sox_size_t nsamp)
 {
         unsigned char datum;
         size_t done = 0, i;
@@ -207,7 +207,7 @@
                         if (feof(p->ch[i]))
                                 return done;
                         /* scale signed up to long's range */
-                        *buf++ = ST_SIGNED_BYTE_TO_SAMPLE(datum,);
+                        *buf++ = SOX_SIGNED_BYTE_TO_SAMPLE(datum,);
                 }
                 done += ft->signal.channels;
         }
@@ -217,7 +217,7 @@
 /*======================================================================*/
 /*                         8SVXSTOPREAD                                 */
 /*======================================================================*/
-static int st_svxstopread(ft_t ft)
+static int sox_svxstopread(ft_t ft)
 {
         size_t i;
 
@@ -227,13 +227,13 @@
         for (i = 1; i < ft->signal.channels; i++) {
                 fclose (p->ch[i]);
         }
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*======================================================================*/
 /*                         8SVXSTARTWRITE                               */
 /*======================================================================*/
-static int st_svxstartwrite(ft_t ft)
+static int sox_svxstartwrite(ft_t ft)
 {
         svx_t p = (svx_t ) ft->priv;
         size_t i;
@@ -243,18 +243,18 @@
         for (i = 1; i < ft->signal.channels; i++) {
                 if ((p->ch[i] = tmpfile()) == NULL)
                 {
-                        st_fail_errno(ft,errno,"Can't open channel output file");
-                        return(ST_EOF);
+                        sox_fail_errno(ft,errno,"Can't open channel output file");
+                        return(SOX_EOF);
                 }
         }
 
         /* write header (channel 0) */
-        ft->signal.encoding = ST_ENCODING_SIGN2;
-        ft->signal.size = ST_SIZE_BYTE;
+        ft->signal.encoding = SOX_ENCODING_SIGN2;
+        ft->signal.size = SOX_SIZE_BYTE;
 
         p->nsamples = 0;
         svxwriteheader(ft, p->nsamples);
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*======================================================================*/
@@ -261,7 +261,7 @@
 /*                         8SVXWRITE                                    */
 /*======================================================================*/
 
-static st_size_t st_svxwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static sox_size_t sox_svxwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
         svx_t p = (svx_t ) ft->priv;
 
@@ -272,7 +272,7 @@
 
         while(done < len) {
                 for (i = 0; i < ft->signal.channels; i++) {
-                        datum = ST_SAMPLE_TO_SIGNED_BYTE(*buf++, ft->clips);
+                        datum = SOX_SAMPLE_TO_SIGNED_BYTE(*buf++, ft->clips);
                         /* FIXME: Needs to pass ft struct and not FILE */
                         putc(datum, p->ch[i]);
                 }
@@ -285,7 +285,7 @@
 /*                         8SVXSTOPWRITE                                */
 /*======================================================================*/
 
-static int st_svxstopwrite(ft_t ft)
+static int sox_svxstopwrite(ft_t ft)
 {
         svx_t p = (svx_t ) ft->priv;
 
@@ -297,8 +297,8 @@
         for (i = 1; i < ft->signal.channels; i++) {
                 if (fseeko(p->ch[i], 0, 0))
                 {
-                        st_fail_errno (ft,errno,"Can't rewind channel output file %d",i);
-                        return(ST_EOF);
+                        sox_fail_errno (ft,errno,"Can't rewind channel output file %d",i);
+                        return(SOX_EOF);
                 }
                 while (!feof(p->ch[i])) {
                         len = fread(svxbuf, 1, 512, p->ch[i]);
@@ -309,16 +309,16 @@
 
         /* add a pad byte if BODY size is odd */
         if(p->nsamples % 2 != 0)
-            st_writeb(ft, '\0');
+            sox_writeb(ft, '\0');
 
         /* fixup file sizes in header */
-        if (st_seeki(ft, 0, 0) != 0)
+        if (sox_seeki(ft, 0, 0) != 0)
         {
-                st_fail_errno(ft,errno,"can't rewind output file to rewrite 8SVX header");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"can't rewind output file to rewrite 8SVX header");
+                return(SOX_EOF);
         }
         svxwriteheader(ft, p->nsamples);
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*======================================================================*/
@@ -325,7 +325,7 @@
 /*                         8SVXWRITEHEADER                              */
 /*======================================================================*/
 #define SVXHEADERSIZE 100
-static void svxwriteheader(ft_t ft, st_size_t nsamples)
+static void svxwriteheader(ft_t ft, sox_size_t nsamples)
 {
         int32_t formsize =  nsamples + SVXHEADERSIZE - 8;
 
@@ -332,31 +332,31 @@
         /* FORM size must be even */
         if(formsize % 2 != 0) formsize++;
 
-        st_writes(ft, "FORM");
-        st_writedw(ft, formsize);  /* size of file */
-        st_writes(ft, "8SVX"); /* File type */
+        sox_writes(ft, "FORM");
+        sox_writedw(ft, formsize);  /* size of file */
+        sox_writes(ft, "8SVX"); /* File type */
 
-        st_writes(ft, "VHDR");
-        st_writedw(ft, 20); /* number of bytes to follow */
-        st_writedw(ft, nsamples/ft->signal.channels);  /* samples, 1-shot */
-        st_writedw(ft, 0);  /* samples, repeat */
-        st_writedw(ft, 0);  /* samples per repeat cycle */
-        st_writew(ft, (int) ft->signal.rate); /* samples per second */
-        st_writeb(ft,1); /* number of octabes */
-        st_writeb(ft,0); /* data compression (none) */
-        st_writew(ft,1); st_writew(ft,0); /* volume */
+        sox_writes(ft, "VHDR");
+        sox_writedw(ft, 20); /* number of bytes to follow */
+        sox_writedw(ft, nsamples/ft->signal.channels);  /* samples, 1-shot */
+        sox_writedw(ft, 0);  /* samples, repeat */
+        sox_writedw(ft, 0);  /* samples per repeat cycle */
+        sox_writew(ft, (int) ft->signal.rate); /* samples per second */
+        sox_writeb(ft,1); /* number of octabes */
+        sox_writeb(ft,0); /* data compression (none) */
+        sox_writew(ft,1); sox_writew(ft,0); /* volume */
 
-        st_writes(ft, "ANNO");
-        st_writedw(ft, 32); /* length of block */
-        st_writes(ft, "File created by Sound Exchange  ");
+        sox_writes(ft, "ANNO");
+        sox_writedw(ft, 32); /* length of block */
+        sox_writes(ft, "File created by Sound Exchange  ");
 
-        st_writes(ft, "CHAN");
-        st_writedw(ft, 4);
-        st_writedw(ft, (ft->signal.channels == 2) ? 6 :
+        sox_writes(ft, "CHAN");
+        sox_writedw(ft, 4);
+        sox_writedw(ft, (ft->signal.channels == 2) ? 6 :
                    (ft->signal.channels == 4) ? 15 : 2);
 
-        st_writes(ft, "BODY");
-        st_writedw(ft, nsamples); /* samples in file */
+        sox_writes(ft, "BODY");
+        sox_writedw(ft, nsamples); /* samples in file */
 }
 
 /* Amiga 8SVX */
@@ -365,20 +365,20 @@
   NULL
 };
 
-static st_format_t st_svx_format = {
+static sox_format_t sox_svx_format = {
   svxnames,
   NULL,
-  ST_FILE_BIG_END,
-  st_svxstartread,
-  st_svxread,
-  st_svxstopread,
-  st_svxstartwrite,
-  st_svxwrite,
-  st_svxstopwrite,
-  st_format_nothing_seek
+  SOX_FILE_BIG_END,
+  sox_svxstartread,
+  sox_svxread,
+  sox_svxstopread,
+  sox_svxstartwrite,
+  sox_svxwrite,
+  sox_svxstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_svx_format_fn(void)
+const sox_format_t *sox_svx_format_fn(void)
 {
-    return &st_svx_format;
+    return &sox_svx_format;
 }
--- a/src/FFT.c
+++ b/src/FFT.c
@@ -51,7 +51,7 @@
 #include <math.h>
 #include <assert.h>
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include "FFT.h"
 
@@ -71,7 +71,7 @@
    int i;
 
    if (PowerOfTwo < 2) {
-      st_debug("Error: FFT called with size %d", PowerOfTwo);
+      sox_debug("Error: FFT called with size %d", PowerOfTwo);
       exit(2);
    }
 
@@ -129,7 +129,7 @@
    float tr, ti;                /* temp real, temp imaginary */
 
    if (!IsPowerOfTwo(NumSamples)) {
-      st_debug("%d is not a power of two", NumSamples);
+      sox_debug("%d is not a power of two", NumSamples);
       exit(2);
    }
 
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,9 +7,9 @@
 LIBTOOL = @LIBTOOL@ @LIBTOOLFLAGS@
 
 bin_PROGRAMS = sox
-bin_SCRIPTS = libst-config
-lib_LTLIBRARIES = libst.la
-include_HEADERS = st.h ststdint.h
+bin_SCRIPTS = libsox-config
+lib_LTLIBRARIES = libsox.la
+include_HEADERS = sox.h soxstdint.h
 
 formats = 8svx.c adpcm.c adpcm.h adpcms.c adpcms.h aiff.c au.c auto.c avr.c \
 	  cdr.c cvsd.c cvsdfilt.h dat.c flac.c g711.c g711.h g721.c g723_24.c \
@@ -27,13 +27,13 @@
 	  skeleff.c speed.c stat.c stretch.c swap.c synth.c synth.h tremolo.c \
 	  trim.c vibro.c vol.c
 
-libst_la_SOURCES = $(formats) $(effects) alsa.c oss.c sunaudio.c handlers.c \
-		   misc.c st_i.h stio.c util.c xmalloc.c xmalloc.h \
+libsox_la_SOURCES = $(formats) $(effects) alsa.c oss.c sunaudio.c handlers.c \
+		   misc.c sox_i.h soxio.c util.c xmalloc.c xmalloc.h \
 		   getopt.c getopt1.c getopt.h stconfig.h
-libst_la_LIBADD = @LIBGSM_LIBADD@
+libsox_la_LIBADD = @LIBGSM_LIBADD@
 
 sox_SOURCES = sox.c
-sox_LDADD = libst.la ../amr-wb/libamrwb.la
+sox_LDADD = libsox.la ../amr-wb/libamrwb.la
 
 EXTRA_DIST = tests.sh testall.sh tests.bat testall.bat monkey.au monkey.wav
 
--- a/src/adpcm.c
+++ b/src/adpcm.c
@@ -35,11 +35,11 @@
 #include <sys/types.h>
 #include <math.h>
 #include <stdio.h>
-#include "st_i.h"
+#include "sox_i.h"
 #include "adpcm.h"
 
 typedef struct MsState {
-        st_sample_t  step;      /* step size */
+        sox_sample_t  step;      /* step size */
         short iCoef[2];
 } MsState_t;
 
@@ -53,7 +53,7 @@
  * 1.0 is scaled to 0x100
  */
 static const
-st_sample_t stepAdjustTable[] = {
+sox_sample_t stepAdjustTable[] = {
         230, 230, 230, 230, 307, 409, 512, 614,
         768, 614, 512, 409, 307, 230, 230, 230
 };
@@ -72,17 +72,17 @@
                         { 392,-232}
 };
 
-static inline st_sample_t AdpcmDecode(st_sample_t c, MsState_t *state,
-                               st_sample_t sample1, st_sample_t sample2)
+static inline sox_sample_t AdpcmDecode(sox_sample_t c, MsState_t *state,
+                               sox_sample_t sample1, sox_sample_t sample2)
 {
-        st_sample_t vlin;
-        st_sample_t sample;
-        st_sample_t step;
+        sox_sample_t vlin;
+        sox_sample_t sample;
+        sox_sample_t step;
 
         /** Compute next step value **/
         step = state->step;
         {
-                st_sample_t nstep;
+                sox_sample_t nstep;
                 nstep = (stepAdjustTable[c] * step) >> 8;
                 state->step = (nstep < 16)? 16:nstep;
         }
@@ -232,7 +232,7 @@
                 if (op) {   /* if we want output, put it in proper place */
                         op[ox>>3] |= (ox&4)? c:(c<<4);
                         ox += 4*chans;
-                        st_debug_more("%.1x",c);
+                        sox_debug_more("%.1x",c);
 
                 }
 
@@ -241,9 +241,9 @@
                 if (step < 16) step = 16;
 
         }
-        if (op) st_debug_more("\n");
+        if (op) sox_debug_more("\n");
         d2 /= n; /* be sure it's non-negative */
-        st_debug_more("ch%d: st %d->%d, d %.1f\n", ch, *iostep, step, sqrt(d2));
+        sox_debug_more("ch%d: st %d->%d, d %.1f\n", ch, *iostep, step, sqrt(d2));
         *iostep = step;
         return (int) sqrt(d2);
 }
@@ -278,7 +278,7 @@
 
                 s1 = s0;
                 AdpcmMashS(ch, chans, v, iCoef[k], ip, n0, &s1, NULL);
-                st_debug_more(" s32 %d\n",s1);
+                sox_debug_more(" s32 %d\n",s1);
                 ss = s1 = (3*s0+s1)/4;
                 d1=AdpcmMashS(ch, chans, v, iCoef[k], ip, n, &ss, NULL); /* with step s1 */
                 if (!k || d0<dmin || d1<dmin) {
@@ -293,7 +293,7 @@
                 }
         }
         *st = smin;
-        st_debug_more("kmin %d, smin %5d, ",kmin,smin);
+        sox_debug_more("kmin %d, smin %5d, ",kmin,smin);
         d=AdpcmMashS(ch, chans, v, iCoef[kmin], ip, n, st, obuff);
         obuff[ch] = kmin;
 }
@@ -310,7 +310,7 @@
         int ch;
         unsigned char *p;
 
-        st_debug("AdpcmMashI(chans %d, ip %p, n %d, st %p, obuff %p, bA %d)\n",
+        sox_debug("AdpcmMashI(chans %d, ip %p, n %d, st %p, obuff %p, bA %d)\n",
                                                                  chans, ip, n, st, obuff, blockAlign);
 
         for (p=obuff+7*chans; p<obuff+blockAlign; p++) *p=0;
@@ -327,13 +327,13 @@
  *  samplesPerBlock which would go into a block of size blockAlign
  *  Yes, it is confusing usage.
  */
-st_size_t AdpcmSamplesIn(
-        st_size_t dataLen,
+sox_size_t AdpcmSamplesIn(
+        sox_size_t dataLen,
         unsigned short chans,
         unsigned short blockAlign,
         unsigned short samplesPerBlock
 ){
-        st_size_t m, n;
+        sox_size_t m, n;
 
         if (samplesPerBlock) {
                 n = (dataLen / blockAlign) * samplesPerBlock;
@@ -351,15 +351,15 @@
         return n;
 }
 
-st_size_t AdpcmBytesPerBlock(
+sox_size_t AdpcmBytesPerBlock(
         unsigned short chans,
         unsigned short samplesPerBlock
 )
 {
-        st_size_t n;
+        sox_size_t n;
         n = 7*chans;  /* header */
         if (samplesPerBlock > 2)
-                n += (((st_size_t)samplesPerBlock-2)*chans + 1)/2;
+                n += (((sox_size_t)samplesPerBlock-2)*chans + 1)/2;
         return n;
 }
 
--- a/src/adpcm.h
+++ b/src/adpcm.h
@@ -1,7 +1,7 @@
 /*
  * adpcm.h
  */
-#include "st.h"
+#include "sox.h"
 
 #ifndef SAMPL
 #define SAMPL short
@@ -39,8 +39,8 @@
  *  samplesPerBlock which would go into a block of size blockAlign
  *  Yes, it is confusing usage.
  */
-extern st_size_t AdpcmSamplesIn(
-	st_size_t dataLen,
+extern sox_size_t AdpcmSamplesIn(
+	sox_size_t dataLen,
 	unsigned short chans,
 	unsigned short blockAlign,
 	unsigned short samplesPerBlock
@@ -47,11 +47,11 @@
 );
 
 /*
- * st_size_t AdpcmBytesPerBlock(chans, samplesPerBlock)
+ * sox_size_t AdpcmBytesPerBlock(chans, samplesPerBlock)
  *   return minimum blocksize which would be required
  *   to encode number of chans with given samplesPerBlock
  */
-extern st_size_t AdpcmBytesPerBlock(
+extern sox_size_t AdpcmBytesPerBlock(
 	unsigned short chans,
 	unsigned short samplesPerBlock
 );
--- a/src/adpcms.c
+++ b/src/adpcms.c
@@ -16,7 +16,7 @@
 
 /* ADPCM CODECs: IMA, OKI.   (c) 2007 robs@users.sourceforge.net */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "adpcms.h"
 
 static int const ima_steps[89] = { /* ~16-bit precision */
@@ -82,10 +82,10 @@
  */
 
 /******************************************************************************
- * Function   : st_adpcm_reset
+ * Function   : sox_adpcm_reset
  * Description: Resets the ADPCM codec state.
  * Parameters : state - ADPCM state structure
- *              type - ST_ENCODING_OKI_ADPCM or ST_ENCODING_IMA_ADPCM
+ *              type - SOX_ENCODING_OKI_ADPCM or SOX_ENCODING_IMA_ADPCM
  * Returns    :
  * Exceptions :
  * Notes      : 1. This function is used for framed ADPCM formats to reset
@@ -92,7 +92,7 @@
  *                 the decoder between frames.
  ******************************************************************************/
 
-void st_adpcm_reset(adpcm_io_t state, st_encoding_t type)
+void sox_adpcm_reset(adpcm_io_t state, sox_encoding_t type)
 {
   state->file.count = 0;
   state->file.pos = 0;
@@ -100,7 +100,7 @@
   state->store.byte = 0;
   state->store.flag = 0;
 
-  adpcm_init(&state->encoder, (type == ST_ENCODING_OKI_ADPCM) ? 1 : 0);
+  adpcm_init(&state->encoder, (type == SOX_ENCODING_OKI_ADPCM) ? 1 : 0);
 }
 
 /******************************************************************************
@@ -108,9 +108,9 @@
  * Description: Initialises the file parameters and ADPCM codec state.
  * Parameters : ft  - file info structure
  *              state - ADPCM state structure
- *              type - ST_ENCODING_OKI_ADPCM or ST_ENCODING_IMA_ADPCM
- * Returns    : int - ST_SUCCESS
- *                    ST_EOF
+ *              type - SOX_ENCODING_OKI_ADPCM or SOX_ENCODING_IMA_ADPCM
+ * Returns    : int - SOX_SUCCESS
+ *                    SOX_EOF
  * Exceptions :
  * Notes      : 1. This function can be used as a startread or
  *                 startwrite method.
@@ -120,30 +120,30 @@
  *                 rates but the codecs allows any user specified rate.
  ******************************************************************************/
 
-static int adpcm_start(ft_t ft, adpcm_io_t state, st_encoding_t type)
+static int adpcm_start(ft_t ft, adpcm_io_t state, sox_encoding_t type)
 {
   /* setup file info */
-  state->file.buf = (char *) xmalloc(ST_BUFSIZ);
-  state->file.size = ST_BUFSIZ;
+  state->file.buf = (char *) xmalloc(SOX_BUFSIZ);
+  state->file.size = SOX_BUFSIZ;
   ft->signal.channels = 1;
 
-  st_adpcm_reset(state, type);
+  sox_adpcm_reset(state, type);
   
-  return st_rawstart(ft, st_true, st_false, type, ST_SIZE_16BIT, ST_OPTION_DEFAULT);
+  return sox_rawstart(ft, sox_true, sox_false, type, SOX_SIZE_16BIT, SOX_OPTION_DEFAULT);
 }
 
-int st_adpcm_oki_start(ft_t ft, adpcm_io_t state)
+int sox_adpcm_oki_start(ft_t ft, adpcm_io_t state)
 {
-  return adpcm_start(ft, state, ST_ENCODING_OKI_ADPCM);
+  return adpcm_start(ft, state, SOX_ENCODING_OKI_ADPCM);
 }
 
-int st_adpcm_ima_start(ft_t ft, adpcm_io_t state)
+int sox_adpcm_ima_start(ft_t ft, adpcm_io_t state)
 {
-  return adpcm_start(ft, state, ST_ENCODING_IMA_ADPCM);
+  return adpcm_start(ft, state, SOX_ENCODING_IMA_ADPCM);
 }
 
 /******************************************************************************
- * Function   : st_adpcm_read 
+ * Function   : sox_adpcm_read 
  * Description: Fills an internal buffer from the VOX file, converts the 
  *              OKI ADPCM 4-bit samples to 12-bit signed PCM and then scales 
  *              the samples to full range 16 bit PCM.
@@ -156,17 +156,17 @@
  * Notes      : 
  ******************************************************************************/
 
-st_size_t st_adpcm_read(ft_t ft, adpcm_io_t state, st_sample_t * buffer, st_size_t len)
+sox_size_t sox_adpcm_read(ft_t ft, adpcm_io_t state, sox_sample_t * buffer, sox_size_t len)
 {
-  st_size_t n;
+  sox_size_t n;
   uint8_t byte;
 
-  for (n = 0; n < (len&~1) && st_readb(ft, &byte) == ST_SUCCESS; n += 2) {
+  for (n = 0; n < (len&~1) && sox_readb(ft, &byte) == SOX_SUCCESS; n += 2) {
     short word = adpcm_decode(byte >> 4, &state->encoder);
-    *buffer++ = ST_SIGNED_WORD_TO_SAMPLE(word, ft->clips);
+    *buffer++ = SOX_SIGNED_WORD_TO_SAMPLE(word, ft->clips);
 
     word = adpcm_decode(byte, &state->encoder);
-    *buffer++ = ST_SIGNED_WORD_TO_SAMPLE(word, ft->clips);
+    *buffer++ = SOX_SIGNED_WORD_TO_SAMPLE(word, ft->clips);
   }
   return n;
 }
@@ -176,16 +176,16 @@
  * Description: Frees the internal buffer allocated in voxstart/imastart.
  * Parameters : ft   - file info structure
  *              state  - ADPCM state structure
- * Returns    : int  - ST_SUCCESS
+ * Returns    : int  - SOX_SUCCESS
  * Exceptions :
  * Notes      : 
  ******************************************************************************/
 
-int st_adpcm_stopread(ft_t ft UNUSED, adpcm_io_t state)
+int sox_adpcm_stopread(ft_t ft UNUSED, adpcm_io_t state)
 {
   free(state->file.buf);
 
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 
@@ -197,21 +197,21 @@
  *              state  - ADPCM state structure
  *              buffer - output buffer
  *              length - size of output buffer
- * Returns    : int    - ST_SUCCESS
- *                       ST_EOF
+ * Returns    : int    - SOX_SUCCESS
+ *                       SOX_EOF
  * Exceptions :
  * Notes      : 
  ******************************************************************************/
 
-st_size_t st_adpcm_write(ft_t ft, adpcm_io_t state, const st_sample_t * buffer, st_size_t length)
+sox_size_t sox_adpcm_write(ft_t ft, adpcm_io_t state, const sox_sample_t * buffer, sox_size_t length)
 {
-  st_size_t count = 0;
+  sox_size_t count = 0;
   uint8_t byte = state->store.byte;
   uint8_t flag = state->store.flag;
   short word;
 
   while (count < length) {
-    word = ST_SAMPLE_TO_SIGNED_WORD(*buffer++, ft->clips);
+    word = SOX_SAMPLE_TO_SIGNED_WORD(*buffer++, ft->clips);
 
     byte <<= 4;
     byte |= adpcm_encode(word, &state->encoder) & 0x0F;
@@ -222,7 +222,7 @@
       state->file.buf[state->file.count++] = byte;
 
       if (state->file.count >= state->file.size) {
-        st_writebuf(ft, state->file.buf, 1, state->file.count);
+        sox_writebuf(ft, state->file.buf, 1, state->file.count);
 
         state->file.count = 0;
       }
@@ -240,7 +240,7 @@
 }
 
 /******************************************************************************
- * Function   : st_adpcm_flush
+ * Function   : sox_adpcm_flush
  * Description: Flushes any leftover samples.
  * Parameters : ft   - file info structure
  *              state  - ADPCM state structure
@@ -249,7 +249,7 @@
  * Notes      : 1. Called directly for writing framed formats
  ******************************************************************************/
 
-void st_adpcm_flush(ft_t ft, adpcm_io_t state)
+void sox_adpcm_flush(ft_t ft, adpcm_io_t state)
 {
   uint8_t byte = state->store.byte;
   uint8_t flag = state->store.flag;
@@ -264,25 +264,25 @@
   }
 
   if (state->file.count > 0)
-    st_writebuf(ft, state->file.buf, 1, state->file.count);
+    sox_writebuf(ft, state->file.buf, 1, state->file.count);
 }
 
 /******************************************************************************
- * Function   : st_adpcm_stopwrite
+ * Function   : sox_adpcm_stopwrite
  * Description: Flushes any leftover samples and frees the internal buffer 
  *              allocated in voxstart/imastart.
  * Parameters : ft   - file info structure
  *              state  - ADPCM state structure
- * Returns    : int  - ST_SUCCESS
+ * Returns    : int  - SOX_SUCCESS
  * Exceptions :
  * Notes      : 
  ******************************************************************************/
 
-int st_adpcm_stopwrite(ft_t ft, adpcm_io_t state)
+int sox_adpcm_stopwrite(ft_t ft, adpcm_io_t state)
 {
-  st_adpcm_flush(ft, state);
+  sox_adpcm_flush(ft, state);
 
   free(state->file.buf);
 
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
--- a/src/adpcms.h
+++ b/src/adpcms.h
@@ -31,15 +31,15 @@
     uint8_t byte;               /* write store */
     uint8_t flag;
   } store;
-  st_fileinfo_t file;
+  sox_fileinfo_t file;
 } *adpcm_io_t;
 
 /* Format methods */
-void st_adpcm_reset(adpcm_io_t state, st_encoding_t type);
-int st_adpcm_oki_start(ft_t ft, adpcm_io_t state);
-int st_adpcm_ima_start(ft_t ft, adpcm_io_t state);
-st_size_t st_adpcm_read(ft_t ft, adpcm_io_t state, st_sample_t *buffer, st_size_t len);
-int st_adpcm_stopread(ft_t ft, adpcm_io_t state);
-st_size_t st_adpcm_write(ft_t ft, adpcm_io_t state, const st_sample_t *buffer, st_size_t length);
-void st_adpcm_flush(ft_t ft, adpcm_io_t state);
-int st_adpcm_stopwrite(ft_t ft, adpcm_io_t state);
+void sox_adpcm_reset(adpcm_io_t state, sox_encoding_t type);
+int sox_adpcm_oki_start(ft_t ft, adpcm_io_t state);
+int sox_adpcm_ima_start(ft_t ft, adpcm_io_t state);
+sox_size_t sox_adpcm_read(ft_t ft, adpcm_io_t state, sox_sample_t *buffer, sox_size_t len);
+int sox_adpcm_stopread(ft_t ft, adpcm_io_t state);
+sox_size_t sox_adpcm_write(ft_t ft, adpcm_io_t state, const sox_sample_t *buffer, sox_size_t length);
+void sox_adpcm_flush(ft_t ft, adpcm_io_t state);
+int sox_adpcm_stopwrite(ft_t ft, adpcm_io_t state);
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -15,7 +15,7 @@
  * the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <math.h>
 #include <time.h>      /* for time stamping comments */
@@ -29,15 +29,15 @@
 
 /* Private data used by writer */
 typedef struct aiffpriv {
-    st_size_t nsamples;  /* number of 1-channel samples read or written */
+    sox_size_t nsamples;  /* number of 1-channel samples read or written */
                          /* Decrements for read increments for write */
-    st_size_t dataStart; /* need to for seeking */
+    sox_size_t dataStart; /* need to for seeking */
 } *aiff_t;
 
 /* forward declarations */
 static double read_ieee_extended(ft_t);
-static int aiffwriteheader(ft_t, st_size_t);
-static int aifcwriteheader(ft_t, st_size_t);
+static int aiffwriteheader(ft_t, sox_size_t);
+static int aifcwriteheader(ft_t, sox_size_t);
 static void write_ieee_extended(ft_t, double);
 static double ConvertFromIeeeExtended(unsigned char*);
 static void ConvertToIeeeExtended(double, char *);
@@ -45,10 +45,10 @@
 static int commentChunk(char **text, char *chunkDescription, ft_t ft);
 static void reportInstrument(ft_t ft);
 
-static int st_aiffseek(ft_t ft, st_size_t offset) 
+static int sox_aiffseek(ft_t ft, sox_size_t offset) 
 {
     aiff_t aiff = (aiff_t ) ft->priv;
-    st_size_t new_offset, channel_block, alignment;
+    sox_size_t new_offset, channel_block, alignment;
 
     new_offset = offset * ft->signal.size;
     /* Make sure request aligns to a channel block (ie left+right) */
@@ -62,15 +62,15 @@
         new_offset += (channel_block - alignment);
     new_offset += aiff->dataStart;
 
-    ft->st_errno = st_seeki(ft, new_offset, SEEK_SET);
+    ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
 
-    if (ft->st_errno == ST_SUCCESS)
+    if (ft->sox_errno == SOX_SUCCESS)
         aiff->nsamples = ft->length - (new_offset / ft->signal.size);
 
-    return(ft->st_errno);
+    return(ft->sox_errno);
 }
 
-static int st_aiffstartread(ft_t ft) 
+static int sox_aiffstartread(ft_t ft) 
 {
         aiff_t aiff = (aiff_t ) ft->priv;
         char buf[5];
@@ -93,7 +93,7 @@
         unsigned short nmarks = 0;
         unsigned short sustainLoopBegin = 0, sustainLoopEnd = 0,
                        releaseLoopBegin = 0, releaseLoopEnd = 0;
-        st_size_t seekto = 0, ssndsize = 0;
+        sox_size_t seekto = 0, ssndsize = 0;
         char *author;
         char *copyright;
         char *nametext;
@@ -105,17 +105,17 @@
         int rc;
 
         /* FORM chunk */
-        if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "FORM", 4) != 0)
+        if (sox_reads(ft, buf, 4) == SOX_EOF || strncmp(buf, "FORM", 4) != 0)
         {
-                st_fail_errno(ft,ST_EHDR,"AIFF header does not begin with magic word 'FORM'");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"AIFF header does not begin with magic word 'FORM'");
+                return(SOX_EOF);
         }
-        st_readdw(ft, &totalsize);
-        if (st_reads(ft, buf, 4) == ST_EOF || (strncmp(buf, "AIFF", 4) != 0 && 
+        sox_readdw(ft, &totalsize);
+        if (sox_reads(ft, buf, 4) == SOX_EOF || (strncmp(buf, "AIFF", 4) != 0 && 
             strncmp(buf, "AIFC", 4) != 0))
         {
-                st_fail_errno(ft,ST_EHDR,"AIFF 'FORM' chunk does not specify 'AIFF' or 'AIFC' as type");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"AIFF 'FORM' chunk does not specify 'AIFF' or 'AIFC' as type");
+                return(SOX_EOF);
         }
 
         
@@ -122,7 +122,7 @@
         /* Skip everything but the COMM chunk and the SSND chunk */
         /* The SSND chunk must be the last in the file */
         while (1) {
-                if (st_reads(ft, buf, 4) == ST_EOF)
+                if (sox_reads(ft, buf, 4) == SOX_EOF)
                 {
                         if (ssndsize > 0)
                         {
@@ -130,21 +130,21 @@
                         }
                         else
                         {
-                                st_fail_errno(ft,ST_EHDR,"Missing SSND chunk in AIFF file");
-                                return(ST_EOF);
+                                sox_fail_errno(ft,SOX_EHDR,"Missing SSND chunk in AIFF file");
+                                return(SOX_EOF);
                         }
                 }
                 if (strncmp(buf, "COMM", 4) == 0) {
                         /* COMM chunk */
-                        st_readdw(ft, &chunksize);
-                        st_readw(ft, &channels);
-                        st_readdw(ft, &frames);
-                        st_readw(ft, &bits);
+                        sox_readdw(ft, &chunksize);
+                        sox_readw(ft, &channels);
+                        sox_readdw(ft, &frames);
+                        sox_readw(ft, &bits);
                         rate = read_ieee_extended(ft);
                         chunksize -= 18;
                         if (chunksize > 0)
                         {
-                            st_reads(ft, buf, 4);
+                            sox_reads(ft, buf, 4);
                             chunksize -= 4;
                             if (strncmp(buf, "sowt", 4) == 0)
                             {
@@ -155,19 +155,19 @@
                             else if (strncmp(buf, "NONE", 4) != 0)
                             {
                                 buf[4] = 0;
-                                st_fail_errno(ft,ST_EHDR,"AIFC files that contain compressed data are not supported: %s",buf);
-                                return(ST_EOF);
+                                sox_fail_errno(ft,SOX_EHDR,"AIFC files that contain compressed data are not supported: %s",buf);
+                                return(SOX_EOF);
                             }
                         }
                         while(chunksize-- > 0)
-                            st_readb(ft, (unsigned char *)&trash8);
+                            sox_readb(ft, (unsigned char *)&trash8);
                         foundcomm = 1;
                 }
                 else if (strncmp(buf, "SSND", 4) == 0) {
                         /* SSND chunk */
-                        st_readdw(ft, &chunksize);
-                        st_readdw(ft, &offset);
-                        st_readdw(ft, &blocksize);
+                        sox_readdw(ft, &chunksize);
+                        sox_readdw(ft, &offset);
+                        sox_readdw(ft, &blocksize);
                         chunksize -= 8;
                         ssndsize = chunksize;
                         /* word-align chunksize in case it wasn't
@@ -178,13 +178,13 @@
                         if (!ft->seekable)
                                 break;
                         /* else, seek to end of sound and hunt for more */
-                        seekto = st_tell(ft);
-                        st_seeki(ft, chunksize, SEEK_CUR); 
+                        seekto = sox_tell(ft);
+                        sox_seeki(ft, chunksize, SEEK_CUR); 
                 }
                 else if (strncmp(buf, "MARK", 4) == 0) {
                         /* MARK chunk */
-                        st_readdw(ft, &chunksize);
-                        st_readw(ft, &nmarks);
+                        sox_readdw(ft, &chunksize);
+                        sox_readw(ft, &nmarks);
 
                         /* Some programs like to always have a MARK chunk
                          * but will set number of marks to 0 and force
@@ -206,14 +206,14 @@
 
                                 if (chunksize < 6)
                                     break;
-                                st_readw(ft, &(marks[i].id));
-                                st_readdw(ft, &(marks[i].position));
+                                sox_readw(ft, &(marks[i].id));
+                                sox_readdw(ft, &(marks[i].position));
                                 chunksize -= 6;
                                 /* If error reading length then
                                  * don't try to read more bytes
                                  * based on that value.
                                  */
-                                if (st_readb(ft, &len) != ST_SUCCESS)
+                                if (sox_readb(ft, &len) != SOX_SUCCESS)
                                     break;
                                 --chunksize;
                                 if (len > chunksize)
@@ -223,7 +223,7 @@
                                     read_len = 39;
                                 for(j = 0; j < len && chunksize; j++) 
                                 {
-                                    st_readb(ft, &tmp_c);
+                                    sox_readb(ft, &tmp_c);
                                     if (j < read_len)
                                         marks[i].name[j] = tmp_c;
                                     chunksize--;
@@ -231,7 +231,7 @@
                                 marks[i].name[read_len] = 0;
                                 if ((len & 1) == 0 && chunksize) {
                                         chunksize--;
-                                        st_readb(ft, (unsigned char *)&trash8);
+                                        sox_readb(ft, (unsigned char *)&trash8);
                                 }
                         }
                         /* HA HA!  Sound Designer (and others) makes */
@@ -238,47 +238,47 @@
                         /* bogus files. It spits out bogus chunksize */
                         /* for MARK field */
                         while(chunksize-- > 0)
-                            st_readb(ft, (unsigned char *)&trash8);
+                            sox_readb(ft, (unsigned char *)&trash8);
                 }
                 else if (strncmp(buf, "INST", 4) == 0) {
                         /* INST chunk */
-                        st_readdw(ft, &chunksize);
-                        st_readb(ft, (unsigned char *)&(ft->instr.MIDInote));
-                        st_readb(ft, (unsigned char *)&trash8);
-                        st_readb(ft, (unsigned char *)&(ft->instr.MIDIlow));
-                        st_readb(ft, (unsigned char *)&(ft->instr.MIDIhi));
+                        sox_readdw(ft, &chunksize);
+                        sox_readb(ft, (unsigned char *)&(ft->instr.MIDInote));
+                        sox_readb(ft, (unsigned char *)&trash8);
+                        sox_readb(ft, (unsigned char *)&(ft->instr.MIDIlow));
+                        sox_readb(ft, (unsigned char *)&(ft->instr.MIDIhi));
                         /* Low  velocity */
-                        st_readb(ft, (unsigned char *)&trash8);
+                        sox_readb(ft, (unsigned char *)&trash8);
                         /* Hi  velocity */
-                        st_readb(ft, (unsigned char *)&trash8);
-                        st_readw(ft, (unsigned short *)&trash16);/* gain */
-                        st_readw(ft, &looptype); /* sustain loop */
+                        sox_readb(ft, (unsigned char *)&trash8);
+                        sox_readw(ft, (unsigned short *)&trash16);/* gain */
+                        sox_readw(ft, &looptype); /* sustain loop */
                         ft->loops[0].type = looptype;
-                        st_readw(ft, &sustainLoopBegin); /* begin marker */
-                        st_readw(ft, &sustainLoopEnd);    /* end marker */
-                        st_readw(ft, &looptype); /* release loop */
+                        sox_readw(ft, &sustainLoopBegin); /* begin marker */
+                        sox_readw(ft, &sustainLoopEnd);    /* end marker */
+                        sox_readw(ft, &looptype); /* release loop */
                         ft->loops[1].type = looptype;
-                        st_readw(ft, &releaseLoopBegin);  /* begin marker */
-                        st_readw(ft, &releaseLoopEnd);    /* end marker */
+                        sox_readw(ft, &releaseLoopBegin);  /* begin marker */
+                        sox_readw(ft, &releaseLoopEnd);    /* end marker */
 
                         foundinstr = 1;
                 }
                 else if (strncmp(buf, "APPL", 4) == 0) {
-                        st_readdw(ft, &chunksize);
+                        sox_readdw(ft, &chunksize);
                         /* word-align chunksize in case it wasn't
                          * done by writing application already.
                          */
                         chunksize += (chunksize % 2);
                         while(chunksize-- > 0)
-                            st_readb(ft, (unsigned char *)&trash8);
+                            sox_readb(ft, (unsigned char *)&trash8);
                 }
                 else if (strncmp(buf, "ALCH", 4) == 0) {
                         /* I think this is bogus and gets grabbed by APPL */
                         /* INST chunk */
-                        st_readdw(ft, &trash32);                /* ENVS - jeez! */
-                        st_readdw(ft, &chunksize);
+                        sox_readdw(ft, &trash32);                /* ENVS - jeez! */
+                        sox_readdw(ft, &chunksize);
                         while(chunksize-- > 0)
-                            st_readb(ft, (unsigned char *)&trash8);
+                            sox_readb(ft, (unsigned char *)&trash8);
                 }
                 else if (strncmp(buf, "ANNO", 4) == 0) {
                         rc = textChunk(&(ft->comment), "Annotation:", ft);
@@ -285,7 +285,7 @@
                         if (rc)
                         {
                           /* Fail already called in function */
-                          return(ST_EOF);
+                          return(SOX_EOF);
                         }
                 }
                 else if (strncmp(buf, "COMT", 4) == 0) {
@@ -292,7 +292,7 @@
                   rc = commentChunk(&(ft->comment), "Comment:", ft);
                   if (rc) {
                     /* Fail already called in function */
-                    return(ST_EOF);
+                    return(SOX_EOF);
                   }
                 }
                 else if (strncmp(buf, "AUTH", 4) == 0) {
@@ -301,7 +301,7 @@
                   if (rc)
                   {
                       /* Fail already called in function */
-                      return(ST_EOF);
+                      return(SOX_EOF);
                   }
                   free(author);
                 }
@@ -311,7 +311,7 @@
                   if (rc)
                   {
                       /* Fail already called in function */
-                      return(ST_EOF);
+                      return(SOX_EOF);
                   }
                   free(nametext);
                 }
@@ -321,26 +321,26 @@
                   if (rc)
                   {
                       /* Fail already called in function */
-                      return(ST_EOF);
+                      return(SOX_EOF);
                   }
                   free(copyright);
                 }
                 else {
-                        if (st_eof(ft))
+                        if (sox_eof(ft))
                                 break;
                         buf[4] = 0;
-                        st_debug("AIFFstartread: ignoring '%s' chunk", buf);
-                        st_readdw(ft, &chunksize);
-                        if (st_eof(ft))
+                        sox_debug("AIFFstartread: ignoring '%s' chunk", buf);
+                        sox_readdw(ft, &chunksize);
+                        if (sox_eof(ft))
                                 break;
-                        /* Skip the chunk using st_readb() so we may read
+                        /* Skip the chunk using sox_readb() so we may read
                            from a pipe */
                         while (chunksize-- > 0) {
-                            if (st_readb(ft, (unsigned char *)&trash8) == ST_EOF)
+                            if (sox_readb(ft, (unsigned char *)&trash8) == SOX_EOF)
                                         break;
                         }
                 }
-                if (st_eof(ft))
+                if (sox_eof(ft))
                         break;
         }
 
@@ -351,22 +351,22 @@
         if (ft->seekable)
         {
                 if (seekto > 0)
-                        st_seeki(ft, seekto, SEEK_SET);
+                        sox_seeki(ft, seekto, SEEK_SET);
                 else
                 {
-                        st_fail_errno(ft,ST_EOF,"AIFF: no sound data on input file");
-                        return(ST_EOF);
+                        sox_fail_errno(ft,SOX_EOF,"AIFF: no sound data on input file");
+                        return(SOX_EOF);
                 }
         }
         /* SSND chunk just read */
         if (blocksize != 0)
-            st_warn("AIFF header has invalid blocksize.  Ignoring but expect a premature EOF");
+            sox_warn("AIFF header has invalid blocksize.  Ignoring but expect a premature EOF");
 
         while (offset-- > 0) {
-                if (st_readb(ft, (unsigned char *)&trash8) == ST_EOF)
+                if (sox_readb(ft, (unsigned char *)&trash8) == SOX_EOF)
                 {
-                        st_fail_errno(ft,errno,"unexpected EOF while skipping AIFF offset");
-                        return(ST_EOF);
+                        sox_fail_errno(ft,errno,"unexpected EOF while skipping AIFF offset");
+                        return(SOX_EOF);
                 }
         }
 
@@ -373,47 +373,47 @@
         if (foundcomm) {
                 ft->signal.channels = channels;
                 ft->signal.rate = rate;
-                if (ft->signal.encoding != ST_ENCODING_UNKNOWN && ft->signal.encoding != ST_ENCODING_SIGN2)
-                    st_report("AIFF only supports signed data.  Forcing to signed.");
-                ft->signal.encoding = ST_ENCODING_SIGN2;
+                if (ft->signal.encoding != SOX_ENCODING_UNKNOWN && ft->signal.encoding != SOX_ENCODING_SIGN2)
+                    sox_report("AIFF only supports signed data.  Forcing to signed.");
+                ft->signal.encoding = SOX_ENCODING_SIGN2;
                 if (bits <= 8)
                 {
-                    ft->signal.size = ST_SIZE_BYTE;
+                    ft->signal.size = SOX_SIZE_BYTE;
                     if (bits < 8)
-                        st_report("Forcing data size from %d bits to 8 bits",bits);
+                        sox_report("Forcing data size from %d bits to 8 bits",bits);
                 }
                 else if (bits <= 16)
                 {
-                    ft->signal.size = ST_SIZE_16BIT;
+                    ft->signal.size = SOX_SIZE_16BIT;
                     if (bits < 16)
-                        st_report("Forcing data size from %d bits to 16 bits",bits);
+                        sox_report("Forcing data size from %d bits to 16 bits",bits);
                 }
                 else if (bits <= 24)
                 {
-                    ft->signal.size = ST_SIZE_24BIT;
+                    ft->signal.size = SOX_SIZE_24BIT;
                     if (bits < 24)
-                        st_report("Forcing data size from %d bits to 24 bits",bits);
+                        sox_report("Forcing data size from %d bits to 24 bits",bits);
                 }
                 else if (bits <= 32)
                 {
-                    ft->signal.size = ST_SIZE_32BIT;
+                    ft->signal.size = SOX_SIZE_32BIT;
                     if (bits < 32)
-                        st_report("Forcing data size from %d bits to 32 bits",bits);
+                        sox_report("Forcing data size from %d bits to 32 bits",bits);
                 }
                 else
                 {
-                    st_fail_errno(ft,ST_EFMT,"unsupported sample size in AIFF header: %d", bits);
-                    return(ST_EOF);
+                    sox_fail_errno(ft,SOX_EFMT,"unsupported sample size in AIFF header: %d", bits);
+                    return(SOX_EOF);
                 }
         } else  {
                 if ((ft->signal.channels == 0)
                         || (ft->signal.rate == 0)
-                        || (ft->signal.encoding == ST_ENCODING_UNKNOWN)
+                        || (ft->signal.encoding == SOX_ENCODING_UNKNOWN)
                         || (ft->signal.size == -1)) {
-                  st_report("You must specify # channels, sample rate, signed/unsigned,");
-                  st_report("and 8/16 on the command line.");
-                  st_fail_errno(ft,ST_EFMT,"Bogus AIFF file: no COMM section.");
-                  return(ST_EOF);
+                  sox_report("You must specify # channels, sample rate, signed/unsigned,");
+                  sox_report("and 8/16 on the command line.");
+                  sox_fail_errno(ft,SOX_EFMT,"Bogus AIFF file: no COMM section.");
+                  return(SOX_EOF);
                 }
 
         }
@@ -429,12 +429,12 @@
         
         if (foundmark && !foundinstr)
         {
-            st_debug("Ignoring MARK chunk since no INSTR found.");
+            sox_debug("Ignoring MARK chunk since no INSTR found.");
             foundmark = 0;
         }
         if (!foundmark && foundinstr)
         {
-            st_debug("Ignoring INSTR chunk since no MARK found.");
+            sox_debug("Ignoring INSTR chunk since no MARK found.");
             foundinstr = 0;
         }
         if (foundmark && foundinstr) {
@@ -461,7 +461,7 @@
                             marks[sleIndex].position - marks[slbIndex].position;
                         /* really the loop count should be infinite */
                         ft->loops[0].count = 1; 
-                        ft->instr.loopmode = ST_LOOP_SUSTAIN_DECAY | ft->loops[0].type;
+                        ft->instr.loopmode = SOX_LOOP_SUSTAIN_DECAY | ft->loops[0].type;
                         ft->instr.nloops++;
                 }
                 if (ft->loops[1].type != 0) {
@@ -470,21 +470,21 @@
                             marks[rleIndex].position - marks[rlbIndex].position;
                         /* really the loop count should be infinite */
                         ft->loops[1].count = 1;
-                        ft->instr.loopmode = ST_LOOP_SUSTAIN_DECAY | ft->loops[1].type;
+                        ft->instr.loopmode = SOX_LOOP_SUSTAIN_DECAY | ft->loops[1].type;
                         ft->instr.nloops++;
                 } 
         }
         reportInstrument(ft);
 
-        /* Needed because of st_rawread() */
-        rc = st_rawstartread(ft);
+        /* Needed because of sox_rawread() */
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
         ft->length = aiff->nsamples;    /* for seeking */
-        aiff->dataStart = st_tell(ft);
+        aiff->dataStart = sox_tell(ft);
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* print out the MIDI key allocations, loop points, directions etc */
@@ -493,24 +493,24 @@
   int loopNum;
 
   if(ft->instr.nloops > 0)
-    st_report("AIFF Loop markers:");
+    sox_report("AIFF Loop markers:");
   for(loopNum  = 0; loopNum < ft->instr.nloops; loopNum++) {
     if (ft->loops[loopNum].count) {
-      st_report("Loop %d: start: %6d", loopNum, ft->loops[loopNum].start);
-      st_report(" end:   %6d", 
+      sox_report("Loop %d: start: %6d", loopNum, ft->loops[loopNum].start);
+      sox_report(" end:   %6d", 
               ft->loops[loopNum].start + ft->loops[loopNum].length);
-      st_report(" count: %6d", ft->loops[loopNum].count);
-      st_report(" type:  ");
-      switch(ft->loops[loopNum].type & ~ST_LOOP_SUSTAIN_DECAY) {
-      case 0: st_report("off"); break;
-      case 1: st_report("forward"); break;
-      case 2: st_report("forward/backward"); break;
+      sox_report(" count: %6d", ft->loops[loopNum].count);
+      sox_report(" type:  ");
+      switch(ft->loops[loopNum].type & ~SOX_LOOP_SUSTAIN_DECAY) {
+      case 0: sox_report("off"); break;
+      case 1: sox_report("forward"); break;
+      case 2: sox_report("forward/backward"); break;
       }
     }
   }
-  st_report("Unity MIDI Note: %d", ft->instr.MIDInote);
-  st_report("Low   MIDI Note: %d", ft->instr.MIDIlow);
-  st_report("High  MIDI Note: %d", ft->instr.MIDIhi);
+  sox_report("Unity MIDI Note: %d", ft->instr.MIDInote);
+  sox_report("Low   MIDI Note: %d", ft->instr.MIDIlow);
+  sox_report("High  MIDI Note: %d", ft->instr.MIDIhi);
 }
 
 /* Process a text chunk, allocate memory, display it if verbose and return */
@@ -517,13 +517,13 @@
 static int textChunk(char **text, char *chunkDescription, ft_t ft) 
 {
   uint32_t chunksize;
-  st_readdw(ft, &chunksize);
+  sox_readdw(ft, &chunksize);
   /* allocate enough memory to hold the text including a terminating \0 */
   *text = (char *) xmalloc((size_t) chunksize + 1);
-  if (st_readbuf(ft, *text, 1, chunksize) != chunksize)
+  if (sox_readbuf(ft, *text, 1, chunksize) != chunksize)
   {
-    st_fail_errno(ft,ST_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
-    return(ST_EOF);
+    sox_fail_errno(ft,SOX_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
+    return(SOX_EOF);
   }
   *(*text + chunksize) = '\0';
         if (chunksize % 2)
@@ -530,14 +530,14 @@
         {
                 /* Read past pad byte */
                 char c;
-                if (st_readbuf(ft, &c, 1, 1) != 1)
+                if (sox_readbuf(ft, &c, 1, 1) != 1)
                 {
-                st_fail_errno(ft,ST_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
-                        return(ST_EOF);
+                sox_fail_errno(ft,SOX_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
+                        return(SOX_EOF);
                 }
         }
-  st_debug("%-10s   \"%s\"", chunkDescription, *text);
-  return(ST_SUCCESS);
+  sox_debug("%-10s   \"%s\"", chunkDescription, *text);
+  return(SOX_SUCCESS);
 }
 
 /* Comment lengths are words, not double words, and we can have several, so
@@ -553,15 +553,15 @@
   unsigned int totalReadLength = 0;
   unsigned int commentIndex;
 
-  st_readdw(ft, &chunksize);
-  st_readw(ft, &numComments);
+  sox_readdw(ft, &chunksize);
+  sox_readw(ft, &numComments);
   totalReadLength += 2; /* chunksize doesn't count */
   for(commentIndex = 0; commentIndex < numComments; commentIndex++) {
     unsigned short commentLength;
 
-    st_readdw(ft, &timeStamp);
-    st_readw(ft, &markerId);
-    st_readw(ft, &commentLength);
+    sox_readdw(ft, &timeStamp);
+    sox_readw(ft, &markerId);
+    sox_readw(ft, &commentLength);
     totalCommentLength += commentLength;
     /* allocate enough memory to hold the text including a terminating \0 */
     if(commentIndex == 0) {
@@ -571,9 +571,9 @@
       *text = xrealloc(*text, (size_t) totalCommentLength + 1);
     }
 
-    if (st_readbuf(ft, *text + totalCommentLength - commentLength, 1, commentLength) != commentLength) {
-        st_fail_errno(ft,ST_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
-        return(ST_EOF);
+    if (sox_readbuf(ft, *text + totalCommentLength - commentLength, 1, commentLength) != commentLength) {
+        sox_fail_errno(ft,SOX_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
+        return(SOX_EOF);
     }
     *(*text + totalCommentLength) = '\0';
     totalReadLength += totalCommentLength + 4 + 2 + 2; /* include header */
@@ -580,39 +580,39 @@
     if (commentLength % 2) {
         /* Read past pad byte */
         char c;
-        if (st_readbuf(ft, &c, 1, 1) != 1) {
-            st_fail_errno(ft,ST_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
-            return(ST_EOF);
+        if (sox_readbuf(ft, &c, 1, 1) != 1) {
+            sox_fail_errno(ft,SOX_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
+            return(SOX_EOF);
         }
     }
   }
-  st_debug("%-10s   \"%s\"", chunkDescription, *text);
+  sox_debug("%-10s   \"%s\"", chunkDescription, *text);
   /* make sure we read the whole chunk */
   if (totalReadLength < chunksize) {
        size_t i;
        char c;
        for (i=0; i < chunksize - totalReadLength; i++ ) {
-               st_readbuf(ft, &c, 1, 1);
+               sox_readbuf(ft, &c, 1, 1);
        }
   }
-  return(ST_SUCCESS);
+  return(SOX_SUCCESS);
 }
 
-static st_size_t st_aiffread(ft_t ft, st_sample_t *buf, st_size_t len)
+static sox_size_t sox_aiffread(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
         aiff_t aiff = (aiff_t ) ft->priv;
-        st_ssize_t done;
+        sox_ssize_t done;
 
-        if ((st_size_t)len > aiff->nsamples)
+        if ((sox_size_t)len > aiff->nsamples)
                 len = aiff->nsamples;
-        done = st_rawread(ft, buf, len);
+        done = sox_rawread(ft, buf, len);
         if (done == 0 && aiff->nsamples != 0)
-                st_warn("Premature EOF on AIFF input file");
+                sox_warn("Premature EOF on AIFF input file");
         aiff->nsamples -= done;
         return done;
 }
 
-static int st_aiffstopread(ft_t ft) 
+static int sox_aiffstopread(ft_t ft) 
 {
         char buf[5];
         uint32_t chunksize;
@@ -620,29 +620,29 @@
 
         if (!ft->seekable)
         {
-            while (! st_eof(ft)) 
+            while (! sox_eof(ft)) 
             {
-                if (st_readbuf(ft, buf, 1, 4) != 4)
+                if (sox_readbuf(ft, buf, 1, 4) != 4)
                         break;
 
-                st_readdw(ft, &chunksize);
-                if (st_eof(ft))
+                sox_readdw(ft, &chunksize);
+                if (sox_eof(ft))
                         break;
                 buf[4] = '\0';
-                st_warn("Ignoring AIFF tail chunk: '%s', %d bytes long", 
+                sox_warn("Ignoring AIFF tail chunk: '%s', %d bytes long", 
                         buf, chunksize);
                 if (! strcmp(buf, "MARK") || ! strcmp(buf, "INST"))
-                        st_warn("       You're stripping MIDI/loop info!");
+                        sox_warn("       You're stripping MIDI/loop info!");
                 while (chunksize-- > 0) 
                 {
-                        if (st_readb(ft, (unsigned char *)&trash) == ST_EOF)
+                        if (sox_readb(ft, (unsigned char *)&trash) == SOX_EOF)
                                 break;
                 }
             }
         }
 
-        /* Needed because of st_rawwrite() */
-        return st_rawstopread(ft);
+        /* Needed because of sox_rawwrite() */
+        return sox_rawstopread(ft);
 }
 
 /* When writing, the header is supposed to contain the number of
@@ -655,26 +655,26 @@
    Strictly spoken this is not legal, but the playaiff utility
    will still be able to play the resulting file. */
 
-static int st_aiffstartwrite(ft_t ft)
+static int sox_aiffstartwrite(ft_t ft)
 {
         aiff_t aiff = (aiff_t ) ft->priv;
         int rc;
 
-        /* Needed because st_rawwrite() */
-        rc = st_rawstartwrite(ft);
+        /* Needed because sox_rawwrite() */
+        rc = sox_rawstartwrite(ft);
         if (rc)
             return rc;
 
         aiff->nsamples = 0;
-        if (ft->signal.encoding < ST_ENCODING_SIZE_IS_WORD && 
-            ft->signal.size == ST_SIZE_BYTE) {
-                st_report("expanding compressed bytes to signed 16 bits");
-                ft->signal.encoding = ST_ENCODING_SIGN2;
-                ft->signal.size = ST_SIZE_16BIT;
+        if (ft->signal.encoding < SOX_ENCODING_SIZE_IS_WORD && 
+            ft->signal.size == SOX_SIZE_BYTE) {
+                sox_report("expanding compressed bytes to signed 16 bits");
+                ft->signal.encoding = SOX_ENCODING_SIGN2;
+                ft->signal.size = SOX_SIZE_16BIT;
         }
-        if (ft->signal.encoding != ST_ENCODING_UNKNOWN && ft->signal.encoding != ST_ENCODING_SIGN2)
-            st_report("AIFF only supports signed data.  Forcing to signed.");
-        ft->signal.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */
+        if (ft->signal.encoding != SOX_ENCODING_UNKNOWN && ft->signal.encoding != SOX_ENCODING_SIGN2)
+            sox_report("AIFF only supports signed data.  Forcing to signed.");
+        ft->signal.encoding = SOX_ENCODING_SIGN2; /* We have a fixed encoding */
 
         /* Compute the "very large number" so that a maximum number
            of samples can be transmitted through a pipe without the
@@ -685,15 +685,15 @@
         return(aiffwriteheader(ft, 0x7f000000 / (ft->signal.size*ft->signal.channels)));
 }
 
-static st_size_t st_aiffwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static sox_size_t sox_aiffwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
         aiff_t aiff = (aiff_t ) ft->priv;
         aiff->nsamples += len;
-        st_rawwrite(ft, buf, len);
+        sox_rawwrite(ft, buf, len);
         return(len);
 }
 
-static int st_aiffstopwrite(ft_t ft)
+static int sox_aiffstopwrite(ft_t ft)
 {
         aiff_t aiff = (aiff_t ) ft->priv;
         int rc;
@@ -702,31 +702,31 @@
            NUL */
         if (aiff->nsamples % 2 == 1 && ft->signal.size == 1 && ft->signal.channels == 1)
         {
-            st_sample_t buf = 0;
-            st_rawwrite(ft, &buf, 1);
+            sox_sample_t buf = 0;
+            sox_rawwrite(ft, &buf, 1);
         }
 
-        /* Needed because of st_rawwrite().  Call now to flush
+        /* Needed because of sox_rawwrite().  Call now to flush
          * buffer now before seeking around below.
          */
-        rc = st_rawstopwrite(ft);
+        rc = sox_rawstopwrite(ft);
         if (rc)
             return rc;
 
         if (!ft->seekable)
         {
-            st_fail_errno(ft,ST_EOF,"Non-seekable file.");
-            return(ST_EOF);
+            sox_fail_errno(ft,SOX_EOF,"Non-seekable file.");
+            return(SOX_EOF);
         }
-        if (st_seeki(ft, 0, SEEK_SET) != 0)
+        if (sox_seeki(ft, 0, SEEK_SET) != 0)
         {
-                st_fail_errno(ft,errno,"can't rewind output file to rewrite AIFF header");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"can't rewind output file to rewrite AIFF header");
+                return(SOX_EOF);
         }
         return(aiffwriteheader(ft, aiff->nsamples / ft->signal.channels));
 }
 
-static int aiffwriteheader(ft_t ft, st_size_t nframes)
+static int aiffwriteheader(ft_t ft, sox_size_t nframes)
 {
         int hsize =
                 8 /*COMM hdr*/ + 18 /*COMM chunk*/ +
@@ -735,7 +735,7 @@
         int i;
         int padded_comment_size = 0;
         int comment_size = 0;
-        st_size_t comment_chunk_size = 0;
+        sox_size_t comment_chunk_size = 0;
 
         /* MARK and INST chunks */
         if (ft->instr.nloops) {
@@ -743,22 +743,22 @@
           hsize += 8 /* INST hdr */ + 20; /* INST chunk */
         }
 
-        if (ft->signal.encoding == ST_ENCODING_SIGN2 && 
-            ft->signal.size == ST_SIZE_BYTE)
+        if (ft->signal.encoding == SOX_ENCODING_SIGN2 && 
+            ft->signal.size == SOX_SIZE_BYTE)
                 bits = 8;
-        else if (ft->signal.encoding == ST_ENCODING_SIGN2 && 
-                 ft->signal.size == ST_SIZE_16BIT)
+        else if (ft->signal.encoding == SOX_ENCODING_SIGN2 && 
+                 ft->signal.size == SOX_SIZE_16BIT)
                 bits = 16;
-        else if (ft->signal.encoding == ST_ENCODING_SIGN2 && 
-                 ft->signal.size == ST_SIZE_24BIT)
+        else if (ft->signal.encoding == SOX_ENCODING_SIGN2 && 
+                 ft->signal.size == SOX_SIZE_24BIT)
                 bits = 24;
-        else if (ft->signal.encoding == ST_ENCODING_SIGN2 && 
-                 ft->signal.size == ST_SIZE_32BIT)
+        else if (ft->signal.encoding == SOX_ENCODING_SIGN2 && 
+                 ft->signal.size == SOX_SIZE_32BIT)
                 bits = 32;
         else
         {
-                st_fail_errno(ft,ST_EFMT,"unsupported output encoding/size for AIFF header");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EFMT,"unsupported output encoding/size for AIFF header");
+                return(SOX_EOF);
         }
 
         /* COMT comment chunk -- holds comments text with a timestamp and marker id */
@@ -776,118 +776,118 @@
           hsize += 8 /* COMT hdr */ + comment_chunk_size; 
         }
 
-        st_writes(ft, "FORM"); /* IFF header */
+        sox_writes(ft, "FORM"); /* IFF header */
         /* file size */
-        st_writedw(ft, hsize + nframes * ft->signal.size * ft->signal.channels); 
-        st_writes(ft, "AIFF"); /* File type */
+        sox_writedw(ft, hsize + nframes * ft->signal.size * ft->signal.channels); 
+        sox_writes(ft, "AIFF"); /* File type */
 
         /* Now we write the COMT comment chunk using the precomputed sizes */
         if (ft->comment)
         {
-          st_writes(ft, "COMT");
-          st_writedw(ft, comment_chunk_size);
+          sox_writes(ft, "COMT");
+          sox_writedw(ft, comment_chunk_size);
 
           /* one comment */
-          st_writew(ft, 1);
+          sox_writew(ft, 1);
 
           /* time stamp of comment, Unix knows of time from 1/1/1970,
              Apple knows time from 1/1/1904 */
-          st_writedw(ft, ((int32_t) time(NULL)) + 2082844800);
+          sox_writedw(ft, ((int32_t) time(NULL)) + 2082844800);
 
           /* A marker ID of 0 indicates the comment is not associated
              with a marker */
-          st_writew(ft, 0);
+          sox_writew(ft, 0);
 
           /* now write the count and the bytes of text */
-          st_writew(ft, padded_comment_size);
-          st_writes(ft, ft->comment);
+          sox_writew(ft, padded_comment_size);
+          sox_writes(ft, ft->comment);
           if (comment_size != padded_comment_size)
-                st_writes(ft, " ");
+                sox_writes(ft, " ");
         }
 
         /* COMM chunk -- describes encoding (and #frames) */
-        st_writes(ft, "COMM");
-        st_writedw(ft, 18); /* COMM chunk size */
-        st_writew(ft, ft->signal.channels); /* nchannels */
-        st_writedw(ft, nframes); /* number of frames */
-        st_writew(ft, bits); /* sample width, in bits */
+        sox_writes(ft, "COMM");
+        sox_writedw(ft, 18); /* COMM chunk size */
+        sox_writew(ft, ft->signal.channels); /* nchannels */
+        sox_writedw(ft, nframes); /* number of frames */
+        sox_writew(ft, bits); /* sample width, in bits */
         write_ieee_extended(ft, (double)ft->signal.rate);
 
         /* MARK chunk -- set markers */
         if (ft->instr.nloops) {
-                st_writes(ft, "MARK");
+                sox_writes(ft, "MARK");
                 if (ft->instr.nloops > 2)
                         ft->instr.nloops = 2;
-                st_writedw(ft, 2 + 16*ft->instr.nloops);
-                st_writew(ft, ft->instr.nloops);
+                sox_writedw(ft, 2 + 16*ft->instr.nloops);
+                sox_writew(ft, ft->instr.nloops);
 
                 for(i = 0; i < ft->instr.nloops; i++) {
-                        st_writew(ft, i + 1);
-                        st_writedw(ft, ft->loops[i].start);
-                        st_writeb(ft, 0);
-                        st_writeb(ft, 0);
-                        st_writew(ft, i*2 + 1);
-                        st_writedw(ft, ft->loops[i].start + ft->loops[i].length);
-                        st_writeb(ft, 0);
-                        st_writeb(ft, 0);
+                        sox_writew(ft, i + 1);
+                        sox_writedw(ft, ft->loops[i].start);
+                        sox_writeb(ft, 0);
+                        sox_writeb(ft, 0);
+                        sox_writew(ft, i*2 + 1);
+                        sox_writedw(ft, ft->loops[i].start + ft->loops[i].length);
+                        sox_writeb(ft, 0);
+                        sox_writeb(ft, 0);
                 }
 
-                st_writes(ft, "INST");
-                st_writedw(ft, 20);
+                sox_writes(ft, "INST");
+                sox_writedw(ft, 20);
                 /* random MIDI shit that we default on */
-                st_writeb(ft, ft->instr.MIDInote);
-                st_writeb(ft, 0);                       /* detune */
-                st_writeb(ft, ft->instr.MIDIlow);
-                st_writeb(ft, ft->instr.MIDIhi);
-                st_writeb(ft, 1);                       /* low velocity */
-                st_writeb(ft, 127);                     /* hi  velocity */
-                st_writew(ft, 0);                               /* gain */
+                sox_writeb(ft, ft->instr.MIDInote);
+                sox_writeb(ft, 0);                       /* detune */
+                sox_writeb(ft, ft->instr.MIDIlow);
+                sox_writeb(ft, ft->instr.MIDIhi);
+                sox_writeb(ft, 1);                       /* low velocity */
+                sox_writeb(ft, 127);                     /* hi  velocity */
+                sox_writew(ft, 0);                               /* gain */
 
                 /* sustain loop */
-                st_writew(ft, ft->loops[0].type);
-                st_writew(ft, 1);                               /* marker 1 */
-                st_writew(ft, 3);                               /* marker 3 */
+                sox_writew(ft, ft->loops[0].type);
+                sox_writew(ft, 1);                               /* marker 1 */
+                sox_writew(ft, 3);                               /* marker 3 */
                 /* release loop, if there */
                 if (ft->instr.nloops == 2) {
-                        st_writew(ft, ft->loops[1].type);
-                        st_writew(ft, 2);                       /* marker 2 */
-                        st_writew(ft, 4);                       /* marker 4 */
+                        sox_writew(ft, ft->loops[1].type);
+                        sox_writew(ft, 2);                       /* marker 2 */
+                        sox_writew(ft, 4);                       /* marker 4 */
                 } else {
-                        st_writew(ft, 0);                       /* no release loop */
-                        st_writew(ft, 0);
-                        st_writew(ft, 0);
+                        sox_writew(ft, 0);                       /* no release loop */
+                        sox_writew(ft, 0);
+                        sox_writew(ft, 0);
                 }
         }
 
         /* SSND chunk -- describes data */
-        st_writes(ft, "SSND");
+        sox_writes(ft, "SSND");
         /* chunk size */
-        st_writedw(ft, 8 + nframes * ft->signal.channels * ft->signal.size); 
-        st_writedw(ft, 0); /* offset */
-        st_writedw(ft, 0); /* block size */
-        return(ST_SUCCESS);
+        sox_writedw(ft, 8 + nframes * ft->signal.channels * ft->signal.size); 
+        sox_writedw(ft, 0); /* offset */
+        sox_writedw(ft, 0); /* block size */
+        return(SOX_SUCCESS);
 }
 
-static int st_aifcstartwrite(ft_t ft)
+static int sox_aifcstartwrite(ft_t ft)
 {
         aiff_t aiff = (aiff_t ) ft->priv;
         int rc;
 
-        /* Needed because st_rawwrite() */
-        rc = st_rawstartwrite(ft);
+        /* Needed because sox_rawwrite() */
+        rc = sox_rawstartwrite(ft);
         if (rc)
             return rc;
 
         aiff->nsamples = 0;
-        if (ft->signal.encoding < ST_ENCODING_SIZE_IS_WORD && 
-            ft->signal.size == ST_SIZE_BYTE) {
-                st_report("expanding compressed bytes to signed 16 bits");
-                ft->signal.encoding = ST_ENCODING_SIGN2;
-                ft->signal.size = ST_SIZE_16BIT;
+        if (ft->signal.encoding < SOX_ENCODING_SIZE_IS_WORD && 
+            ft->signal.size == SOX_SIZE_BYTE) {
+                sox_report("expanding compressed bytes to signed 16 bits");
+                ft->signal.encoding = SOX_ENCODING_SIGN2;
+                ft->signal.size = SOX_SIZE_16BIT;
         }
-        if (ft->signal.encoding != ST_ENCODING_UNKNOWN && ft->signal.encoding != ST_ENCODING_SIGN2)
-            st_report("AIFC only supports signed data.  Forcing to signed.");
-        ft->signal.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */
+        if (ft->signal.encoding != SOX_ENCODING_UNKNOWN && ft->signal.encoding != SOX_ENCODING_SIGN2)
+            sox_report("AIFC only supports signed data.  Forcing to signed.");
+        ft->signal.encoding = SOX_ENCODING_SIGN2; /* We have a fixed encoding */
 
         /* Compute the "very large number" so that a maximum number
            of samples can be transmitted through a pipe without the
@@ -898,7 +898,7 @@
         return(aifcwriteheader(ft, 0x7f000000 / (ft->signal.size*ft->signal.channels)));
 }
 
-static int st_aifcstopwrite(ft_t ft)
+static int sox_aifcstopwrite(ft_t ft)
 {
         aiff_t aiff = (aiff_t ) ft->priv;
         int rc;
@@ -907,31 +907,31 @@
            NUL */
         if (aiff->nsamples % 2 == 1 && ft->signal.size == 1 && ft->signal.channels == 1)
         {
-            st_sample_t buf = 0;
-            st_rawwrite(ft, &buf, 1);
+            sox_sample_t buf = 0;
+            sox_rawwrite(ft, &buf, 1);
         }
 
-        /* Needed because of st_rawwrite().  Call now to flush
+        /* Needed because of sox_rawwrite().  Call now to flush
          * buffer now before seeking around below.
          */
-        rc = st_rawstopwrite(ft);
+        rc = sox_rawstopwrite(ft);
         if (rc)
             return rc;
 
         if (!ft->seekable)
         {
-            st_fail_errno(ft,ST_EOF,"Non-seekable file.");
-            return(ST_EOF);
+            sox_fail_errno(ft,SOX_EOF,"Non-seekable file.");
+            return(SOX_EOF);
         }
-        if (st_seeki(ft, 0, SEEK_SET) != 0)
+        if (sox_seeki(ft, 0, SEEK_SET) != 0)
         {
-                st_fail_errno(ft,errno,"can't rewind output file to rewrite AIFC header");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"can't rewind output file to rewrite AIFC header");
+                return(SOX_EOF);
         }
         return(aifcwriteheader(ft, aiff->nsamples / ft->signal.channels));
 }
 
-static int aifcwriteheader(ft_t ft, st_size_t nframes)
+static int aifcwriteheader(ft_t ft, sox_size_t nframes)
 {
         int hsize =
                 12 /*FVER*/ + 8 /*COMM hdr*/ + 18+4+1+15 /*COMM chunk*/ +
@@ -938,65 +938,65 @@
                 8 /*SSND hdr*/ + 12 /*SSND chunk*/;
         int bits = 0;
 
-        if (ft->signal.encoding == ST_ENCODING_SIGN2 && 
-            ft->signal.size == ST_SIZE_BYTE)
+        if (ft->signal.encoding == SOX_ENCODING_SIGN2 && 
+            ft->signal.size == SOX_SIZE_BYTE)
                 bits = 8;
-        else if (ft->signal.encoding == ST_ENCODING_SIGN2 && 
-                 ft->signal.size == ST_SIZE_16BIT)
+        else if (ft->signal.encoding == SOX_ENCODING_SIGN2 && 
+                 ft->signal.size == SOX_SIZE_16BIT)
                 bits = 16;
-        else if (ft->signal.encoding == ST_ENCODING_SIGN2 && 
-                 ft->signal.size == ST_SIZE_24BIT)
+        else if (ft->signal.encoding == SOX_ENCODING_SIGN2 && 
+                 ft->signal.size == SOX_SIZE_24BIT)
                 bits = 24;
-        else if (ft->signal.encoding == ST_ENCODING_SIGN2 && 
-                 ft->signal.size == ST_SIZE_32BIT)
+        else if (ft->signal.encoding == SOX_ENCODING_SIGN2 && 
+                 ft->signal.size == SOX_SIZE_32BIT)
                 bits = 32;
         else
         {
-                st_fail_errno(ft,ST_EFMT,"unsupported output encoding/size for AIFC header");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EFMT,"unsupported output encoding/size for AIFC header");
+                return(SOX_EOF);
         }
 
-        st_writes(ft, "FORM"); /* IFF header */
+        sox_writes(ft, "FORM"); /* IFF header */
         /* file size */
-        st_writedw(ft, hsize + nframes * ft->signal.size * ft->signal.channels); 
-        st_writes(ft, "AIFC"); /* File type */
+        sox_writedw(ft, hsize + nframes * ft->signal.size * ft->signal.channels); 
+        sox_writes(ft, "AIFC"); /* File type */
 
         /* FVER chunk */
-        st_writes(ft, "FVER");
-        st_writedw(ft, 4); /* FVER chunk size */
-        st_writedw(ft, 0xa2805140); /* version_date(May23,1990,2:40pm) */
+        sox_writes(ft, "FVER");
+        sox_writedw(ft, 4); /* FVER chunk size */
+        sox_writedw(ft, 0xa2805140); /* version_date(May23,1990,2:40pm) */
 
         /* COMM chunk -- describes encoding (and #frames) */
-        st_writes(ft, "COMM");
-        st_writedw(ft, 18+4+1+15); /* COMM chunk size */
-        st_writew(ft, ft->signal.channels); /* nchannels */
-        st_writedw(ft, nframes); /* number of frames */
-        st_writew(ft, bits); /* sample width, in bits */
+        sox_writes(ft, "COMM");
+        sox_writedw(ft, 18+4+1+15); /* COMM chunk size */
+        sox_writew(ft, ft->signal.channels); /* nchannels */
+        sox_writedw(ft, nframes); /* number of frames */
+        sox_writew(ft, bits); /* sample width, in bits */
         write_ieee_extended(ft, (double)ft->signal.rate);
 
-        st_writes(ft, "NONE"); /*compression_type*/
-        st_writeb(ft, 14);
-        st_writes(ft, "not compressed");
-        st_writeb(ft, 0);
+        sox_writes(ft, "NONE"); /*compression_type*/
+        sox_writeb(ft, 14);
+        sox_writes(ft, "not compressed");
+        sox_writeb(ft, 0);
 
         /* SSND chunk -- describes data */
-        st_writes(ft, "SSND");
+        sox_writes(ft, "SSND");
         /* chunk size */
-        st_writedw(ft, 8 + nframes * ft->signal.channels * ft->signal.size); 
-        st_writedw(ft, 0); /* offset */
-        st_writedw(ft, 0); /* block size */
+        sox_writedw(ft, 8 + nframes * ft->signal.channels * ft->signal.size); 
+        sox_writedw(ft, 0); /* offset */
+        sox_writedw(ft, 0); /* block size */
 
         /* Any Private chunks shall appear after the required chunks (FORM,FVER,COMM,SSND) */
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 static double read_ieee_extended(ft_t ft)
 {
         char buf[10];
-        if (st_readbuf(ft, buf, 1, 10) != 10)
+        if (sox_readbuf(ft, buf, 1, 10) != 10)
         {
-                st_fail_errno(ft,ST_EOF,"EOF while reading IEEE extended number");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EOF,"EOF while reading IEEE extended number");
+                return(SOX_EOF);
         }
         return ConvertFromIeeeExtended((unsigned char *)buf);
 }
@@ -1006,12 +1006,12 @@
         char buf[10];
         ConvertToIeeeExtended(x, buf);
         /*
-        st_debug("converted %g to %o %o %o %o %o %o %o %o %o %o",
+        sox_debug("converted %g to %o %o %o %o %o %o %o %o %o %o",
                 x,
                 buf[0], buf[1], buf[2], buf[3], buf[4],
                 buf[5], buf[6], buf[7], buf[8], buf[9]);
         */
-        (void)st_writebuf(ft, buf, 1, 10);
+        (void)sox_writebuf(ft, buf, 1, 10);
 }
 
 
@@ -1188,22 +1188,22 @@
   NULL
 };
 
-static st_format_t st_aiff_format = {
+static sox_format_t sox_aiff_format = {
   aiffnames,
   NULL,
-  ST_FILE_LOOPS | ST_FILE_SEEK | ST_FILE_BIG_END,
-  st_aiffstartread,
-  st_aiffread,
-  st_aiffstopread,
-  st_aiffstartwrite,
-  st_aiffwrite,
-  st_aiffstopwrite,
-  st_aiffseek
+  SOX_FILE_LOOPS | SOX_FILE_SEEK | SOX_FILE_BIG_END,
+  sox_aiffstartread,
+  sox_aiffread,
+  sox_aiffstopread,
+  sox_aiffstartwrite,
+  sox_aiffwrite,
+  sox_aiffstopwrite,
+  sox_aiffseek
 };
 
-const st_format_t *st_aiff_format_fn(void)
+const sox_format_t *sox_aiff_format_fn(void)
 {
-    return &st_aiff_format;
+    return &sox_aiff_format;
 }
 
 static const char *aifcnames[] = {
@@ -1212,20 +1212,20 @@
   NULL
 };
 
-static st_format_t st_aifc_format = {
+static sox_format_t sox_aifc_format = {
   aifcnames,
   NULL,
-  ST_FILE_LOOPS | ST_FILE_SEEK | ST_FILE_BIG_END,
-  st_aiffstartread,
-  st_aiffread,
-  st_aiffstopread,
-  st_aifcstartwrite,
-  st_aiffwrite,
-  st_aifcstopwrite,
-  st_aiffseek
+  SOX_FILE_LOOPS | SOX_FILE_SEEK | SOX_FILE_BIG_END,
+  sox_aiffstartread,
+  sox_aiffread,
+  sox_aiffstopread,
+  sox_aifcstartwrite,
+  sox_aiffwrite,
+  sox_aifcstopwrite,
+  sox_aiffseek
 };
 
-const st_format_t *st_aifc_format_fn(void)
+const sox_format_t *sox_aifc_format_fn(void)
 {
-    return &st_aifc_format;
+    return &sox_aifc_format;
 }
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -7,7 +7,7 @@
  * responsible for the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #ifdef HAVE_ALSA
 
@@ -17,52 +17,52 @@
 {
     snd_pcm_t *pcm_handle;
     char *buf;
-    st_size_t buf_size;
+    sox_size_t buf_size;
 } *alsa_priv_t;
 
 static int get_format(ft_t ft, snd_pcm_format_mask_t *fmask, int *fmt)
 {
     if (ft->signal.size == -1)
-        ft->signal.size = ST_SIZE_16BIT;
+        ft->signal.size = SOX_SIZE_16BIT;
 
-    if (ft->signal.size != ST_SIZE_16BIT)
+    if (ft->signal.size != SOX_SIZE_16BIT)
     {
-        st_report("trying for word samples.");
-        ft->signal.size = ST_SIZE_16BIT;
+        sox_report("trying for word samples.");
+        ft->signal.size = SOX_SIZE_16BIT;
     }
 
-    if (ft->signal.encoding != ST_ENCODING_SIGN2 &&
-        ft->signal.encoding != ST_ENCODING_UNSIGNED)
+    if (ft->signal.encoding != SOX_ENCODING_SIGN2 &&
+        ft->signal.encoding != SOX_ENCODING_UNSIGNED)
     {
-        if (ft->signal.size == ST_SIZE_16BIT)
+        if (ft->signal.size == SOX_SIZE_16BIT)
         {
-            st_report("driver only supports signed and unsigned samples.  Changing to signed.");
-            ft->signal.encoding = ST_ENCODING_SIGN2;
+            sox_report("driver only supports signed and unsigned samples.  Changing to signed.");
+            ft->signal.encoding = SOX_ENCODING_SIGN2;
         }
         else
         {
-            st_report("driver only supports signed and unsigned samples.  Changing to unsigned.");
-            ft->signal.encoding = ST_ENCODING_UNSIGNED;
+            sox_report("driver only supports signed and unsigned samples.  Changing to unsigned.");
+            ft->signal.encoding = SOX_ENCODING_UNSIGNED;
         }
     }
 
     /* Some hardware only wants to work with 8-bit or 16-bit data */
-    if (ft->signal.size == ST_SIZE_BYTE)
+    if (ft->signal.size == SOX_SIZE_BYTE)
     {
         if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U8)) && 
             !(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S8)))
         {
-            st_report("driver doesn't supported byte samples.  Changing to words.");
-            ft->signal.size = ST_SIZE_16BIT;
+            sox_report("driver doesn't supported byte samples.  Changing to words.");
+            ft->signal.size = SOX_SIZE_16BIT;
         }
     }
-    else if (ft->signal.size == ST_SIZE_16BIT)
+    else if (ft->signal.size == SOX_SIZE_16BIT)
     {
         if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U16)) && 
             !(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S16)))
         {
-            st_report("driver doesn't supported word samples.  Changing to bytes.");
-            ft->signal.size = ST_SIZE_BYTE;
+            sox_report("driver doesn't supported word samples.  Changing to bytes.");
+            ft->signal.size = SOX_SIZE_BYTE;
         }
     }
     else
@@ -70,31 +70,31 @@
         if ((snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U16)) ||
             (snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S16)))
         {
-            st_report("driver doesn't supported %s samples.  Changing to words.", st_sizes_str[(unsigned char)ft->signal.size]);
-            ft->signal.size = ST_SIZE_16BIT;
+            sox_report("driver doesn't supported %s samples.  Changing to words.", sox_sizes_str[(unsigned char)ft->signal.size]);
+            ft->signal.size = SOX_SIZE_16BIT;
         }
         else
         {
-            st_report("driver doesn't supported %s samples.  Changing to bytes.", st_sizes_str[(unsigned char)ft->signal.size]);
-            ft->signal.size = ST_SIZE_BYTE;
+            sox_report("driver doesn't supported %s samples.  Changing to bytes.", sox_sizes_str[(unsigned char)ft->signal.size]);
+            ft->signal.size = SOX_SIZE_BYTE;
         }
     }
 
-    if (ft->signal.size == ST_SIZE_BYTE) {
+    if (ft->signal.size == SOX_SIZE_BYTE) {
         switch (ft->signal.encoding)
         {
-            case ST_ENCODING_SIGN2:
+            case SOX_ENCODING_SIGN2:
                 if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S8)))
                 {
-                    st_report("driver doesn't supported signed byte samples.  Changing to unsigned bytes.");
-                    ft->signal.encoding = ST_ENCODING_UNSIGNED;
+                    sox_report("driver doesn't supported signed byte samples.  Changing to unsigned bytes.");
+                    ft->signal.encoding = SOX_ENCODING_UNSIGNED;
                 }
                 break;
-            case ST_ENCODING_UNSIGNED:
+            case SOX_ENCODING_UNSIGNED:
                 if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U8)))
                 {
-                    st_report("driver doesn't supported unsigned byte samples.  Changing to signed bytes.");
-                    ft->signal.encoding = ST_ENCODING_SIGN2;
+                    sox_report("driver doesn't supported unsigned byte samples.  Changing to signed bytes.");
+                    ft->signal.encoding = SOX_ENCODING_SIGN2;
                 }
                 break;
             default:
@@ -102,19 +102,19 @@
         }
         switch (ft->signal.encoding)
         {
-            case ST_ENCODING_SIGN2:
+            case SOX_ENCODING_SIGN2:
                 if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S8)))
                 {
-                    st_fail_errno(ft,ST_EFMT,"ALSA driver does not support signed byte samples");
-                    return ST_EOF;
+                    sox_fail_errno(ft,SOX_EFMT,"ALSA driver does not support signed byte samples");
+                    return SOX_EOF;
                 }
                 *fmt = SND_PCM_FORMAT_S8;
                 break;
-            case ST_ENCODING_UNSIGNED:
+            case SOX_ENCODING_UNSIGNED:
                 if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U8)))
                 {
-                    st_fail_errno(ft,ST_EFMT,"ALSA driver does not support unsigned byte samples");
-                    return ST_EOF;
+                    sox_fail_errno(ft,SOX_EFMT,"ALSA driver does not support unsigned byte samples");
+                    return SOX_EOF;
                 }
                 *fmt = SND_PCM_FORMAT_U8;
                 break;
@@ -122,21 +122,21 @@
                     break;
         }
     }
-    else if (ft->signal.size == ST_SIZE_16BIT) {
+    else if (ft->signal.size == SOX_SIZE_16BIT) {
         switch (ft->signal.encoding)
         {
-            case ST_ENCODING_SIGN2:
+            case SOX_ENCODING_SIGN2:
                 if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S16)))
                 {
-                    st_report("driver does not support signed word samples.  Changing to unsigned words.");
-                    ft->signal.encoding = ST_ENCODING_UNSIGNED;
+                    sox_report("driver does not support signed word samples.  Changing to unsigned words.");
+                    ft->signal.encoding = SOX_ENCODING_UNSIGNED;
                 }
                 break;
-            case ST_ENCODING_UNSIGNED:
+            case SOX_ENCODING_UNSIGNED:
                 if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U16)))
                 {
-                    st_report("driver does not support unsigned word samples.  Changing to signed words.");
-                    ft->signal.encoding = ST_ENCODING_SIGN2;
+                    sox_report("driver does not support unsigned word samples.  Changing to signed words.");
+                    ft->signal.encoding = SOX_ENCODING_SIGN2;
                 }
                 break;
             default:
@@ -144,19 +144,19 @@
         }
         switch (ft->signal.encoding)
         {
-            case ST_ENCODING_SIGN2:
+            case SOX_ENCODING_SIGN2:
                 if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_S16)))
                 {
-                    st_fail_errno(ft,ST_EFMT,"ALSA driver does not support signed word samples");
-                    return ST_EOF;
+                    sox_fail_errno(ft,SOX_EFMT,"ALSA driver does not support signed word samples");
+                    return SOX_EOF;
                 }
                 *fmt = SND_PCM_FORMAT_S16_LE;
                 break;
-            case ST_ENCODING_UNSIGNED:
+            case SOX_ENCODING_UNSIGNED:
                 if (!(snd_pcm_format_mask_test(fmask, SND_PCM_FORMAT_U16)))
                 {
-                    st_fail_errno(ft,ST_EFMT,"ALSA driver does not support unsigned word samples");
-                    return ST_EOF;
+                    sox_fail_errno(ft,SOX_EFMT,"ALSA driver does not support unsigned word samples");
+                    return SOX_EOF;
                 }
                 *fmt = SND_PCM_FORMAT_U16_LE;
                 break;
@@ -165,14 +165,14 @@
         }
     }
     else {
-        st_fail_errno(ft,ST_EFMT,"ALSA driver does not support %s %s output",
-                      st_encodings_str[(unsigned char)ft->signal.encoding], st_sizes_str[(unsigned char)ft->signal.size]);
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EFMT,"ALSA driver does not support %s %s output",
+                      sox_encodings_str[(unsigned char)ft->signal.encoding], sox_sizes_str[(unsigned char)ft->signal.size]);
+        return SOX_EOF;
     }
     return 0;
 }
 
-static int st_alsasetup(ft_t ft, snd_pcm_stream_t mode)
+static int sox_alsasetup(ft_t ft, snd_pcm_stream_t mode)
 {
     int fmt = SND_PCM_FORMAT_S16;
     int err;
@@ -189,13 +189,13 @@
     if ((err = snd_pcm_open(&(alsa->pcm_handle), ft->filename, 
                             mode, 0)) < 0) 
     {
-        st_fail_errno(ft, ST_EPERM, "cannot open audio device");
+        sox_fail_errno(ft, SOX_EPERM, "cannot open audio device");
         goto open_error;
     }
 
     if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0) 
     {
-        st_fail_errno(ft, ST_ENOMEM, 
+        sox_fail_errno(ft, SOX_ENOMEM, 
                       "cannot allocate hardware parameter structure");
         goto open_error;
     }
@@ -202,7 +202,7 @@
 
     if ((err = snd_pcm_hw_params_any(alsa->pcm_handle, hw_params)) < 0) 
     {
-        st_fail_errno(ft, ST_EPERM,
+        sox_fail_errno(ft, SOX_EPERM,
                       "cannot initialize hardware parameter structure");
         goto open_error;
     }
@@ -211,7 +211,7 @@
     /* Turn off software resampling */
     err = snd_pcm_hw_params_set_rate_resample(alsa->pcm_handle, hw_params, 0);
     if (err < 0) {
-        st_fail_errno(ft, ST_EPERM, "Resampling setup failed for playback");
+        sox_fail_errno(ft, SOX_EPERM, "Resampling setup failed for playback");
         goto open_error;
     }
 #endif
@@ -219,7 +219,7 @@
     if ((err = snd_pcm_hw_params_set_access(alsa->pcm_handle, hw_params, 
                                             SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
     {
-        st_fail_errno(ft, ST_EPERM,
+        sox_fail_errno(ft, SOX_EPERM,
                       "cannot set access type");
         goto open_error;
     }
@@ -247,7 +247,7 @@
     if ((err = snd_pcm_hw_params_set_format(alsa->pcm_handle, 
                                             hw_params, fmt)) < 0) 
     {
-        st_fail_errno(ft, ST_EPERM, "cannot set sample format");
+        sox_fail_errno(ft, SOX_EPERM, "cannot set sample format");
         goto open_error;
     }
 
@@ -257,7 +257,7 @@
     rate = range_limit(ft->signal.rate, min_rate, max_rate);
     if (rate != ft->signal.rate)
     {
-        st_report("hardware does not support sample rate %i; changing to %i.", ft->signal.rate, rate);
+        sox_report("hardware does not support sample rate %i; changing to %i.", ft->signal.rate, rate);
         ft->signal.rate = rate;
     }
     dir = 0;
@@ -266,7 +266,7 @@
                                                &rate,
                                                &dir)) < 0) 
     {
-        st_fail_errno(ft, ST_EPERM, "cannot set sample rate");
+        sox_fail_errno(ft, SOX_EPERM, "cannot set sample rate");
         goto open_error;
     }
     snd_pcm_hw_params_get_rate(hw_params, 
@@ -275,7 +275,7 @@
  
     if (rate != ft->signal.rate)
     {
-        st_report("Could not set exact rate of %d.  Approximating with %d",
+        sox_report("Could not set exact rate of %d.  Approximating with %d",
                 ft->signal.rate, rate);
     }
 
@@ -285,22 +285,22 @@
                                               hw_params, 
                                               ft->signal.channels)) < 0) 
     {
-        st_fail_errno(ft, ST_EPERM, "cannot set channel count");
+        sox_fail_errno(ft, SOX_EPERM, "cannot set channel count");
         goto open_error;
     }
 
-    /* Have a much larger buffer than ST_BUFSIZ to avoid underruns */
-    buffer_size = ST_BUFSIZ * 8 / ft->signal.size / ft->signal.channels;
+    /* Have a much larger buffer than SOX_BUFSIZ to avoid underruns */
+    buffer_size = SOX_BUFSIZ * 8 / ft->signal.size / ft->signal.channels;
 
     if (snd_pcm_hw_params_get_buffer_size_min(hw_params, &buffer_size_min) < 0)
     {
-        st_fail_errno(ft, ST_EPERM, "Error getting min buffer size.");
+        sox_fail_errno(ft, SOX_EPERM, "Error getting min buffer size.");
         goto open_error;
     }
 
     if (snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size_max) < 0)
     {
-        st_fail_errno(ft, ST_EPERM, "Error getting max buffer size.");
+        sox_fail_errno(ft, SOX_EPERM, "Error getting max buffer size.");
         goto open_error;
     }
 
@@ -308,7 +308,7 @@
     if (snd_pcm_hw_params_get_period_size_min(hw_params, 
                                               &period_size_min, &dir) < 0)
     {
-        st_fail_errno(ft, ST_EPERM, "Error getting min period size.");
+        sox_fail_errno(ft, SOX_EPERM, "Error getting min period size.");
         goto open_error;
     }
 
@@ -316,7 +316,7 @@
     if (snd_pcm_hw_params_get_period_size_max(hw_params, 
                                               &period_size_max, &dir) < 0)
     {
-        st_fail_errno(ft, ST_EPERM, "Error getting max buffer size.");
+        sox_fail_errno(ft, SOX_EPERM, "Error getting max buffer size.");
         goto open_error;
     }
 
@@ -332,7 +332,7 @@
     if (snd_pcm_hw_params_set_period_size_near(alsa->pcm_handle, hw_params, 
                                                &period_size, &dir) < 0) 
     {
-        st_fail_errno(ft, ST_EPERM, "Error setting periods.");
+        sox_fail_errno(ft, SOX_EPERM, "Error setting periods.");
         goto open_error;
     }
     snd_pcm_hw_params_get_period_size(hw_params, &period_size, &dir);
@@ -340,7 +340,7 @@
     dir = 0;
     if (snd_pcm_hw_params_set_buffer_size_near(alsa->pcm_handle, hw_params, 
                                                &buffer_size) < 0) {
-        st_fail_errno(ft, ST_EPERM, "Error setting buffer size.");
+        sox_fail_errno(ft, SOX_EPERM, "Error setting buffer size.");
         goto open_error;
     }
 
@@ -347,13 +347,13 @@
     snd_pcm_hw_params_get_buffer_size(hw_params, &buffer_size);
     if (period_size * 2 > buffer_size)
     {
-        st_fail_errno(ft, ST_EPERM, "Buffer too small. Could not use.");
+        sox_fail_errno(ft, SOX_EPERM, "Buffer too small. Could not use.");
         goto open_error;
     }
 
     if ((err = snd_pcm_hw_params(alsa->pcm_handle, hw_params)) < 0) 
     {
-        st_fail_errno(ft, ST_EPERM, "cannot set parameters");
+        sox_fail_errno(ft, SOX_EPERM, "cannot set parameters");
         goto open_error;
     }
 
@@ -362,7 +362,7 @@
 
     if ((err = snd_pcm_prepare(alsa->pcm_handle)) < 0) 
     {
-        st_fail_errno(ft, ST_EPERM, "cannot prepare audio interface for use");
+        sox_fail_errno(ft, SOX_EPERM, "cannot prepare audio interface for use");
         goto open_error;
     }
 
@@ -369,7 +369,7 @@
     alsa->buf_size = buffer_size * ft->signal.size * ft->signal.channels;
     alsa->buf = xmalloc(alsa->buf_size);
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 
 open_error:
     if (fmask)
@@ -377,7 +377,7 @@
     if (hw_params)
         snd_pcm_hw_params_free(hw_params);
 
-    return ST_EOF;
+    return SOX_EOF;
 
 }
 
@@ -390,7 +390,7 @@
     {   /* over/under-run */
         err = snd_pcm_prepare(handle);
         if (err < 0)
-            st_warn("Can't recover from over/underrun, prepare failed: %s", snd_strerror(err));
+            sox_warn("Can't recover from over/underrun, prepare failed: %s", snd_strerror(err));
         return 0;
     } 
     else 
@@ -404,7 +404,7 @@
             {
                 err = snd_pcm_prepare(handle);
                 if (err < 0)
-                    st_warn("Can't recovery from suspend, prepare failed: %s", snd_strerror(err));
+                    sox_warn("Can't recovery from suspend, prepare failed: %s", snd_strerror(err));
             }
         }
         return 0;
@@ -419,24 +419,24 @@
  *      size and encoding of samples,
  *      mono/stereo/quad.
  */
-static int st_alsastartread(ft_t ft)
+static int sox_alsastartread(ft_t ft)
 {
-    return st_alsasetup(ft, SND_PCM_STREAM_CAPTURE);
+    return sox_alsasetup(ft, SND_PCM_STREAM_CAPTURE);
 }
 
-static void st_ub_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clips UNUSED)
+static void sox_ub_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, char swap UNUSED, sox_size_t * clips UNUSED)
 {
     while (len--)
-        *buf1++ = ST_UNSIGNED_BYTE_TO_SAMPLE(*((unsigned char *)buf2++),);
+        *buf1++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(*((unsigned char *)buf2++),);
 }
 
-static void st_sb_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap UNUSED, st_size_t * clips UNUSED)
+static void sox_sb_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, char swap UNUSED, sox_size_t * clips UNUSED)
 {
     while (len--)
-        *buf1++ = ST_SIGNED_BYTE_TO_SAMPLE(*((int8_t *)buf2++),);
+        *buf1++ = SOX_SIGNED_BYTE_TO_SAMPLE(*((int8_t *)buf2++),);
 }
 
-static void st_uw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clips UNUSED)
+static void sox_uw_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, char swap, sox_size_t * clips UNUSED)
 {
     while (len--)
     {
@@ -443,13 +443,13 @@
         uint16_t datum = *((uint16_t *)buf2);
         buf2++; buf2++;
         if (swap)
-            datum = st_swapw(datum);
+            datum = sox_swapw(datum);
 
-        *buf1++ = ST_UNSIGNED_WORD_TO_SAMPLE(datum,);
+        *buf1++ = SOX_UNSIGNED_WORD_TO_SAMPLE(datum,);
     }
 }
 
-static void st_sw_read_buf(st_sample_t *buf1, char const * buf2, st_size_t len, char swap, st_size_t * clips UNUSED)
+static void sox_sw_read_buf(sox_sample_t *buf1, char const * buf2, sox_size_t len, char swap, sox_size_t * clips UNUSED)
 {
     while (len--)
     {
@@ -456,50 +456,50 @@
         int16_t datum = *((int16_t *)buf2);
         buf2++; buf2++;
         if (swap)
-            datum = st_swapw(datum);
+            datum = sox_swapw(datum);
 
-        *buf1++ = ST_SIGNED_WORD_TO_SAMPLE(datum,);
+        *buf1++ = SOX_SIGNED_WORD_TO_SAMPLE(datum,);
     }
 }
 
-static st_size_t st_alsaread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
+static sox_size_t sox_alsaread(ft_t ft, sox_sample_t *buf, sox_size_t nsamp)
 {
-    st_size_t len;
+    sox_size_t len;
     int err;
     alsa_priv_t alsa = (alsa_priv_t)ft->priv;
-    void (*read_buf)(st_sample_t *, char const *, st_size_t, char, st_size_t *) = 0;
+    void (*read_buf)(sox_sample_t *, char const *, sox_size_t, char, sox_size_t *) = 0;
 
     switch(ft->signal.size) {
-        case ST_SIZE_BYTE:
+        case SOX_SIZE_BYTE:
             switch(ft->signal.encoding)
             {
-                case ST_ENCODING_SIGN2:
-                    read_buf = st_sb_read_buf;
+                case SOX_ENCODING_SIGN2:
+                    read_buf = sox_sb_read_buf;
                     break;
-                case ST_ENCODING_UNSIGNED:
-                    read_buf = st_ub_read_buf;
+                case SOX_ENCODING_UNSIGNED:
+                    read_buf = sox_ub_read_buf;
                     break;
                 default:
-                    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
+                    sox_fail_errno(ft,SOX_EFMT,"Do not support this encoding for this data size");
                     return 0;
             }
             break;
-        case ST_SIZE_16BIT:
+        case SOX_SIZE_16BIT:
             switch(ft->signal.encoding)
             {
-                case ST_ENCODING_SIGN2:
-                    read_buf = st_sw_read_buf;
+                case SOX_ENCODING_SIGN2:
+                    read_buf = sox_sw_read_buf;
                     break;
-                case ST_ENCODING_UNSIGNED:
-                    read_buf = st_uw_read_buf;
+                case SOX_ENCODING_UNSIGNED:
+                    read_buf = sox_uw_read_buf;
                     break;
                 default:
-                    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
+                    sox_fail_errno(ft,SOX_EFMT,"Do not support this encoding for this data size");
                     return 0;
             }
             break;
         default:
-            st_fail_errno(ft,ST_EFMT,"Do not support this data size for this handler");
+            sox_fail_errno(ft,SOX_EFMT,"Do not support this data size for this handler");
             return 0;
     }
 
@@ -517,13 +517,13 @@
         {
             if (xrun_recovery(alsa->pcm_handle, err) < 0)
             {
-                st_fail_errno(ft, ST_EPERM, "ALSA write error");
+                sox_fail_errno(ft, SOX_EPERM, "ALSA write error");
                 return 0;
             }
         }
         else
         {
-            read_buf(buf+(len*sizeof(st_sample_t)), alsa->buf, err, ft->signal.reverse_bytes, &ft->clips);
+            read_buf(buf+(len*sizeof(sox_sample_t)), alsa->buf, err, ft->signal.reverse_bytes, &ft->clips);
             len += err * ft->signal.channels;
         }
     }
@@ -531,7 +531,7 @@
     return len;
 }
 
-static int st_alsastopread(ft_t ft)
+static int sox_alsastopread(ft_t ft)
 {
     alsa_priv_t alsa = (alsa_priv_t)ft->priv;
 
@@ -539,93 +539,93 @@
 
     free(alsa->buf);
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
-static int st_alsastartwrite(ft_t ft)
+static int sox_alsastartwrite(ft_t ft)
 {
-    return st_alsasetup(ft, SND_PCM_STREAM_PLAYBACK);
+    return sox_alsasetup(ft, SND_PCM_STREAM_PLAYBACK);
 }
 
-static void st_ub_write_buf(char* buf1, st_sample_t const * buf2, st_size_t len, char swap UNUSED, st_size_t * clips)
+static void sox_ub_write_buf(char* buf1, sox_sample_t const * buf2, sox_size_t len, char swap UNUSED, sox_size_t * clips)
 {
     while (len--)
-        *(uint8_t *)buf1++ = ST_SAMPLE_TO_UNSIGNED_BYTE(*buf2++, *clips);
+        *(uint8_t *)buf1++ = SOX_SAMPLE_TO_UNSIGNED_BYTE(*buf2++, *clips);
 }
 
-static void st_sb_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap UNUSED, st_size_t * clips)
+static void sox_sb_write_buf(char *buf1, sox_sample_t const * buf2, sox_size_t len, char swap UNUSED, sox_size_t * clips)
 {
     while (len--)
-        *(int8_t *)buf1++ = ST_SAMPLE_TO_SIGNED_BYTE(*buf2++, *clips);
+        *(int8_t *)buf1++ = SOX_SAMPLE_TO_SIGNED_BYTE(*buf2++, *clips);
 }
 
-static void st_uw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clips)
+static void sox_uw_write_buf(char *buf1, sox_sample_t const * buf2, sox_size_t len, char swap, sox_size_t * clips)
 {
     while (len--)
     {
-        uint16_t datum = ST_SAMPLE_TO_UNSIGNED_WORD(*buf2++, *clips);
+        uint16_t datum = SOX_SAMPLE_TO_UNSIGNED_WORD(*buf2++, *clips);
         if (swap)
-            datum = st_swapw(datum);
+            datum = sox_swapw(datum);
         *(uint16_t *)buf1 = datum;
         buf1++; buf1++;
     }
 }
 
-static void st_sw_write_buf(char *buf1, st_sample_t const * buf2, st_size_t len, char swap, st_size_t * clips)
+static void sox_sw_write_buf(char *buf1, sox_sample_t const * buf2, sox_size_t len, char swap, sox_size_t * clips)
 {
     while (len--)
     {
-        int16_t datum = ST_SAMPLE_TO_SIGNED_WORD(*buf2++, *clips);
+        int16_t datum = SOX_SAMPLE_TO_SIGNED_WORD(*buf2++, *clips);
         if (swap)
-            datum = st_swapw(datum);
+            datum = sox_swapw(datum);
         *(int16_t *)buf1 = datum;
         buf1++; buf1++;
     }
 }
 
-static st_size_t st_alsawrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
+static sox_size_t sox_alsawrite(ft_t ft, const sox_sample_t *buf, sox_size_t nsamp)
 {
-    st_size_t osamp, done;
+    sox_size_t osamp, done;
     alsa_priv_t alsa = (alsa_priv_t)ft->priv;
-    void (*write_buf)(char *, const st_sample_t *, st_size_t, char, st_size_t *) = 0;
+    void (*write_buf)(char *, const sox_sample_t *, sox_size_t, char, sox_size_t *) = 0;
 
     switch(ft->signal.size) {
-        case ST_SIZE_BYTE:
+        case SOX_SIZE_BYTE:
             switch (ft->signal.encoding)
             {
-                case ST_ENCODING_SIGN2:
-                    write_buf = st_sb_write_buf;
+                case SOX_ENCODING_SIGN2:
+                    write_buf = sox_sb_write_buf;
                     break;
-                case ST_ENCODING_UNSIGNED:
-                    write_buf = st_ub_write_buf;
+                case SOX_ENCODING_UNSIGNED:
+                    write_buf = sox_ub_write_buf;
                     break;
                 default:
-                    st_fail_errno(ft,ST_EFMT,"this encoding is not supported for this data size");
+                    sox_fail_errno(ft,SOX_EFMT,"this encoding is not supported for this data size");
                     return 0;
             }
             break;
-        case ST_SIZE_16BIT:
+        case SOX_SIZE_16BIT:
             switch (ft->signal.encoding)
             {
-                case ST_ENCODING_SIGN2:
-                    write_buf = st_sw_write_buf;
+                case SOX_ENCODING_SIGN2:
+                    write_buf = sox_sw_write_buf;
                     break;
-                case ST_ENCODING_UNSIGNED:
-                    write_buf = st_uw_write_buf;
+                case SOX_ENCODING_UNSIGNED:
+                    write_buf = sox_uw_write_buf;
                     break;
                 default:
-                    st_fail_errno(ft,ST_EFMT,"this encoding is not supported for this data size");
+                    sox_fail_errno(ft,SOX_EFMT,"this encoding is not supported for this data size");
                     return 0;
             }
             break;
         default:
-            st_fail_errno(ft,ST_EFMT,"this data size is not supported by this handler");
+            sox_fail_errno(ft,SOX_EFMT,"this data size is not supported by this handler");
             return 0;
     }
 
     for (done = 0; done < nsamp; done += osamp) {
       int err;
-      st_size_t len;
+      sox_size_t len;
       
       osamp = min(nsamp - done, alsa->buf_size / ft->signal.size);
       write_buf(alsa->buf, buf, osamp, ft->signal.reverse_bytes, &ft->clips);
@@ -639,7 +639,7 @@
           errno = 0;
         if (err < 0) {
           if (xrun_recovery(alsa->pcm_handle, err) < 0) {
-            st_fail_errno(ft, ST_EPERM, "ALSA write error");
+            sox_fail_errno(ft, SOX_EPERM, "ALSA write error");
             return 0;
           }
         } else
@@ -651,7 +651,7 @@
 }
 
 
-static int st_alsastopwrite(ft_t ft)
+static int sox_alsastopwrite(ft_t ft)
 {
     alsa_priv_t alsa = (alsa_priv_t)ft->priv;
 
@@ -660,7 +660,7 @@
 
     free(alsa->buf);
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 static const char *alsanames[] = {
@@ -668,22 +668,22 @@
   NULL
 };
 
-static st_format_t st_alsa_format = {
+static sox_format_t sox_alsa_format = {
   alsanames,
   NULL,
-  ST_FILE_DEVICE | ST_FILE_NOSTDIO,
-  st_alsastartread,
-  st_alsaread,
-  st_alsastopread,
-  st_alsastartwrite,
-  st_alsawrite,
-  st_alsastopwrite,
-  st_format_nothing_seek
+  SOX_FILE_DEVICE | SOX_FILE_NOSTDIO,
+  sox_alsastartread,
+  sox_alsaread,
+  sox_alsastopread,
+  sox_alsastartwrite,
+  sox_alsawrite,
+  sox_alsastopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_alsa_format_fn(void)
+const sox_format_t *sox_alsa_format_fn(void)
 {
-    return &st_alsa_format;
+    return &sox_alsa_format;
 }
 
 #endif /* HAVE_ALSA */
--- a/src/amr-wb.c
+++ b/src/amr-wb.c
@@ -16,7 +16,7 @@
 
 /* File format: AMR-WB   (c) 2007 robs@users.sourceforge.net */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "../amr-wb/amr-wb.h"
 #include <string.h>
 #include <math.h>
@@ -30,18 +30,18 @@
   void * state;
   Word16 coding_mode;
   Word16 mode_previous;
-  st_bool reset;
-  st_bool reset_previous;
+  sox_bool reset;
+  sox_bool reset_previous;
   Word16 pcm[L_FRAME16k];
-  st_size_t pcm_index;
+  sox_size_t pcm_index;
 } * amr_wb_t;
 
-assert_static(sizeof(struct amr_wb) <= ST_MAX_FILE_PRIVSIZE,
+assert_static(sizeof(struct amr_wb) <= SOX_MAX_FILE_PRIVSIZE,
               /* else */ amr_wb_PRIVSIZE_too_big);
 
 #define ENCODING 2 /* 0..2 */
 
-static st_size_t decode_1_frame(ft_t ft)
+static sox_size_t decode_1_frame(ft_t ft)
 {
   amr_wb_t this = (amr_wb_t) ft->priv;
   Word16 nb_bits, i;
@@ -54,7 +54,7 @@
 
   if (frame_type == RX_NO_DATA || frame_type == RX_SPEECH_LOST) {
     mode = this->mode_previous;
-    this->reset = st_false;
+    this->reset = sox_false;
   } else {
     this->mode_previous = mode;
 
@@ -77,7 +77,7 @@
 static void encode_1_frame(ft_t ft)
 {
   amr_wb_t this = (amr_wb_t) ft->priv;
-  st_size_t i;
+  sox_size_t i;
   Word16 nb_bits;
   Word16 prms[NB_BITS_MAX];
   Word16 reset = encoder_homing_frame_test(this->pcm);
@@ -94,8 +94,8 @@
 static void set_format(ft_t ft)
 {
   ft->signal.rate = 16000;
-  ft->signal.size = ST_SIZE_16BIT;
-  ft->signal.encoding = ST_ENCODING_AMR_WB;
+  ft->signal.size = SOX_SIZE_16BIT;
+  ft->signal.encoding = SOX_ENCODING_AMR_WB;
   ft->signal.channels = 1;
 }
 
@@ -103,7 +103,7 @@
 {
   amr_wb_t this = (amr_wb_t) ft->priv;
 
-  this->reset_previous = st_true;
+  this->reset_previous = sox_true;
   this->pcm_index = L_FRAME16k;
 
   Init_decoder(&this->state);
@@ -115,18 +115,18 @@
     fread(buffer, sizeof(char), sizeof(buffer) - 1, ft->fp);
     buffer[sizeof(buffer) - 1] = 0;
     if (strcmp(buffer, magic)) {
-      st_fail("Invalid magic number");
-      return ST_EOF;
+      sox_fail("Invalid magic number");
+      return SOX_EOF;
     }
   }
   set_format(ft);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static st_size_t read(ft_t ft, st_sample_t * buf, st_size_t len)
+static sox_size_t read(ft_t ft, sox_sample_t * buf, sox_size_t len)
 {
   amr_wb_t this = (amr_wb_t) ft->priv;
-  st_size_t done;
+  sox_size_t done;
 
   for (done = 0; done < len; done++) {
     if (this->pcm_index >= L_FRAME16k)
@@ -133,7 +133,7 @@
       this->pcm_index = decode_1_frame(ft);
     if (this->pcm_index >= L_FRAME16k)
       break;
-    *buf++ = ST_SIGNED_WORD_TO_SAMPLE(0xfffc & this->pcm[this->pcm_index++], ft->clips);
+    *buf++ = SOX_SIGNED_WORD_TO_SAMPLE(0xfffc & this->pcm[this->pcm_index++], ft->clips);
   }
   return done;
 }
@@ -143,7 +143,7 @@
   amr_wb_t this = (amr_wb_t) ft->priv;
   Close_decoder(this->state);
   Close_read_serial(this->rx_state);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static int startwrite(ft_t ft)
@@ -153,8 +153,8 @@
   if (ft->signal.compression != HUGE_VAL) {
     this->coding_mode = ft->signal.compression;
     if (this->coding_mode != ft->signal.compression || this->coding_mode > 8) {
-      st_fail_errno(ft, ST_EINVAL, "compression level must be a whole number from 0 to 8");
-      return ST_EOF;
+      sox_fail_errno(ft, SOX_EINVAL, "compression level must be a whole number from 0 to 8");
+      return SOX_EOF;
     }
   }
   else this->coding_mode = 0;
@@ -163,18 +163,18 @@
   Init_coder(&this->state);
   Init_write_serial(&this->tx_state);
   if (ENCODING == 2)
-    st_writes(ft, magic);
+    sox_writes(ft, magic);
   this->pcm_index = 0;
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static st_size_t write(ft_t ft, const st_sample_t * buf, st_size_t len)
+static sox_size_t write(ft_t ft, const sox_sample_t * buf, sox_size_t len)
 {
   amr_wb_t this = (amr_wb_t) ft->priv;
-  st_size_t done;
+  sox_size_t done;
 
   for (done = 0; done < len; ++done) {
-    this->pcm[this->pcm_index++] = (Word16) (ST_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips));
+    this->pcm[this->pcm_index++] = (Word16) (SOX_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips));
     if (this->pcm_index == L_FRAME16k) {
       this->pcm_index = 0;
       encode_1_frame(ft);
@@ -195,17 +195,17 @@
   }
   Close_coder(this->state);
   Close_write_serial(this->tx_state);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-st_format_t const * st_amr_wb_format_fn(void)
+sox_format_t const * sox_amr_wb_format_fn(void)
 {
   static char const * names[] = {"amr-wb", NULL};
-  static st_format_t driver = {
+  static sox_format_t driver = {
     names, NULL, 0,
     startread, read, stopread,
     startwrite, write, stopwrite,
-    st_format_nothing_seek
+    sox_format_nothing_seek
   };
   return &driver;
 }
--- a/src/au.c
+++ b/src/au.c
@@ -19,7 +19,7 @@
  * Output is always in big-endian (Sun/NeXT) order.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "g72x.h"
 #include <stdlib.h>
 #include <string.h>
@@ -48,9 +48,9 @@
 /* Private data */
 typedef struct aupriv {
         /* For writer: size in bytes */
-        st_size_t data_size;
+        sox_size_t data_size;
         /* For seeking */
-        st_size_t dataStart;
+        sox_size_t dataStart;
         /* For G72x decoding: */
         struct g72x_state state;
         int (*dec_routine)(int i, int out_coding, struct g72x_state *state_ptr);
@@ -59,65 +59,65 @@
         int in_bits;
 } *au_t;
 
-static void auwriteheader(ft_t ft, st_size_t data_size);
+static void auwriteheader(ft_t ft, sox_size_t data_size);
 
-static int st_auencodingandsize(int sun_encoding, st_encoding_t * encoding, int * size)
+static int sox_auencodingandsize(int sun_encoding, sox_encoding_t * encoding, int * size)
 {
     switch (sun_encoding) {
     case SUN_ULAW:
-            *encoding = ST_ENCODING_ULAW;
-            *size = ST_SIZE_BYTE;
+            *encoding = SOX_ENCODING_ULAW;
+            *size = SOX_SIZE_BYTE;
             break;
     case SUN_ALAW:
-            *encoding = ST_ENCODING_ALAW;
-            *size = ST_SIZE_BYTE;
+            *encoding = SOX_ENCODING_ALAW;
+            *size = SOX_SIZE_BYTE;
             break;
     case SUN_LIN_8:
-            *encoding = ST_ENCODING_SIGN2;
-            *size = ST_SIZE_BYTE;
+            *encoding = SOX_ENCODING_SIGN2;
+            *size = SOX_SIZE_BYTE;
             break;
     case SUN_LIN_16:
-            *encoding = ST_ENCODING_SIGN2;
-            *size = ST_SIZE_16BIT;
+            *encoding = SOX_ENCODING_SIGN2;
+            *size = SOX_SIZE_16BIT;
             break;
     case SUN_LIN_24:
-            *encoding = ST_ENCODING_SIGN2;
-            *size = ST_SIZE_24BIT;
+            *encoding = SOX_ENCODING_SIGN2;
+            *size = SOX_SIZE_24BIT;
             break;
     case SUN_G721:
-            *encoding = ST_ENCODING_SIGN2;
-            *size = ST_SIZE_16BIT;
+            *encoding = SOX_ENCODING_SIGN2;
+            *size = SOX_SIZE_16BIT;
             break;
     case SUN_G723_3:
-            *encoding = ST_ENCODING_SIGN2;
-            *size = ST_SIZE_16BIT;
+            *encoding = SOX_ENCODING_SIGN2;
+            *size = SOX_SIZE_16BIT;
             break;
     case SUN_G723_5:
-            *encoding = ST_ENCODING_SIGN2;
-            *size = ST_SIZE_16BIT;
+            *encoding = SOX_ENCODING_SIGN2;
+            *size = SOX_SIZE_16BIT;
             break;
     case SUN_FLOAT:
-            *encoding = ST_ENCODING_FLOAT;
-            *size = ST_SIZE_32BIT;
+            *encoding = SOX_ENCODING_FLOAT;
+            *size = SOX_SIZE_32BIT;
             break;
     default:
-            st_debug("encoding: 0x%lx", encoding);
-            return(ST_EOF);
+            sox_debug("encoding: 0x%lx", encoding);
+            return(SOX_EOF);
     }
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
 }
 
-static int st_auseek(ft_t ft, st_size_t offset) 
+static int sox_auseek(ft_t ft, sox_size_t offset) 
 {
     au_t au = (au_t ) ft->priv;
 
     if (au->dec_routine != NULL)
     {
-        st_fail_errno(ft,ST_ENOTSUP,"Sorry, DEC unsupported");
+        sox_fail_errno(ft,SOX_ENOTSUP,"Sorry, DEC unsupported");
     }
     else 
     {
-        st_size_t new_offset, channel_block, alignment;
+        sox_size_t new_offset, channel_block, alignment;
 
         new_offset = offset * ft->signal.size;
         /* Make sure request aligns to a channel block (ie left+right) */
@@ -131,13 +131,13 @@
             new_offset += (channel_block - alignment);
         new_offset += au->dataStart;
 
-        ft->st_errno = st_seeki(ft, new_offset, SEEK_SET);
+        ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
     }
 
-    return(ft->st_errno);
+    return(ft->sox_errno);
 }
 
-static int st_austartread(ft_t ft) 
+static int sox_austartread(ft_t ft) 
 {
         /* The following 6 variables represent a Sun sound header on disk.
            The numbers are written as big-endians.
@@ -158,7 +158,7 @@
         int rc;
 
         /* Check the magic word */
-        st_readdw(ft, &magic);
+        sox_readdw(ft, &magic);
         if (magic == DEC_INV_MAGIC) {
                 /* Inverted headers are not standard.  Code was probably
                  * left over from pre-standardize period of testing for
@@ -165,37 +165,37 @@
                  * endianess.  Its not hurting though.
                  */
                 ft->signal.reverse_bytes = !ft->signal.reverse_bytes;
-                st_debug("Found inverted DEC magic word.  Swapping bytes.");
+                sox_debug("Found inverted DEC magic word.  Swapping bytes.");
         }
         else if (magic == SUN_INV_MAGIC) {
                 ft->signal.reverse_bytes = !ft->signal.reverse_bytes;
-                st_debug("Found inverted Sun/NeXT magic word. Swapping bytes.");
+                sox_debug("Found inverted Sun/NeXT magic word. Swapping bytes.");
         }
         else if (magic == SUN_MAGIC) {
-                st_debug("Found Sun/NeXT magic word");
+                sox_debug("Found Sun/NeXT magic word");
         }
         else if (magic == DEC_MAGIC) {
-                st_debug("Found DEC magic word");
+                sox_debug("Found DEC magic word");
         }
         else
         {
-                st_fail_errno(ft,ST_EHDR,"Did not detect valid Sun/NeXT/DEC magic number in header.");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"Did not detect valid Sun/NeXT/DEC magic number in header.");
+                return(SOX_EOF);
         }
 
         /* Read the header size */
-        st_readdw(ft, &hdr_size);
+        sox_readdw(ft, &hdr_size);
         if (hdr_size < SUN_HDRSIZE)
         {
-                st_fail_errno(ft,ST_EHDR,"Sun/NeXT header size too small.");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"Sun/NeXT header size too small.");
+                return(SOX_EOF);
         }
 
         /* Read the data size; may be ~0 meaning unspecified */
-        st_readdw(ft, &data_size);
+        sox_readdw(ft, &data_size);
 
         /* Read the encoding; there are some more possibilities */
-        st_readdw(ft, &encoding);
+        sox_readdw(ft, &encoding);
 
 
         /* Translate the encoding into encoding and size parameters */
@@ -203,11 +203,11 @@
         p->dec_routine = NULL;
         p->in_buffer = 0;
         p->in_bits = 0;
-        if(st_auencodingandsize(encoding, &(ft->signal.encoding),
-                             &(ft->signal.size)) == ST_EOF)
+        if(sox_auencodingandsize(encoding, &(ft->signal.encoding),
+                             &(ft->signal.size)) == SOX_EOF)
         {
-            st_fail_errno(ft,ST_EFMT,"Unsupported encoding in Sun/NeXT header.\nOnly U-law, signed bytes, signed words, ADPCM, and 32-bit floats are supported.");
-            return(ST_EOF);
+            sox_fail_errno(ft,SOX_EFMT,"Unsupported encoding in Sun/NeXT header.\nOnly U-law, signed bytes, signed words, ADPCM, and 32-bit floats are supported.");
+            return(SOX_EOF);
         }
         switch (encoding) {
         case SUN_G721:
@@ -229,18 +229,18 @@
 
 
         /* Read the sampling rate */
-        st_readdw(ft, &sample_rate);
+        sox_readdw(ft, &sample_rate);
         if (ft->signal.rate == 0 || ft->signal.rate == sample_rate)
             ft->signal.rate = sample_rate;
         else
-            st_report("User options overriding rate read in .au header");
+            sox_report("User options overriding rate read in .au header");
 
         /* Read the number of channels */
-        st_readdw(ft, &channels);
+        sox_readdw(ft, &channels);
         if (ft->signal.channels == 0 || ft->signal.channels == channels)
             ft->signal.channels = channels;
         else
-            st_report("User options overriding channels read in .au header");
+            sox_report("User options overriding channels read in .au header");
 
 
         /* Skip the info string in header; print it if verbose */
@@ -250,11 +250,11 @@
                 buf = (char *) xmalloc(hdr_size+1);
                 
                 for(i = 0; i < hdr_size; i++) {
-                        st_readb(ft, (unsigned char *)&(buf[i]));
-                        if (st_eof(ft))
+                        sox_readb(ft, (unsigned char *)&(buf[i]));
+                        if (sox_eof(ft))
                         {
-                                st_fail_errno(ft,ST_EOF,"Unexpected EOF in Sun/NeXT header info.");
-                                return(ST_EOF);
+                                sox_fail_errno(ft,SOX_EOF,"Unexpected EOF in Sun/NeXT header info.");
+                                return(SOX_EOF);
                         }
                 }
                 /* Buffer should already be null terminated but
@@ -270,14 +270,14 @@
         /* Needed for seeking */
         ft->length = data_size/ft->signal.size;
         if(ft->seekable)
-                p->dataStart = st_tell(ft);
+                p->dataStart = sox_tell(ft);
 
         /* Needed for rawread() */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* When writing, the header is supposed to contain the number of
@@ -289,19 +289,19 @@
    if it is not, the unspecified size remains in the header
    (this is legal). */
 
-static int st_austartwrite(ft_t ft) 
+static int sox_austartwrite(ft_t ft) 
 {
         au_t p = (au_t ) ft->priv;
         int rc;
 
         /* Needed because of rawwrite(); */
-        rc = st_rawstartwrite(ft);
+        rc = sox_rawstartwrite(ft);
         if (rc)
             return rc;
 
         p->data_size = 0;
         auwriteheader(ft, SUN_UNSPEC);
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*
@@ -315,7 +315,7 @@
         unsigned char           in_byte;
 
         if (p->in_bits < p->dec_bits) {
-                if (st_readb(ft, &in_byte) == ST_EOF) {
+                if (sox_readb(ft, &in_byte) == SOX_EOF) {
                         *code = 0;
                         return (-1);
                 }
@@ -328,16 +328,16 @@
         return (p->in_bits > 0);
 }
 
-static st_size_t st_auread(ft_t ft, st_sample_t *buf, st_size_t samp)
+static sox_size_t sox_auread(ft_t ft, sox_sample_t *buf, sox_size_t samp)
 {
         au_t p = (au_t ) ft->priv;
         unsigned char code;
         int done;
         if (p->dec_routine == NULL)
-                return st_rawread(ft, buf, samp);
+                return sox_rawread(ft, buf, samp);
         done = 0;
         while (samp > 0 && unpack_input(ft, &code) >= 0) {
-                *buf++ = ST_SIGNED_WORD_TO_SAMPLE(
+                *buf++ = SOX_SIGNED_WORD_TO_SAMPLE(
                         (*p->dec_routine)(code, AUDIO_ENCODING_LINEAR,
                                           &p->state),);
                 samp--;
@@ -346,14 +346,14 @@
         return done;
 }
 
-static st_size_t st_auwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static sox_size_t sox_auwrite(ft_t ft, const sox_sample_t *buf, sox_size_t samp)
 {
         au_t p = (au_t ) ft->priv;
         p->data_size += samp * ft->signal.size;
-        return(st_rawwrite(ft, buf, samp));
+        return(sox_rawwrite(ft, buf, samp));
 }
 
-static int st_austopwrite(ft_t ft)
+static int sox_austopwrite(ft_t ft)
 {
         au_t p = (au_t ) ft->priv;
         int rc;
@@ -361,7 +361,7 @@
         /* Needed because of rawwrite(). Do now to flush
          * data before seeking around below.
          */
-        rc = st_rawstopwrite(ft);
+        rc = sox_rawstopwrite(ft);
         if (rc)
             return rc;
 
@@ -368,38 +368,38 @@
         /* Attempt to update header */
         if (ft->seekable)
         {
-          if (st_seeki(ft, 0, 0) != 0)
+          if (sox_seeki(ft, 0, 0) != 0)
           {
-                st_fail_errno(ft,errno,"Can't rewind output file to rewrite Sun header.");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"Can't rewind output file to rewrite Sun header.");
+                return(SOX_EOF);
           }
           auwriteheader(ft, p->data_size);
         }
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
-static int st_ausunencoding(int size, int encoding)
+static int sox_ausunencoding(int size, int encoding)
 {
         int sun_encoding;
 
-        if (encoding == ST_ENCODING_ULAW && size == ST_SIZE_BYTE)
+        if (encoding == SOX_ENCODING_ULAW && size == SOX_SIZE_BYTE)
                 sun_encoding = SUN_ULAW;
-        else if (encoding == ST_ENCODING_ALAW && size == ST_SIZE_BYTE)
+        else if (encoding == SOX_ENCODING_ALAW && size == SOX_SIZE_BYTE)
                 sun_encoding = SUN_ALAW;
-        else if (encoding == ST_ENCODING_SIGN2 && size == ST_SIZE_BYTE)
+        else if (encoding == SOX_ENCODING_SIGN2 && size == SOX_SIZE_BYTE)
                 sun_encoding = SUN_LIN_8;
-        else if (encoding == ST_ENCODING_SIGN2 && size == ST_SIZE_16BIT)
+        else if (encoding == SOX_ENCODING_SIGN2 && size == SOX_SIZE_16BIT)
                 sun_encoding = SUN_LIN_16;
-        else if (encoding == ST_ENCODING_SIGN2 && size == ST_SIZE_24BIT)
+        else if (encoding == SOX_ENCODING_SIGN2 && size == SOX_SIZE_24BIT)
                 sun_encoding = SUN_LIN_24;
-        else if (encoding == ST_ENCODING_FLOAT && size == ST_SIZE_32BIT)
+        else if (encoding == SOX_ENCODING_FLOAT && size == SOX_SIZE_32BIT)
                 sun_encoding = SUN_FLOAT;
         else
-                sun_encoding = ST_ENCODING_UNKNOWN;
+                sun_encoding = SOX_ENCODING_UNKNOWN;
         return sun_encoding;
 }
 
-static void auwriteheader(ft_t ft, st_size_t data_size)
+static void auwriteheader(ft_t ft, sox_size_t data_size)
 {
         uint32_t magic;
         uint32_t hdr_size;
@@ -409,18 +409,18 @@
         int   x;
         int   comment_size;
 
-        if ((encoding = st_ausunencoding(ft->signal.size, ft->signal.encoding)) == -1) {
-                st_report("Unsupported output encoding/size for Sun/NeXT header or .AU format not specified.");
-                st_report("Only U-law, A-law, and signed bytes/words/tri-bytes are supported.");
-                st_report("Defaulting to 8khz u-law");
+        if ((encoding = sox_ausunencoding(ft->signal.size, ft->signal.encoding)) == -1) {
+                sox_report("Unsupported output encoding/size for Sun/NeXT header or .AU format not specified.");
+                sox_report("Only U-law, A-law, and signed bytes/words/tri-bytes are supported.");
+                sox_report("Defaulting to 8khz u-law");
                 encoding = SUN_ULAW;
-                ft->signal.encoding = ST_ENCODING_ULAW;
-                ft->signal.size = ST_SIZE_BYTE;
+                ft->signal.encoding = SOX_ENCODING_ULAW;
+                ft->signal.size = SOX_SIZE_BYTE;
                 ft->signal.rate = 8000;  /* strange but true */
         }
 
         magic = SUN_MAGIC;
-        st_writedw(ft, magic);
+        sox_writedw(ft, magic);
 
         /* Info field is at least 4 bytes. Here I force it to something
          * useful when there is no comments.
@@ -436,26 +436,26 @@
 
         hdr_size += comment_size;
 
-        st_writedw(ft, hdr_size);
+        sox_writedw(ft, hdr_size);
 
-        st_writedw(ft, data_size);
+        sox_writedw(ft, data_size);
 
-        st_writedw(ft, encoding);
+        sox_writedw(ft, encoding);
 
         sample_rate = ft->signal.rate;
-        st_writedw(ft, sample_rate);
+        sox_writedw(ft, sample_rate);
 
         channels = ft->signal.channels;
-        st_writedw(ft, channels);
+        sox_writedw(ft, channels);
 
-        st_writes(ft, ft->comment);
+        sox_writes(ft, ft->comment);
 
         /* Info must be 4 bytes at least and null terminated. */
         x = strlen(ft->comment);
         for (;x < 3; x++)
-            st_writeb(ft, 0);
+            sox_writeb(ft, 0);
 
-        st_writeb(ft, 0);
+        sox_writeb(ft, 0);
 }
 
 /* SPARC .au w/header */
@@ -465,20 +465,20 @@
   NULL
 };
 
-static st_format_t st_au_format = {
+static sox_format_t sox_au_format = {
   aunames,
   NULL,
-  ST_FILE_SEEK | ST_FILE_BIG_END,
-  st_austartread,
-  st_auread,
-  st_rawstopread,
-  st_austartwrite,
-  st_auwrite,
-  st_austopwrite,
-  st_auseek
+  SOX_FILE_SEEK | SOX_FILE_BIG_END,
+  sox_austartread,
+  sox_auread,
+  sox_rawstopread,
+  sox_austartwrite,
+  sox_auwrite,
+  sox_austopwrite,
+  sox_auseek
 };
 
-const st_format_t *st_au_format_fn(void)
+const sox_format_t *sox_au_format_fn(void)
 {
-    return &st_au_format;
+    return &sox_au_format;
 }
--- a/src/auto.c
+++ b/src/auto.c
@@ -14,7 +14,7 @@
  * used any more -- but this is just laziness on my part.) 
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <string.h>
 
 #if defined(DOS) || defined(WIN32)
@@ -23,7 +23,7 @@
 #define LASTCHAR '/'
 #endif
 
-static int st_autostartread(ft_t ft)
+static int sox_autostartread(ft_t ft)
 {
     char *type = NULL;
     char header[256];
@@ -38,7 +38,7 @@
          * file.  So we start checking for those filetypes first.
          */
         memset(header,0,4);
-        if (st_readbuf(ft, header, 1, 4) == 4)
+        if (sox_readbuf(ft, header, 1, 4) == 4)
         {
             /* Look for .snd or dns. header of AU files */
             if ((strncmp(header, ".snd", 4) == 0) ||
@@ -51,7 +51,7 @@
             else if (strncmp(header, "FORM", 4) == 0) 
             {
                 /* Need to read more data to see what type of FORM file */
-                if (st_readbuf(ft, header, 1, 8) == 8)
+                if (sox_readbuf(ft, header, 1, 8) == 8)
                 {
                     if (strncmp(header + 4, "AIFF", 4) == 0)
                         type = "aiff";
@@ -65,13 +65,13 @@
             }
             else if (strncmp(header, "RIFF", 4) == 0)
             {
-                if (st_readbuf(ft, header, 1, 8) == 8)
+                if (sox_readbuf(ft, header, 1, 8) == 8)
                     if (strncmp(header + 4, "WAVE", 4) == 0)
                         type = "wav";
             }
             else if (strncmp(header, "Crea", 4) == 0) 
             {
-                if (st_readbuf(ft, header, 1, 15) == 15)
+                if (sox_readbuf(ft, header, 1, 15) == 15)
                     if (strncmp(header, "tive Voice File", 15) == 0) 
                         type = "voc";
             }
@@ -78,10 +78,10 @@
             else if (strncmp(header, "SOUN", 4) == 0)
             {
                 /* Check for SOUND magic header */
-                if (st_readbuf(ft, header, 1, 1) == 1 && *header == 'D')
+                if (sox_readbuf(ft, header, 1, 1) == 1 && *header == 'D')
                 {
                     /* Once we've found SOUND see if its smp or sndt */
-                    if (st_readbuf(ft, header, 1, 12) == 12)
+                    if (sox_readbuf(ft, header, 1, 12) == 12)
                     {
                         if (strncmp(header, " SAMPLE DATA", 12) == 0)
                             type = "smp";
@@ -96,13 +96,13 @@
                 type = "avr";
             else if (strncmp(header, "NIST", 4) == 0) 
             {
-                if (st_readbuf(ft, header, 1, 3) == 3)
+                if (sox_readbuf(ft, header, 1, 3) == 3)
                     if (strncmp(header, "_1A", 3) == 0) 
                         type = "sph";
             }
             else if (strncmp(header, "ALaw", 4) == 0)
             {
-                if (st_readbuf(ft, header, 1, 11) == 11)
+                if (sox_readbuf(ft, header, 1, 11) == 11)
                     if (strncmp(header, "SoundFile**", 11) == 0)
                         type = "wve";
             }
@@ -122,26 +122,26 @@
         if (type == NULL)
         {
             for (loop = 0; loop < 60; loop++)
-                if (st_readbuf(ft, header, 1, 1) != 1)
+                if (sox_readbuf(ft, header, 1, 1) != 1)
                     break;
-            if (st_readbuf(ft, header, 1, 4) == 4 && 
+            if (sox_readbuf(ft, header, 1, 4) == 4 && 
                 strncmp(header, "FSSD", 4) == 0)
             {
                 for (loop = 0; loop < 62; loop++)
-                    if (st_readbuf(ft, header, 1, 1) != 1)
+                    if (sox_readbuf(ft, header, 1, 1) != 1)
                         break;
-                if (st_readbuf(ft, header, 1, 4) == 0 && 
+                if (sox_readbuf(ft, header, 1, 4) == 0 && 
                     strncmp(header, "HCOM", 4) == 0)
                     type = "hcom";
             }
         }
 
-        st_rewind(ft);
+        sox_rewind(ft);
 
         if (type == NULL) {
           if (prc_checkheader(ft, header))
             type = "prc";
-          st_rewind(ft);
+          sox_rewind(ft);
         }        
     } /* if (seekable) */
 
@@ -163,27 +163,27 @@
 
     if (type == NULL)
     {
-        st_fail_errno(ft,ST_EFMT, "Could not determine file type.");
-        return (ST_EOF);
+        sox_fail_errno(ft,SOX_EFMT, "Could not determine file type.");
+        return (SOX_EOF);
     }
     free(ft->filetype);
     ft->filetype = strdup(type);
-    rc = st_gettype(ft, st_true); /* Change ft->h to the new format */
-    if(rc != ST_SUCCESS)
+    rc = sox_gettype(ft, sox_true); /* Change ft->h to the new format */
+    if(rc != SOX_SUCCESS)
     {
-        st_fail_errno(ft,ST_EFMT,"Do not understand format type: %s",type);
+        sox_fail_errno(ft,SOX_EFMT,"Do not understand format type: %s",type);
         return (rc);
     }
 
-    st_debug("Detected file format type: %s", type);
+    sox_debug("Detected file format type: %s", type);
     set_endianness_if_not_already_set(ft);
     return (* ft->h->startread)(ft);
 }
 
-static int st_autostartwrite(ft_t ft) 
+static int sox_autostartwrite(ft_t ft) 
 {
-        st_fail_errno(ft,ST_EFMT,"Type AUTO can only be used for input!");
-        return(ST_EOF);
+        sox_fail_errno(ft,SOX_EFMT,"Type AUTO can only be used for input!");
+        return(SOX_EOF);
 }
 
 static const char *autonames[] = {
@@ -191,20 +191,20 @@
   NULL
 };
 
-static st_format_t st_auto_format = {
+static sox_format_t sox_auto_format = {
   autonames,
   NULL,
-  ST_FILE_DEVICE | ST_FILE_PHONY,
-  st_autostartread,
-  st_format_nothing_read_io,
-  st_format_nothing,
-  st_autostartwrite,
-  st_format_nothing_write_io,
-  st_format_nothing,
-  st_format_nothing_seek
+  SOX_FILE_DEVICE | SOX_FILE_PHONY,
+  sox_autostartread,
+  sox_format_nothing_read_io,
+  sox_format_nothing,
+  sox_autostartwrite,
+  sox_format_nothing_write_io,
+  sox_format_nothing,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_auto_format_fn(void)
+const sox_format_t *sox_auto_format_fn(void)
 {
-    return &st_auto_format;
+    return &sox_auto_format;
 }
--- a/src/avr.c
+++ b/src/avr.c
@@ -22,7 +22,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #define AVR_MAGIC "2BIT"
 
@@ -63,21 +63,21 @@
  */
 
 
-static int st_avrstartread(ft_t ft) 
+static int sox_avrstartread(ft_t ft) 
 {
   avr_t avr = (avr_t)ft->priv;
   int rc;
 
-  st_reads(ft, avr->magic, 4);
+  sox_reads(ft, avr->magic, 4);
 
   if (strncmp (avr->magic, AVR_MAGIC, 4)) {
-    st_fail_errno(ft,ST_EHDR,"AVR: unknown header");
-    return(ST_EOF);
+    sox_fail_errno(ft,SOX_EHDR,"AVR: unknown header");
+    return(SOX_EOF);
   }
 
-  st_readbuf(ft, avr->name, 1, sizeof(avr->name));
+  sox_readbuf(ft, avr->name, 1, sizeof(avr->name));
 
-  st_readw (ft, &(avr->mono));
+  sox_readw (ft, &(avr->mono));
   if (avr->mono) {
     ft->signal.channels = 2;
   }
@@ -85,31 +85,31 @@
     ft->signal.channels = 1;
   }
 
-  st_readw (ft, &(avr->rez));
+  sox_readw (ft, &(avr->rez));
   if (avr->rez == 8) {
-    ft->signal.size = ST_SIZE_BYTE;
+    ft->signal.size = SOX_SIZE_BYTE;
   }
   else if (avr->rez == 16) {
-    ft->signal.size = ST_SIZE_16BIT;
+    ft->signal.size = SOX_SIZE_16BIT;
   }
   else {
-    st_fail_errno(ft,ST_EFMT,"AVR: unsupported sample resolution");
-    return(ST_EOF);
+    sox_fail_errno(ft,SOX_EFMT,"AVR: unsupported sample resolution");
+    return(SOX_EOF);
   }
 
-  st_readw (ft, &(avr->sign));
+  sox_readw (ft, &(avr->sign));
   if (avr->sign) {
-    ft->signal.encoding = ST_ENCODING_SIGN2;
+    ft->signal.encoding = SOX_ENCODING_SIGN2;
   }
   else {
-    ft->signal.encoding = ST_ENCODING_UNSIGNED;
+    ft->signal.encoding = SOX_ENCODING_UNSIGNED;
   }
 
-  st_readw (ft, &(avr->loop));
+  sox_readw (ft, &(avr->loop));
 
-  st_readw (ft, &(avr->midi));
+  sox_readw (ft, &(avr->midi));
 
-  st_readdw (ft, &(avr->rate));
+  sox_readdw (ft, &(avr->rate));
   /*
    * No support for AVRs created by ST-Replay,
    * Replay Proffesional and PRO-Series 12.
@@ -118,144 +118,144 @@
    */
   ft->signal.rate = (avr->rate & 0x00ffffff);
 
-  st_readdw (ft, &(avr->size));
+  sox_readdw (ft, &(avr->size));
 
-  st_readdw (ft, &(avr->lbeg));
+  sox_readdw (ft, &(avr->lbeg));
 
-  st_readdw (ft, &(avr->lend));
+  sox_readdw (ft, &(avr->lend));
 
-  st_readw (ft, &(avr->res1));
+  sox_readw (ft, &(avr->res1));
 
-  st_readw (ft, &(avr->res2));
+  sox_readw (ft, &(avr->res2));
 
-  st_readw (ft, &(avr->res3));
+  sox_readw (ft, &(avr->res3));
 
-  st_readbuf(ft, avr->ext, 1, sizeof(avr->ext));
+  sox_readbuf(ft, avr->ext, 1, sizeof(avr->ext));
 
-  st_readbuf(ft, avr->user, 1, sizeof(avr->user));
+  sox_readbuf(ft, avr->user, 1, sizeof(avr->user));
 
-  rc = st_rawstartread (ft);
+  rc = sox_rawstartread (ft);
   if (rc)
       return rc;
 
-  return(ST_SUCCESS);
+  return(SOX_SUCCESS);
 }
 
-static int st_avrstartwrite(ft_t ft) 
+static int sox_avrstartwrite(ft_t ft) 
 {
   avr_t avr = (avr_t)ft->priv;
   int rc;
 
   if (!ft->seekable) {
-    st_fail_errno(ft,ST_EOF,"AVR: file is not seekable");
-    return(ST_EOF);
+    sox_fail_errno(ft,SOX_EOF,"AVR: file is not seekable");
+    return(SOX_EOF);
   }
 
-  rc = st_rawstartwrite (ft);
+  rc = sox_rawstartwrite (ft);
   if (rc)
       return rc;
 
   /* magic */
-  st_writes(ft, AVR_MAGIC);
+  sox_writes(ft, AVR_MAGIC);
 
   /* name */
-  st_writeb(ft, 0);
-  st_writeb(ft, 0);
-  st_writeb(ft, 0);
-  st_writeb(ft, 0);
-  st_writeb(ft, 0);
-  st_writeb(ft, 0);
-  st_writeb(ft, 0);
-  st_writeb(ft, 0);
+  sox_writeb(ft, 0);
+  sox_writeb(ft, 0);
+  sox_writeb(ft, 0);
+  sox_writeb(ft, 0);
+  sox_writeb(ft, 0);
+  sox_writeb(ft, 0);
+  sox_writeb(ft, 0);
+  sox_writeb(ft, 0);
 
   /* mono */
   if (ft->signal.channels == 1) {
-    st_writew (ft, 0);
+    sox_writew (ft, 0);
   }
   else if (ft->signal.channels == 2) {
-    st_writew (ft, 0xffff);
+    sox_writew (ft, 0xffff);
   }
   else {
-    st_fail_errno(ft,ST_EFMT,"AVR: number of channels not supported");
+    sox_fail_errno(ft,SOX_EFMT,"AVR: number of channels not supported");
     return(0);
   }
 
   /* rez */
-  if (ft->signal.size == ST_SIZE_BYTE) {
-    st_writew (ft, 8);
+  if (ft->signal.size == SOX_SIZE_BYTE) {
+    sox_writew (ft, 8);
   }
-  else if (ft->signal.size == ST_SIZE_16BIT) {
-    st_writew (ft, 16);
+  else if (ft->signal.size == SOX_SIZE_16BIT) {
+    sox_writew (ft, 16);
   }
   else {
-    st_fail_errno(ft,ST_EFMT,"AVR: unsupported sample resolution");
-    return(ST_EOF);
+    sox_fail_errno(ft,SOX_EFMT,"AVR: unsupported sample resolution");
+    return(SOX_EOF);
   }
 
   /* sign */
-  if (ft->signal.encoding == ST_ENCODING_SIGN2) {
-    st_writew (ft, 0xffff);
+  if (ft->signal.encoding == SOX_ENCODING_SIGN2) {
+    sox_writew (ft, 0xffff);
   }
-  else if (ft->signal.encoding == ST_ENCODING_UNSIGNED) {
-    st_writew (ft, 0);
+  else if (ft->signal.encoding == SOX_ENCODING_UNSIGNED) {
+    sox_writew (ft, 0);
   }
   else {
-    st_fail_errno(ft,ST_EFMT,"AVR: unsupported encoding");
-    return(ST_EOF);
+    sox_fail_errno(ft,SOX_EFMT,"AVR: unsupported encoding");
+    return(SOX_EOF);
   }
 
   /* loop */
-  st_writew (ft, 0xffff);
+  sox_writew (ft, 0xffff);
 
   /* midi */
-  st_writew (ft, 0xffff);
+  sox_writew (ft, 0xffff);
 
   /* rate */
-  st_writedw (ft, ft->signal.rate);
+  sox_writedw (ft, ft->signal.rate);
 
   /* size */
   /* Don't know the size yet. */
-  st_writedw (ft, 0);
+  sox_writedw (ft, 0);
 
   /* lbeg */
-  st_writedw (ft, 0);
+  sox_writedw (ft, 0);
 
   /* lend */
   /* Don't know the size yet, so we can't set lend, either. */
-  st_writedw (ft, 0);
+  sox_writedw (ft, 0);
 
   /* res1 */
-  st_writew (ft, 0);
+  sox_writew (ft, 0);
 
   /* res2 */
-  st_writew (ft, 0);
+  sox_writew (ft, 0);
 
   /* res3 */
-  st_writew (ft, 0);
+  sox_writew (ft, 0);
 
   /* ext */
-  st_writebuf(ft, (void *)"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 1, sizeof(avr->ext));
+  sox_writebuf(ft, (void *)"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 1, sizeof(avr->ext));
 
   /* user */
-  st_writebuf(ft, 
+  sox_writebuf(ft, 
            (void *)"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
            "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
            "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
            "\0\0\0\0", 1, sizeof (avr->user));
 
-  return(ST_SUCCESS);
+  return(SOX_SUCCESS);
 }
 
-static st_size_t st_avrwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp) 
+static sox_size_t sox_avrwrite(ft_t ft, const sox_sample_t *buf, sox_size_t nsamp) 
 {
   avr_t avr = (avr_t)ft->priv;
 
   avr->size += nsamp;
 
-  return (st_rawwrite (ft, buf, nsamp));
+  return (sox_rawwrite (ft, buf, nsamp));
 }
 
-static int st_avrstopwrite(ft_t ft) 
+static int sox_avrstopwrite(ft_t ft) 
 {
   avr_t avr = (avr_t)ft->priv;
   int rc;
@@ -262,19 +262,19 @@
 
   int size = avr->size / ft->signal.channels;
 
-  rc = st_rawstopwrite(ft);
+  rc = sox_rawstopwrite(ft);
   if (rc)
       return rc;
 
   /* Fix size */
-  st_seeki(ft, 26, SEEK_SET);
-  st_writedw (ft, size);
+  sox_seeki(ft, 26, SEEK_SET);
+  sox_writedw (ft, size);
 
   /* Fix lend */
-  st_seeki(ft, 34, SEEK_SET);
-  st_writedw (ft, size);
+  sox_seeki(ft, 34, SEEK_SET);
+  sox_writedw (ft, size);
 
-  return(ST_SUCCESS);
+  return(SOX_SUCCESS);
 }
 
 static const char *avrnames[] = {
@@ -282,20 +282,20 @@
   NULL
 };
 
-static st_format_t st_avr_format = {
+static sox_format_t sox_avr_format = {
   avrnames,
   NULL,
-  ST_FILE_BIG_END,
-  st_avrstartread,
-  st_rawread,
-  st_format_nothing,
-  st_avrstartwrite,
-  st_avrwrite,
-  st_avrstopwrite,
-  st_format_nothing_seek
+  SOX_FILE_BIG_END,
+  sox_avrstartread,
+  sox_rawread,
+  sox_format_nothing,
+  sox_avrstartwrite,
+  sox_avrwrite,
+  sox_avrstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_avr_format_fn(void)
+const sox_format_t *sox_avr_format_fn(void)
 {
-    return &st_avr_format;
+    return &sox_avr_format;
 }
--- a/src/biquad.c
+++ b/src/biquad.c
@@ -31,7 +31,7 @@
 static char const all_width_types[] = "hboqs";
 
 
-int st_biquad_getopts(eff_t effp, int n, char **argv,
+int sox_biquad_getopts(eff_t effp, int n, char **argv,
     int min_args, int max_args, int fc_pos, int width_pos, int gain_pos,
     char const * allowed_width_types, filter_t filter_type)
 {
@@ -45,17 +45,17 @@
       (n > width_pos && ((unsigned)(sscanf(argv[width_pos], "%lf%c %c", &p->width, &width_type, &dummy)-1) > 1 || p->width <= 0)) ||
       (n > gain_pos  && sscanf(argv[gain_pos], "%lf %c", &p->gain, &dummy) != 1) ||
       !strchr(allowed_width_types, width_type) || (width_type == 's' && p->width > 1)) {
-    st_fail(effp->h->usage);
-    return ST_EOF;
+    sox_fail(effp->h->usage);
+    return SOX_EOF;
   }
   p->width_type = strchr(all_width_types, width_type) - all_width_types;
   if (p->width_type >= strlen(all_width_types))
     p->width_type = 0;
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
-int st_biquad_start(eff_t effp)
+int sox_biquad_start(eff_t effp)
 {
   biquad_t p = (biquad_t) effp->priv;
 
@@ -82,19 +82,19 @@
       , effp->ininfo.rate, effp->ininfo.rate
       , p->b0, p->b1, p->b2, p->a1, p->a2
       );
-    return ST_EOF;
+    return SOX_EOF;
   }
 
   p->o2 = p->o1 = p->i2 = p-> i1 = 0;
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
-int st_biquad_flow(eff_t effp, const st_sample_t *ibuf,
-    st_sample_t *obuf, st_size_t *isamp, st_size_t *osamp)
+int sox_biquad_flow(eff_t effp, const sox_sample_t *ibuf,
+    sox_sample_t *obuf, sox_size_t *isamp, sox_size_t *osamp)
 {
   biquad_t p = (biquad_t) effp->priv;
-  st_size_t len = (*isamp > *osamp)? *osamp : *isamp;
+  sox_size_t len = (*isamp > *osamp)? *osamp : *isamp;
   *isamp = *osamp = len;
 
   while (len--)
@@ -102,7 +102,7 @@
     double o0 = *ibuf*p->b0 +p->i1*p->b1 +p->i2*p->b2 -p->o1*p->a1 -p->o2*p->a2;
     p->i2 = p->i1, p->i1 = *ibuf++;
     p->o2 = p->o1, p->o1 = o0;
-    *obuf++ = ST_ROUND_CLIP_COUNT(o0, effp->clips);
+    *obuf++ = SOX_ROUND_CLIP_COUNT(o0, effp->clips);
   }
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
--- a/src/biquad.h
+++ b/src/biquad.h
@@ -19,7 +19,7 @@
 #ifndef biquad_included
 #define biquad_included
 
-#include "st_i.h"
+#include "sox_i.h"
 
 
 typedef enum {
@@ -66,22 +66,22 @@
   double b2, b1, b0;       /* Filter coefficients */
   double a2, a1, a0;       /* Filter coefficients */
 
-  st_sample_t i1, i2;      /* Filter memory */
+  sox_sample_t i1, i2;      /* Filter memory */
   double      o1, o2;      /* Filter memory */
 } * biquad_t;
 
 
-assert_static(sizeof(struct biquad) <= ST_MAX_EFFECT_PRIVSIZE, 
+assert_static(sizeof(struct biquad) <= SOX_MAX_EFFECT_PRIVSIZE, 
     /* else */ biquad_PRIVSIZE_too_big);
 
-int st_biquad_getopts(eff_t effp, int n, char **argv,
+int sox_biquad_getopts(eff_t effp, int n, char **argv,
     int min_args, int max_args, int fc_pos, int width_pos, int gain_pos,
     char const * allowed_width_types, filter_t filter_type);
-int st_biquad_start(eff_t effp);
-int st_biquad_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                        st_size_t *isamp, st_size_t *osamp);
+int sox_biquad_start(eff_t effp);
+int sox_biquad_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                        sox_size_t *isamp, sox_size_t *osamp);
 
-#undef st_fail
-#define st_fail st_message_filename=effp->name,st_fail
+#undef sox_fail
+#define sox_fail sox_message_filename=effp->name,sox_fail
 
 #endif
--- a/src/biquads.c
+++ b/src/biquads.c
@@ -65,7 +65,7 @@
 
 
 static int hilo1_getopts(eff_t effp, int n, char **argv) {
-  return st_biquad_getopts(effp, n, argv, 1, 1, 0, 1, 2, "",
+  return sox_biquad_getopts(effp, n, argv, 1, 1, 0, 1, 2, "",
       *effp->name == 'l'? filter_LPF_1 : filter_HPF_1);
 }
 
@@ -77,7 +77,7 @@
   if (n != 0 && strcmp(argv[0], "-2") == 0)
     ++argv, --n;
   p->width = sqrt(0.5); /* Default to Butterworth */
-  return st_biquad_getopts(effp, n, argv, 1, 2, 0, 1, 2, "qoh",
+  return sox_biquad_getopts(effp, n, argv, 1, 2, 0, 1, 2, "qoh",
       *effp->name == 'l'? filter_LPF : filter_HPF);
 }
 
@@ -86,12 +86,12 @@
   filter_t type = filter_BPF;
   if (n != 0 && strcmp(argv[0], "-c") == 0)
     ++argv, --n, type = filter_BPF_CSG;
-  return st_biquad_getopts(effp, n, argv, 2, 2, 0, 1, 2, "hqob", type);
+  return sox_biquad_getopts(effp, n, argv, 2, 2, 0, 1, 2, "hqob", type);
 }
 
 
 static int bandrej_getopts(eff_t effp, int n, char **argv) {
-  return st_biquad_getopts(effp, n, argv, 2, 2, 0, 1, 2, "hqob", filter_notch);
+  return sox_biquad_getopts(effp, n, argv, 2, 2, 0, 1, 2, "hqob", filter_notch);
 }
 
 
@@ -103,7 +103,7 @@
   else if (n != 0 && strcmp(argv[0], "-2") == 0)
     ++argv, --n, type = filter_AP2;
   m = 1 + (type == filter_APF);
-  return st_biquad_getopts(effp, n, argv, m, m, 0, 1, 2, "hqo", type);
+  return sox_biquad_getopts(effp, n, argv, m, m, 0, 1, 2, "hqo", type);
 }
 
 
@@ -111,13 +111,13 @@
   biquad_t p = (biquad_t) effp->priv;
   p->width = 0.5;
   p->fc = *effp->name == 'b'? 100 : 3000;
-  return st_biquad_getopts(effp, n, argv, 1, 3, 1, 2, 0, "shqo",
+  return sox_biquad_getopts(effp, n, argv, 1, 3, 1, 2, 0, "shqo",
       *effp->name == 'b'?  filter_lowShelf: filter_highShelf);
 }
 
 
 static int equalizer_getopts(eff_t effp, int n, char **argv) {
-  return st_biquad_getopts(effp, n, argv, 3, 3, 0, 1, 2, "qoh", filter_peakingEQ);
+  return sox_biquad_getopts(effp, n, argv, 3, 3, 0, 1, 2, "qoh", filter_peakingEQ);
 }
 
 
@@ -125,12 +125,12 @@
   filter_t type = filter_BPF_SPK;
   if (n != 0 && strcmp(argv[0], "-n") == 0)
     ++argv, --n, type = filter_BPF_SPK_N;
-  return st_biquad_getopts(effp, n, argv, 1, 2, 0, 1, 2, "hqo", type);
+  return sox_biquad_getopts(effp, n, argv, 1, 2, 0, 1, 2, "hqo", type);
 }
 
 
 static int deemph_getopts(eff_t effp, int n, char **argv) {
-  return st_biquad_getopts(effp, n, argv, 0, 0, 0, 1, 2, "", filter_deemph);
+  return sox_biquad_getopts(effp, n, argv, 0, 0, 0, 1, 2, "", filter_deemph);
 }
 
 
@@ -142,8 +142,8 @@
   double alpha = 0;
 
   if (w0 > M_PI) {
-    st_fail("frequency must be less than half the sample-rate (Nyquist rate)");
-    return ST_EOF;
+    sox_fail("frequency must be less than half the sample-rate (Nyquist rate)");
+    return SOX_EOF;
   }
   
   /* Set defaults: */
@@ -228,7 +228,7 @@
 
     case filter_peakingEQ: /* H(s) = (s^2 + s*(A/Q) + 1) / (s^2 + s/(A*Q) + 1) */
       if (A == 1)
-        return ST_EFF_NULL;
+        return SOX_EFF_NULL;
       p->b0 =   1 + alpha*A;
       p->b1 =  -2*cos(w0);
       p->b2 =   1 - alpha*A;
@@ -239,7 +239,7 @@
 
     case filter_lowShelf: /* H(s) = A * (s^2 + (sqrt(A)/Q)*s + A)/(A*s^2 + (sqrt(A)/Q)*s + 1) */
       if (A == 1)
-        return ST_EFF_NULL;
+        return SOX_EFF_NULL;
       p->b0 =    A*( (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha );
       p->b1 =  2*A*( (A-1) - (A+1)*cos(w0)                   );
       p->b2 =    A*( (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha );
@@ -250,7 +250,7 @@
 
     case filter_highShelf: /* H(s) = A * (A*s^2 + (sqrt(A)/Q)*s + 1)/(s^2 + (sqrt(A)/Q)*s + A) */
       if (!A)
-        return ST_EFF_NULL;
+        return SOX_EFF_NULL;
       p->b0 =    A*( (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha );
       p->b1 = -2*A*( (A-1) + (A+1)*cos(w0)                   );
       p->b2 =    A*( (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha );
@@ -301,21 +301,21 @@
       break;
     }
   }
-  return st_biquad_start(effp);
+  return sox_biquad_start(effp);
 }
 
 
 #define BIQUAD_EFFECT(name,group,usage,flags) \
-st_effect_t const * st_##name##_effect_fn(void) { \
-  static st_effect_t driver = { \
+sox_effect_t const * sox_##name##_effect_fn(void) { \
+  static sox_effect_t driver = { \
     #name, "Usage: " #name " " usage, flags, \
-    group##_getopts, start, st_biquad_flow, 0, 0, 0, \
+    group##_getopts, start, sox_biquad_flow, 0, 0, 0, \
   }; \
   return &driver; \
 }
 
-BIQUAD_EFFECT(highp,     hilo1,    "cutoff-frequency", ST_EFF_DEPRECATED)
-BIQUAD_EFFECT(lowp,      hilo1,    "cutoff-frequency", ST_EFF_DEPRECATED)
+BIQUAD_EFFECT(highp,     hilo1,    "cutoff-frequency", SOX_EFF_DEPRECATED)
+BIQUAD_EFFECT(lowp,      hilo1,    "cutoff-frequency", SOX_EFF_DEPRECATED)
 BIQUAD_EFFECT(highpass,  hilo2,    "[-1|-2] frequency [width[q|o|h]]", 0)
 BIQUAD_EFFECT(lowpass,   hilo2,    "[-1|-2] frequency [width[q|o|h]]", 0)
 BIQUAD_EFFECT(bandpass,  bandpass, "[-c] frequency width[h|q|o]", 0)
--- a/src/cdr.c
+++ b/src/cdr.c
@@ -22,13 +22,13 @@
  *
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #define SECTORSIZE      (2352 / 2)
 
 /* Private data for SKEL file */
 typedef struct cdrstuff {
-        st_size_t samples;      /* number of samples written */
+        sox_size_t samples;      /* number of samples written */
 } *cdr_t;
 
 /*
@@ -39,29 +39,29 @@
  *      mono/stereo/quad.
  */
 
-static int st_cdrstartread(ft_t ft) 
+static int sox_cdrstartread(ft_t ft) 
 {
         int rc;
 
         /* Needed because of rawread() */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
         ft->signal.rate = 44100;
-        ft->signal.size = ST_SIZE_16BIT;
-        ft->signal.encoding = ST_ENCODING_SIGN2;
+        ft->signal.size = SOX_SIZE_16BIT;
+        ft->signal.encoding = SOX_ENCODING_SIGN2;
         ft->signal.channels = 2;
         ft->comment = NULL;
 
 /* Need length for seeking */
         if(ft->seekable){
-                ft->length = st_filelength(ft)/ST_SIZE_16BIT;
+                ft->length = sox_filelength(ft)/SOX_SIZE_16BIT;
         } else {
                 ft->length = 0;
         }
         
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*
@@ -71,10 +71,10 @@
  * Return number of samples read.
  */
 
-static st_size_t st_cdrread(ft_t ft, st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_cdrread(ft_t ft, sox_sample_t *buf, sox_size_t len) 
 {
 
-        return st_rawread(ft, buf, len);
+        return sox_rawread(ft, buf, len);
 }
 
 /*
@@ -81,19 +81,19 @@
  * Do anything required when you stop reading samples.  
  * Don't close input file! 
  */
-static int st_cdrstopread(ft_t ft) 
+static int sox_cdrstopread(ft_t ft) 
 {
         /* Needed because of rawread() */
-        return st_rawstopread(ft);
+        return sox_rawstopread(ft);
 }
 
-static int st_cdrstartwrite(ft_t ft) 
+static int sox_cdrstartwrite(ft_t ft) 
 {
         cdr_t cdr = (cdr_t) ft->priv;
         int rc;
 
         /* Needed because of rawwrite() */
-        rc = st_rawstartwrite(ft);
+        rc = sox_rawstartwrite(ft);
         if (rc)
             return rc;
 
@@ -100,20 +100,20 @@
         cdr->samples = 0;
 
         ft->signal.rate = 44100;
-        ft->signal.size = ST_SIZE_16BIT;
-        ft->signal.encoding = ST_ENCODING_SIGN2;
+        ft->signal.size = SOX_SIZE_16BIT;
+        ft->signal.encoding = SOX_ENCODING_SIGN2;
         ft->signal.channels = 2;
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
-static st_size_t st_cdrwrite(ft_t ft, const st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_cdrwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len) 
 {
         cdr_t cdr = (cdr_t) ft->priv;
 
         cdr->samples += len;
 
-        return st_rawwrite(ft, buf, len);
+        return sox_rawwrite(ft, buf, len);
 }
 
 /*
@@ -121,7 +121,7 @@
  * samples.  We write -32768 for each sample to pad it out.
  */
 
-static int st_cdrstopwrite(ft_t ft) 
+static int sox_cdrstopwrite(ft_t ft) 
 {
         cdr_t cdr = (cdr_t) ft->priv;
         int padsamps = SECTORSIZE - (cdr->samples % SECTORSIZE);
@@ -129,7 +129,7 @@
         int rc;
 
         /* Flush buffer before writing anything else */
-        rc = st_rawstopwrite(ft);
+        rc = sox_rawstopwrite(ft);
 
         if (rc)
             return rc;
@@ -139,11 +139,11 @@
         if (padsamps != SECTORSIZE) 
         {
                 while (padsamps > 0) {
-                        st_writew(ft, zero);
+                        sox_writew(ft, zero);
                         padsamps--;
                 }
         }
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 static const char *cdrnames[] = {
@@ -152,20 +152,20 @@
   NULL
 };
 
-static st_format_t st_cdr_format = {
+static sox_format_t sox_cdr_format = {
   cdrnames,
   NULL,
-  ST_FILE_SEEK | ST_FILE_BIG_END,
-  st_cdrstartread,
-  st_cdrread,
-  st_cdrstopread,
-  st_cdrstartwrite,
-  st_cdrwrite,
-  st_cdrstopwrite,
-  st_rawseek
+  SOX_FILE_SEEK | SOX_FILE_BIG_END,
+  sox_cdrstartread,
+  sox_cdrread,
+  sox_cdrstopread,
+  sox_cdrstartwrite,
+  sox_cdrwrite,
+  sox_cdrstopwrite,
+  sox_rawseek
 };
 
-const st_format_t *st_cdr_format_fn(void)
+const sox_format_t *sox_cdr_format_fn(void)
 {
-    return &st_cdr_format;
+    return &sox_cdr_format;
 }
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -65,13 +65,13 @@
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
 #include <math.h>
 #include <string.h>
-#include "st_i.h"
+#include "sox_i.h"
 
 #define MOD_SINE        0
 #define MOD_TRIANGLE    1
 #define MAX_CHORUS      7
 
-static st_effect_t st_chorus_effect;
+static sox_effect_t sox_chorus_effect;
 
 typedef struct chorusstuff {
         int     num_chorus;
@@ -92,7 +92,7 @@
 /*
  * Process options
  */
-static int st_chorus_getopts(eff_t effp, int n, char **argv) 
+static int sox_chorus_getopts(eff_t effp, int n, char **argv) 
 {
         chorus_t chorus = (chorus_t) effp->priv;
         int i;
@@ -102,8 +102,8 @@
 
         if ( ( n < 7 ) || (( n - 2 ) % 5 ) )
         {
-            st_fail(st_chorus_effect.usage);
-            return (ST_EOF);
+            sox_fail(sox_chorus_effect.usage);
+            return (SOX_EOF);
         }
 
         sscanf(argv[i++], "%f", &chorus->in_gain);
@@ -111,8 +111,8 @@
         while ( i < n ) {
                 if ( chorus->num_chorus > MAX_CHORUS )
                 {
-                        st_fail("chorus: to many delays, use less than %i delays", MAX_CHORUS);
-                        return (ST_EOF);
+                        sox_fail("chorus: to many delays, use less than %i delays", MAX_CHORUS);
+                        return (SOX_EOF);
                 }
                 sscanf(argv[i++], "%f", &chorus->delay[chorus->num_chorus]);
                 sscanf(argv[i++], "%f", &chorus->decay[chorus->num_chorus]);
@@ -124,19 +124,19 @@
                         chorus->modulation[chorus->num_chorus] = MOD_TRIANGLE;
                 else
                 {
-                        st_fail(st_chorus_effect.usage);
-                        return (ST_EOF);
+                        sox_fail(sox_chorus_effect.usage);
+                        return (SOX_EOF);
                 }
                 i++;
                 chorus->num_chorus++;
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Prepare for processing.
  */
-static int st_chorus_start(eff_t effp)
+static int sox_chorus_start(eff_t effp)
 {
         chorus_t chorus = (chorus_t) effp->priv;
         int i;
@@ -146,18 +146,18 @@
 
         if ( chorus->in_gain < 0.0 )
         {
-                st_fail("chorus: gain-in must be positive!");
-                return (ST_EOF);
+                sox_fail("chorus: gain-in must be positive!");
+                return (SOX_EOF);
         }
         if ( chorus->in_gain > 1.0 )
         {
-                st_fail("chorus: gain-in must be less than 1.0!");
-                return (ST_EOF);
+                sox_fail("chorus: gain-in must be less than 1.0!");
+                return (SOX_EOF);
         }
         if ( chorus->out_gain < 0.0 )
         {
-                st_fail("chorus: gain-out must be positive!");
-                return (ST_EOF);
+                sox_fail("chorus: gain-out must be positive!");
+                return (SOX_EOF);
         }
         for ( i = 0; i < chorus->num_chorus; i++ ) {
                 chorus->samples[i] = (int) ( ( chorus->delay[i] + 
@@ -167,52 +167,52 @@
 
                 if ( chorus->delay[i] < 20.0 )
                 {
-                        st_fail("chorus: delay must be more than 20.0 msec!");
-                        return (ST_EOF);
+                        sox_fail("chorus: delay must be more than 20.0 msec!");
+                        return (SOX_EOF);
                 }
                 if ( chorus->delay[i] > 100.0 )
                 {
-                        st_fail("chorus: delay must be less than 100.0 msec!");
-                        return (ST_EOF);
+                        sox_fail("chorus: delay must be less than 100.0 msec!");
+                        return (SOX_EOF);
                 }
                 if ( chorus->speed[i] < 0.1 )
                 {
-                        st_fail("chorus: speed must be more than 0.1 Hz!");
-                        return (ST_EOF);
+                        sox_fail("chorus: speed must be more than 0.1 Hz!");
+                        return (SOX_EOF);
                 }
                 if ( chorus->speed[i] > 5.0 )
                 {
-                        st_fail("chorus: speed must be less than 5.0 Hz!");
-                        return (ST_EOF);
+                        sox_fail("chorus: speed must be less than 5.0 Hz!");
+                        return (SOX_EOF);
                 }
                 if ( chorus->depth[i] < 0.0 )
                 {
-                        st_fail("chorus: delay must be more positive!");
-                        return (ST_EOF);
+                        sox_fail("chorus: delay must be more positive!");
+                        return (SOX_EOF);
                 }
                 if ( chorus->depth[i] > 10.0 )
                 {
-                    st_fail("chorus: delay must be less than 10.0 msec!");
-                    return (ST_EOF);
+                    sox_fail("chorus: delay must be less than 10.0 msec!");
+                    return (SOX_EOF);
                 }
                 if ( chorus->decay[i] < 0.0 )
                 {
-                        st_fail("chorus: decay must be positive!" );
-                        return (ST_EOF);
+                        sox_fail("chorus: decay must be positive!" );
+                        return (SOX_EOF);
                 }
                 if ( chorus->decay[i] > 1.0 )
                 {
-                        st_fail("chorus: decay must be less that 1.0!" );
-                        return (ST_EOF);
+                        sox_fail("chorus: decay must be less that 1.0!" );
+                        return (SOX_EOF);
                 }
                 chorus->length[i] = effp->ininfo.rate / chorus->speed[i];
                 chorus->lookup_tab[i] = (int *) xmalloc(sizeof (int) * chorus->length[i]);
 
                 if (chorus->modulation[i] == MOD_SINE)
-                  st_generate_wave_table(ST_WAVE_SINE, ST_INT, chorus->lookup_tab[i],
+                  sox_generate_wave_table(SOX_WAVE_SINE, SOX_INT, chorus->lookup_tab[i],
                                          chorus->length[i], 0, chorus->depth_samples[i], 0);
                 else
-                  st_generate_wave_table(ST_WAVE_TRIANGLE, ST_INT, chorus->lookup_tab[i], 
+                  sox_generate_wave_table(SOX_WAVE_TRIANGLE, SOX_INT, chorus->lookup_tab[i], 
                                          chorus->length[i],
                                          chorus->samples[i] - 1 - 2 * chorus->depth_samples[i],
                                          chorus->samples[i] - 1, 3 * M_PI_2);
@@ -227,7 +227,7 @@
         for ( i = 0; i < chorus->num_chorus; i++ )
                 sum_in_volume += chorus->decay[i];
         if ( chorus->in_gain * ( sum_in_volume ) > 1.0 / chorus->out_gain )
-        st_warn("chorus: warning >>> gain-out can cause saturation or clipping of output <<<");
+        sox_warn("chorus: warning >>> gain-out can cause saturation or clipping of output <<<");
 
 
         chorus->chorusbuf = (float *) xmalloc(sizeof (float) * chorus->maxsamples);
@@ -236,7 +236,7 @@
 
         chorus->counter = 0;
         chorus->fade_out = chorus->maxsamples;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
@@ -243,8 +243,8 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_chorus_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                   st_size_t *isamp, st_size_t *osamp)
+static int sox_chorus_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                   sox_size_t *isamp, sox_size_t *osamp)
 {
         chorus_t chorus = (chorus_t) effp->priv;
         int len, done;
@@ -251,7 +251,7 @@
         int i;
         
         float d_in, d_out;
-        st_sample_t out;
+        sox_sample_t out;
 
         len = ((*isamp > *osamp) ? *osamp : *isamp);
         for(done = 0; done < len; done++) {
@@ -265,7 +265,7 @@
                         chorus->maxsamples] * chorus->decay[i];
                 /* Adjust the output volume and size to 24 bit */
                 d_out = d_out * chorus->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 *obuf++ = out * 256;
                 /* Mix decay of delay and input */
                 chorus->chorusbuf[chorus->counter] = d_in;
@@ -276,20 +276,20 @@
                                 ( chorus->phase[i] + 1 ) % chorus->length[i];
         }
         /* processed all samples */
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Drain out reverb lines. 
  */
-static int st_chorus_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_chorus_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
         chorus_t chorus = (chorus_t) effp->priv;
-        st_size_t done;
+        sox_size_t done;
         int i;
         
         float d_in, d_out;
-        st_sample_t out;
+        sox_sample_t out;
 
         done = 0;
         while ( ( done < *osamp ) && ( done < chorus->fade_out ) ) {
@@ -302,7 +302,7 @@
                 chorus->maxsamples] * chorus->decay[i];
                 /* Adjust the output volume and size to 24 bit */
                 d_out = d_out * chorus->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 *obuf++ = out * 256;
                 /* Mix decay of delay and input */
                 chorus->chorusbuf[chorus->counter] = d_in;
@@ -317,15 +317,15 @@
         /* samples played, it remains */
         *osamp = done;
         if (chorus->fade_out == 0)
-            return ST_EOF;
+            return SOX_EOF;
         else
-            return ST_SUCCESS;
+            return SOX_SUCCESS;
 }
 
 /*
  * Clean up chorus effect.
  */
-static int st_chorus_stop(eff_t effp)
+static int sox_chorus_stop(eff_t effp)
 {
         chorus_t chorus = (chorus_t) effp->priv;
         int i;
@@ -336,22 +336,22 @@
                 free((char *) chorus->lookup_tab[i]);
                 chorus->lookup_tab[i] = (int *) -1;   /* guaranteed core dump */
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_effect_t st_chorus_effect = {
+static sox_effect_t sox_chorus_effect = {
   "chorus",
   "Usage: chorus gain-in gain-out delay decay speed depth [ -s | -t ]",
   0,
-  st_chorus_getopts,
-  st_chorus_start,
-  st_chorus_flow,
-  st_chorus_drain,
-  st_chorus_stop,
-  st_effect_nothing
+  sox_chorus_getopts,
+  sox_chorus_start,
+  sox_chorus_flow,
+  sox_chorus_drain,
+  sox_chorus_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_chorus_effect_fn(void)
+const sox_effect_t *sox_chorus_effect_fn(void)
 {
-    return &st_chorus_effect;
+    return &sox_chorus_effect;
 }
--- a/src/compand.c
+++ b/src/compand.c
@@ -43,7 +43,7 @@
  */
 
 typedef struct {
-  st_compandt_t transfer_fn;
+  sox_compandt_t transfer_fn;
 
   struct {
     double attack_times[2]; /* 0:attack_time, 1:decay_time */
@@ -52,10 +52,10 @@
   unsigned expectedChannels;/* Also flags that channels aren't to be treated
                                individually when = 1 and input not mono */
   double delay;             /* Delay to apply before companding */
-  st_sample_t *delay_buf;   /* Old samples, used for delay processing */
-  st_ssize_t delay_buf_size;/* Size of delay_buf in samples */
-  st_ssize_t delay_buf_index; /* Index into delay_buf */
-  st_ssize_t delay_buf_cnt; /* No. of active entries in delay_buf */
+  sox_sample_t *delay_buf;   /* Old samples, used for delay processing */
+  sox_ssize_t delay_buf_size;/* Size of delay_buf in samples */
+  sox_ssize_t delay_buf_index; /* Index into delay_buf */
+  sox_ssize_t delay_buf_cnt; /* No. of active entries in delay_buf */
   int delay_buf_full;       /* Shows buffer situation (important for drain) */
 } * compand_t;
 
@@ -67,15 +67,15 @@
   unsigned pairs, i, j, commas;
 
   if (n < 2 || n > 5) {
-    st_fail(effp->h->usage);
-    return ST_EOF;
+    sox_fail(effp->h->usage);
+    return SOX_EOF;
   }
 
   /* Start by checking the attack and decay rates */
   for (s = argv[0], commas = 0; *s; ++s) if (*s == ',') ++commas;
   if ((commas % 2) == 0) {
-    st_fail("there must be an even number of attack/decay parameters");
-    return ST_EOF;
+    sox_fail("there must be an even number of attack/decay parameters");
+    return SOX_EOF;
   }
   pairs = 1 + commas/2;
   l->channels = xcalloc(pairs, sizeof(*l->channels));
@@ -86,18 +86,18 @@
   for (i = 0, s = strtok(argv[0], ","); s != NULL; ++i) {
     for (j = 0; j < 2; ++j) {
       if (sscanf(s, "%lf %c", &l->channels[i].attack_times[j], &dummy) != 1) {
-        st_fail("syntax error trying to read attack/decay time");
-        return ST_EOF;
+        sox_fail("syntax error trying to read attack/decay time");
+        return SOX_EOF;
       } else if (l->channels[i].attack_times[j] < 0) {
-        st_fail("attack & decay times can't be less than 0 seconds");
-        return ST_EOF;
+        sox_fail("attack & decay times can't be less than 0 seconds");
+        return SOX_EOF;
       }
       s = strtok(NULL, ",");
     }
   }
 
-  if (!st_compandt_parse(&l->transfer_fn, argv[1], n>2 ? argv[2] : 0))
-    return ST_EOF;
+  if (!sox_compandt_parse(&l->transfer_fn, argv[1], n>2 ? argv[2] : 0))
+    return SOX_EOF;
 
   /* Set the initial "volume" to be attibuted to the input channels.
      Unless specified, choose 0dB otherwise clipping will
@@ -105,11 +105,11 @@
   for (i = 0; i < l->expectedChannels; ++i) {
     double init_vol_dB = 0;
     if (n > 3 && sscanf(argv[3], "%lf %c", &init_vol_dB, &dummy) != 1) {
-      st_fail("syntax error trying to read initial volume");
-      return ST_EOF;
+      sox_fail("syntax error trying to read initial volume");
+      return SOX_EOF;
     } else if (init_vol_dB > 0) {
-      st_fail("initial volume is relative to maximum volume so can't exceed 0dB");
-      return ST_EOF;
+      sox_fail("initial volume is relative to maximum volume so can't exceed 0dB");
+      return SOX_EOF;
     }
     l->channels[i].volume = pow(10., init_vol_dB / 20);
   }
@@ -116,14 +116,14 @@
 
   /* If there is a delay, store it. */
   if (n > 4 && sscanf(argv[4], "%lf %c", &l->delay, &dummy) != 1) {
-    st_fail("syntax error trying to read delay value");
-    return ST_EOF;
+    sox_fail("syntax error trying to read delay value");
+    return SOX_EOF;
   } else if (l->delay < 0) {
-    st_fail("delay can't be less than 0 seconds");
-    return ST_EOF;
+    sox_fail("delay can't be less than 0 seconds");
+    return SOX_EOF;
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static int start(eff_t effp)
@@ -131,14 +131,14 @@
   compand_t l = (compand_t) effp->priv;
   unsigned i, j;
 
-  st_debug("Starting compand effect; rate %i", effp->outinfo.rate);
-  st_debug("%i input channel(s) expected: actually %i",
+  sox_debug("Starting compand effect; rate %i", effp->outinfo.rate);
+  sox_debug("%i input channel(s) expected: actually %i",
       l->expectedChannels, effp->outinfo.channels);
   for (i = 0; i < l->expectedChannels; ++i)
-    st_debug("Channel %i: attack = %g decay = %g", i,
+    sox_debug("Channel %i: attack = %g decay = %g", i,
         l->channels[i].attack_times[0], l->channels[i].attack_times[1]);
-  if (!st_compandt_show(&l->transfer_fn, effp->globalinfo->octave_plot_effect))
-    return ST_EOF;
+  if (!sox_compandt_show(&l->transfer_fn, effp->globalinfo->octave_plot_effect))
+    return SOX_EOF;
 
   /* Convert attack and decay rates using number of samples */
   for (i = 0; i < l->expectedChannels; ++i)
@@ -152,12 +152,12 @@
   /* Allocate the delay buffer */
   l->delay_buf_size = l->delay * effp->outinfo.rate * effp->outinfo.channels;
   if (l->delay_buf_size > 0)
-    l->delay_buf = xcalloc((st_size_t)l->delay_buf_size, sizeof(*l->delay_buf));
+    l->delay_buf = xcalloc((sox_size_t)l->delay_buf_size, sizeof(*l->delay_buf));
   l->delay_buf_index = 0;
   l->delay_buf_cnt = 0;
   l->delay_buf_full= 0;
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
@@ -166,7 +166,7 @@
  */
 static void doVolume(double *v, double samp, compand_t l, int chan)
 {
-  double s = -samp / ST_SAMPLE_MIN;
+  double s = -samp / SOX_SAMPLE_MIN;
   double delta = s - *v;
 
   if (delta > 0.0) /* increase volume according to attack rate */
@@ -175,8 +175,8 @@
     *v += delta * l->channels[chan].attack_times[1];
 }
 
-static int flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
-                    st_size_t *isamp, st_size_t *osamp)
+static int flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf,
+                    sox_size_t *isamp, sox_size_t *osamp)
 {
   compand_t l = (compand_t) effp->priv;
   int len =  (*isamp > *osamp) ? *osamp : *isamp;
@@ -206,12 +206,12 @@
     for (chan = 0; chan < filechans; ++chan) {
       int ch = l->expectedChannels > 1 ? chan : 0;
       double level_in_lin = l->channels[ch].volume;
-      double level_out_lin = st_compandt(&l->transfer_fn, level_in_lin);
+      double level_out_lin = sox_compandt(&l->transfer_fn, level_in_lin);
       double checkbuf;
 
       if (l->delay_buf_size <= 0) {
         checkbuf = ibuf[chan] * level_out_lin;
-        ST_SAMPLE_CLIP_COUNT(checkbuf, effp->clips);
+        SOX_SAMPLE_CLIP_COUNT(checkbuf, effp->clips);
         obuf[odone++] = checkbuf;
         idone++;
       } else {
@@ -218,7 +218,7 @@
         if (l->delay_buf_cnt >= l->delay_buf_size) {
           l->delay_buf_full=1; /* delay buffer is now definitely full */
           checkbuf = l->delay_buf[l->delay_buf_index] * level_out_lin;
-          ST_SAMPLE_CLIP_COUNT(checkbuf, effp->clips);
+          SOX_SAMPLE_CLIP_COUNT(checkbuf, effp->clips);
           obuf[odone] = checkbuf;
           odone++;
           idone++;
@@ -233,13 +233,13 @@
   }
 
   *isamp = idone; *osamp = odone;
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
-static int drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
   compand_t l = (compand_t) effp->priv;
-  st_size_t chan, done = 0;
+  sox_size_t chan, done = 0;
 
   if (l->delay_buf_full == 0)
     l->delay_buf_index = 0;
@@ -247,13 +247,13 @@
     for (chan = 0; chan < effp->outinfo.channels; ++chan) {
       int c = l->expectedChannels > 1 ? chan : 0;
       double level_in_lin = l->channels[c].volume;
-      double level_out_lin = st_compandt(&l->transfer_fn, level_in_lin);
+      double level_out_lin = sox_compandt(&l->transfer_fn, level_in_lin);
       obuf[done++] = l->delay_buf[l->delay_buf_index++] * level_out_lin;
       l->delay_buf_index %= l->delay_buf_size;
       l->delay_buf_cnt--;
     }
   *osamp = done;
-  return l->delay_buf_cnt > 0 ? ST_SUCCESS : ST_EOF;
+  return l->delay_buf_cnt > 0 ? SOX_SUCCESS : SOX_EOF;
 }
 
 static int stop(eff_t effp)
@@ -261,7 +261,7 @@
   compand_t l = (compand_t) effp->priv;
 
   free(l->delay_buf);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static int kill(eff_t effp)
@@ -268,15 +268,15 @@
 {
   compand_t l = (compand_t) effp->priv;
 
-  st_compandt_kill(&l->transfer_fn);
+  sox_compandt_kill(&l->transfer_fn);
   free(l->channels);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-st_effect_t const * st_compand_effect_fn(void)
+sox_effect_t const * sox_compand_effect_fn(void)
 {
-  static st_effect_t driver = {
-    "compand", compand_usage, ST_EFF_MCHAN,
+  static sox_effect_t driver = {
+    "compand", compand_usage, SOX_EFF_MCHAN,
     getopts, start, flow, drain, stop, kill
   };
   return &driver;
--- a/src/compandt.c
+++ b/src/compandt.c
@@ -21,12 +21,12 @@
 
 #define LOG_TO_LOG10(x) ((x) * 20 / log(10.))
 
-st_bool st_compandt_show(st_compandt_t * t, st_bool plot)
+sox_bool sox_compandt_show(sox_compandt_t * t, sox_bool plot)
 {
   int i;
 
   for (i = 1; t->segments[i-1].x; ++i)
-    st_debug("TF: %g %g %g %g",
+    sox_debug("TF: %g %g %g %g",
        LOG_TO_LOG10(t->segments[i].x),
        LOG_TO_LOG10(t->segments[i].y),
        LOG_TO_LOG10(t->segments[i].a),
@@ -33,7 +33,7 @@
        LOG_TO_LOG10(t->segments[i].b));
 
   if (!plot)
-    return st_true;
+    return sox_true;
   printf(
     "title('SoX effect: compand')\n"
     "xlabel('Input level (dB)')\n"
@@ -45,7 +45,7 @@
   for (i = -199; i <= 0; ++i) {
     double in = i/2.;
     double in_lin = pow(10., in/20);
-    printf("%g ", in + 20 * log10(st_compandt(t, in_lin)));
+    printf("%g ", in + 20 * log10(sox_compandt(t, in_lin)));
   }
   printf(
     "];\n"
@@ -52,10 +52,10 @@
     "%%plot(in,out,'b') %% hmm.. doesn't work :(\n"
     "semilogx(exp(in),out,'b')\n"
     "pause\n");
-  return st_false;
+  return sox_false;
 }
 
-static void prepare_transfer_fn(st_compandt_t * t)
+static void prepare_transfer_fn(sox_compandt_t * t)
 {
   int i;
   double radius = t->curve_dB * log(10.) / 20;
@@ -115,24 +115,24 @@
   t->out_min_lin= exp(t->segments[1].y);
 }
 
-static st_bool parse_transfer_value(char const * text, double * value)
+static sox_bool parse_transfer_value(char const * text, double * value)
 {
   char dummy;     /* To check for extraneous chars. */
 
   if (!strcmp(text, "-inf"))
-    *value = -20 * log10(-(double)ST_SAMPLE_MIN);
+    *value = -20 * log10(-(double)SOX_SAMPLE_MIN);
   else if (sscanf(text, "%lf %c", value, &dummy) != 1) {
-    st_fail("syntax error trying to read transfer function value");
-    return st_false;
+    sox_fail("syntax error trying to read transfer function value");
+    return sox_false;
   }
   else if (*value > 0) {
-    st_fail("transfer function values are relative to maximum volume so can't exceed 0dB");
-    return st_false;
+    sox_fail("transfer function values are relative to maximum volume so can't exceed 0dB");
+    return sox_false;
   }
-  return st_true;
+  return sox_true;
 }
 
-st_bool st_compandt_parse(st_compandt_t * t, char * points, char * gain)
+sox_bool sox_compandt_parse(sox_compandt_t * t, char * points, char * gain)
 {
   char const * text = points;
   unsigned i, j, num, pairs, commas = 0;
@@ -153,15 +153,15 @@
 #define s(n) t->segments[2*((n)+1)]
   for (i = 0, text = strtok(points, ","); text != NULL; ++i) {
     if (!parse_transfer_value(text, &s(i).x))
-      return st_false;
+      return sox_false;
     if (i && s(i-1).x > s(i).x) {
-      st_fail("transfer function input values must be strictly increasing");
-      return st_false;
+      sox_fail("transfer function input values must be strictly increasing");
+      return sox_false;
     }
     if (i || (commas & 1)) {
       text = strtok(NULL, ",");
       if (!parse_transfer_value(text, &s(i).y))
-        return st_false;
+        return sox_false;
       s(i).y -= s(i).x;
     }
     text = strtok(NULL, ",");
@@ -173,8 +173,8 @@
 #undef s
 
   if (gain && sscanf(gain, "%lf %c", &t->outgain_dB, &dummy) != 1) {
-    st_fail("syntax error trying to read post-processing gain value");
-    return st_false;
+    sox_fail("syntax error trying to read post-processing gain value");
+    return sox_false;
   }
 
 #define s(n) t->segments[2*(n)]
@@ -194,10 +194,10 @@
 #undef s
 
   prepare_transfer_fn(t);
-  return st_true;
+  return sox_true;
 }
 
-void st_compandt_kill(st_compandt_t * p)
+void sox_compandt_kill(sox_compandt_t * p)
 {
   free(p->segments);
 }
--- a/src/compandt.h
+++ b/src/compandt.h
@@ -16,11 +16,11 @@
  * Compander Transfer Function: (c) 2007 robs@users.sourceforge.net
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <math.h>
 
 typedef struct {
-  struct st_compandt_segment {
+  struct sox_compandt_segment {
     double x, y;              /* 1st point in segment */
     double a, b;              /* Quadratic coeffecients for rest of segment */
   } * segments;
@@ -28,16 +28,16 @@
   double out_min_lin;
   double outgain_dB;        /* Post processor gain */
   double curve_dB;
-} st_compandt_t;
+} sox_compandt_t;
 
-st_bool st_compandt_parse(st_compandt_t * t, char * points, char * gain);
-st_bool st_compandt_show(st_compandt_t * t, st_bool plot);
-void    st_compandt_kill(st_compandt_t * p);
+sox_bool sox_compandt_parse(sox_compandt_t * t, char * points, char * gain);
+sox_bool sox_compandt_show(sox_compandt_t * t, sox_bool plot);
+void    sox_compandt_kill(sox_compandt_t * p);
 
 /* Place in header to allow in-lining */
-static double st_compandt(st_compandt_t * t, double in_lin)
+static double sox_compandt(sox_compandt_t * t, double in_lin)
 {
-  struct st_compandt_segment * s;
+  struct sox_compandt_segment * s;
   double in_log, out_log;
 
   if (in_lin <= t->in_min_lin)
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -34,7 +34,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <math.h>
 #include <string.h>
@@ -117,8 +117,8 @@
         p->cvsd_rate = (ft->signal.rate <= 24000) ? 16000 : 32000;
         ft->signal.rate = 8000;
         ft->signal.channels = 1;
-        ft->signal.size = ST_SIZE_16BIT; /* make output format default to words */
-        ft->signal.encoding = ST_ENCODING_SIGN2;
+        ft->signal.size = SOX_SIZE_16BIT; /* make output format default to words */
+        ft->signal.encoding = SOX_ENCODING_SIGN2;
         /*
          * initialize the decoder
          */
@@ -144,13 +144,13 @@
         p->bytes_written = 0;
         p->com.v_min = 1;
         p->com.v_max = -1;
-        st_report("cvsd: bit rate %dbit/s, bits from %s", p->cvsd_rate,
+        sox_report("cvsd: bit rate %dbit/s, bits from %s", p->cvsd_rate,
                ft->signal.reverse_bits ? "msb to lsb" : "lsb to msb");
 }
 
 /* ---------------------------------------------------------------------- */
 
-static int st_cvsdstartread(ft_t ft) 
+static int sox_cvsdstartread(ft_t ft) 
 {
         struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
         float *fp1;
@@ -171,12 +171,12 @@
         for(fp1 = p->c.dec.output_filter, i = DEC_FILTERLEN; i > 0; i--)
                 *fp1++ = 0;
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /* ---------------------------------------------------------------------- */
 
-static int st_cvsdstartwrite(ft_t ft) 
+static int sox_cvsdstartwrite(ft_t ft) 
 {
         struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
         float *fp1;
@@ -193,48 +193,48 @@
                 *fp1++ = 0;
         p->c.enc.recon_int = 0;
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* ---------------------------------------------------------------------- */
 
-static int st_cvsdstopwrite(ft_t ft)
+static int sox_cvsdstopwrite(ft_t ft)
 {
         struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
 
         if (p->bit.cnt) {
-                st_writeb(ft, p->bit.shreg);
+                sox_writeb(ft, p->bit.shreg);
                 p->bytes_written++;
         }
-        st_debug("cvsd: min slope %f, max slope %f", 
+        sox_debug("cvsd: min slope %f, max slope %f", 
                p->com.v_min, p->com.v_max);     
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /* ---------------------------------------------------------------------- */
 
-static int st_cvsdstopread(ft_t ft)
-{
+static int sox_cvsdstopread(ft_t ft)
+{
         struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
 
-        st_debug("cvsd: min value %f, max value %f", 
+        sox_debug("cvsd: min value %f, max value %f", 
                p->com.v_min, p->com.v_max);
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* ---------------------------------------------------------------------- */
 
-static st_size_t st_cvsdread(ft_t ft, st_sample_t *buf, st_size_t nsamp) 
+static sox_size_t sox_cvsdread(ft_t ft, sox_sample_t *buf, sox_size_t nsamp) 
 {
         struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
-        st_size_t done = 0;
+        sox_size_t done = 0;
         float oval;
         
         while (done < nsamp) {
                 if (!p->bit.cnt) {
-                        if (st_readb(ft, &(p->bit.shreg)) == ST_EOF)
+                        if (sox_readb(ft, &(p->bit.shreg)) == SOX_EOF)
                                 return done;
                         p->bit.cnt = 8;
                         p->bit.mask = 1;
@@ -264,8 +264,8 @@
                                           (p->cvsd_rate < 24000) ? 
                                           dec_filter_16 : dec_filter_32, 
                                           DEC_FILTERLEN);
-                        st_debug_more("input %d %f\n", debug_count, p->com.mla_int);
-                        st_debug_more("recon %d %f\n", debug_count, oval);
+                        sox_debug_more("input %d %f\n", debug_count, p->com.mla_int);
+                        sox_debug_more("recon %d %f\n", debug_count, oval);
                         debug_count++;
 
                         if (oval > p->com.v_max)
@@ -272,7 +272,7 @@
                                 p->com.v_max = oval;
                         if (oval < p->com.v_min)
                                 p->com.v_min = oval;
-                        *buf++ = (oval * ((float)ST_SAMPLE_MAX));
+                        *buf++ = (oval * ((float)SOX_SAMPLE_MAX));
                         done++;
                 }
                 p->com.phase &= 3;
@@ -282,10 +282,10 @@
 
 /* ---------------------------------------------------------------------- */
 
-static st_size_t st_cvsdwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp) 
+static sox_size_t sox_cvsdwrite(ft_t ft, const sox_sample_t *buf, sox_size_t nsamp) 
 {
         struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
-        st_size_t done = 0;
+        sox_size_t done = 0;
         float inval;
 
         for(;;) {
@@ -298,7 +298,7 @@
                         memmove(p->c.enc.input_filter+1, p->c.enc.input_filter,
                                 sizeof(p->c.enc.input_filter)-sizeof(float));
                         p->c.enc.input_filter[0] = (*buf++) / 
-                                ((float)ST_SAMPLE_MAX);
+                                ((float)SOX_SAMPLE_MAX);
                         done++;
                 }
                 p->com.phase &= 3;
@@ -326,7 +326,7 @@
                 } else
                         p->c.enc.recon_int -= p->com.mla_int;
                 if ((++(p->bit.cnt)) >= 8) {
-                        st_writeb(ft, p->bit.shreg);
+                        sox_writeb(ft, p->bit.shreg);
                         p->bytes_written++;
                         p->bit.shreg = p->bit.cnt = 0;
                         p->bit.mask = 1;
@@ -333,8 +333,8 @@
                 } else
                         p->bit.mask <<= 1;
                 p->com.phase += p->com.phase_inc;
-                st_debug_more("input %d %f\n", debug_count, inval);
-                st_debug_more("recon %d %f\n", debug_count, p->c.enc.recon_int);
+                sox_debug_more("input %d %f\n", debug_count, inval);
+                sox_debug_more("recon %d %f\n", debug_count, p->c.enc.recon_int);
                 debug_count++;
         }
 }
@@ -350,7 +350,7 @@
         time_t        Unixtime;
         unsigned      Usender;
         unsigned      Ureceiver;
-        st_size_t     Length;
+        sox_size_t     Length;
         unsigned      Srate;
         unsigned      Days;
         unsigned      Custom1;
@@ -371,9 +371,9 @@
         int i;
         unsigned sum;
 
-        if (st_readbuf(ft, hdrbuf, sizeof(hdrbuf), 1) != 1)
+        if (sox_readbuf(ft, hdrbuf, sizeof(hdrbuf), 1) != 1)
         {
-                return (ST_EOF);
+                return (SOX_EOF);
         }
         for(i = sizeof(hdrbuf), sum = 0; i > /*2*/3; i--) /* Deti bug */
                 sum += *pch++;
@@ -397,11 +397,11 @@
         hdr->Crc = get16_le(&pch);
         if (sum != hdr->Crc) 
         {
-                st_report("DVMS header checksum error, read %u, calculated %u",
+                sox_report("DVMS header checksum error, read %u, calculated %u",
                      hdr->Crc, sum);
-                return (ST_EOF);
+                return (SOX_EOF);
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /* ---------------------------------------------------------------------- */
@@ -437,17 +437,17 @@
                 sum += *pchs++;
         hdr->Crc = sum;
         put16_le(&pch, hdr->Crc);
-        if (st_seeki(ft, 0, SEEK_SET) < 0)
+        if (sox_seeki(ft, 0, SEEK_SET) < 0)
         {
-                st_report("seek failed\n: %s",strerror(errno));
-                return (ST_EOF);
+                sox_report("seek failed\n: %s",strerror(errno));
+                return (SOX_EOF);
         }
-        if (st_writebuf(ft, hdrbuf, sizeof(hdrbuf), 1) != 1)
+        if (sox_writebuf(ft, hdrbuf, sizeof(hdrbuf), 1) != 1)
         {
-                st_report("%s",strerror(errno));
-                return (ST_EOF);
+                sox_report("%s",strerror(errno));
+                return (SOX_EOF);
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /* ---------------------------------------------------------------------- */
@@ -478,7 +478,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-static int st_dvmsstartread(ft_t ft) 
+static int sox_dvmsstartread(ft_t ft) 
 {
         struct dvms_header hdr;
         int rc;
@@ -485,42 +485,42 @@
 
         rc = dvms_read_header(ft, &hdr);
         if (rc){
-            st_fail_errno(ft,ST_EHDR,"unable to read DVMS header");
+            sox_fail_errno(ft,SOX_EHDR,"unable to read DVMS header");
             return rc;
         }
 
-        st_debug("DVMS header of source file \"%s\":");
-        st_debug("  filename  \"%.14s\"",ft->filename);
-        st_debug("  id        0x%x", hdr.Filename);
-        st_debug("  state     0x%x", hdr.Id, hdr.State);
-        st_debug("  time      %s",ctime(&hdr.Unixtime)); /* ctime generates lf */
-        st_debug("  usender   %u", hdr.Usender);
-        st_debug("  ureceiver %u", hdr.Ureceiver);
-        st_debug("  length    %u", hdr.Length);
-        st_debug("  srate     %u", hdr.Srate);
-        st_debug("  days      %u", hdr.Days);
-        st_debug("  custom1   %u", hdr.Custom1);
-        st_debug("  custom2   %u", hdr.Custom2);
-        st_debug("  info      \"%.16s\"", hdr.Info);
+        sox_debug("DVMS header of source file \"%s\":");
+        sox_debug("  filename  \"%.14s\"",ft->filename);
+        sox_debug("  id        0x%x", hdr.Filename);
+        sox_debug("  state     0x%x", hdr.Id, hdr.State);
+        sox_debug("  time      %s",ctime(&hdr.Unixtime)); /* ctime generates lf */
+        sox_debug("  usender   %u", hdr.Usender);
+        sox_debug("  ureceiver %u", hdr.Ureceiver);
+        sox_debug("  length    %u", hdr.Length);
+        sox_debug("  srate     %u", hdr.Srate);
+        sox_debug("  days      %u", hdr.Days);
+        sox_debug("  custom1   %u", hdr.Custom1);
+        sox_debug("  custom2   %u", hdr.Custom2);
+        sox_debug("  info      \"%.16s\"", hdr.Info);
         ft->signal.rate = (hdr.Srate < 240) ? 16000 : 32000;
-        st_debug("DVMS rate %dbit/s using %dbit/s deviation %d%%", 
+        sox_debug("DVMS rate %dbit/s using %dbit/s deviation %d%%", 
                hdr.Srate*100, ft->signal.rate, 
                ((ft->signal.rate - hdr.Srate*100) * 100) / ft->signal.rate);
-        rc = st_cvsdstartread(ft);
+        rc = sox_cvsdstartread(ft);
         if (rc)
             return rc;
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* ---------------------------------------------------------------------- */
 
-static int st_dvmsstartwrite(ft_t ft) 
+static int sox_dvmsstartwrite(ft_t ft) 
 {
         struct dvms_header hdr;
         int rc;
         
-        rc = st_cvsdstartwrite(ft);
+        rc = sox_cvsdstartwrite(ft);
         if (rc)
             return rc;
 
@@ -527,38 +527,38 @@
         make_dvms_hdr(ft, &hdr);
         rc = dvms_write_header(ft, &hdr);
         if (rc){
-                st_fail_errno(ft,rc,"cannot write DVMS header");
+                sox_fail_errno(ft,rc,"cannot write DVMS header");
             return rc;
         }
 
         if (!ft->seekable)
-               st_warn("Length in output .DVMS header will wrong since can't seek to fix it");
+               sox_warn("Length in output .DVMS header will wrong since can't seek to fix it");
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* ---------------------------------------------------------------------- */
 
-static int st_dvmsstopwrite(ft_t ft)
+static int sox_dvmsstopwrite(ft_t ft)
 {
         struct dvms_header hdr;
         int rc;
         
-        st_cvsdstopwrite(ft);
+        sox_cvsdstopwrite(ft);
         if (!ft->seekable)
         {
-            st_warn("File not seekable");
-            return (ST_EOF);
+            sox_warn("File not seekable");
+            return (SOX_EOF);
         }
-        if (st_seeki(ft, 0, 0) != 0)
+        if (sox_seeki(ft, 0, 0) != 0)
         {
-                st_fail_errno(ft,errno,"Can't rewind output file to rewrite DVMS header.");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"Can't rewind output file to rewrite DVMS header.");
+                return(SOX_EOF);
         }
         make_dvms_hdr(ft, &hdr);
         rc = dvms_write_header(ft, &hdr);
         if(rc){
-            st_fail_errno(ft,rc,"cannot write DVMS header");
+            sox_fail_errno(ft,rc,"cannot write DVMS header");
             return rc;
         }       
         return rc;
@@ -573,22 +573,22 @@
   NULL
 };
 
-static st_format_t st_cvsd_format = {
+static sox_format_t sox_cvsd_format = {
   cvsdnames,
   NULL,
   0,
-  st_cvsdstartread,
-  st_cvsdread,
-  st_cvsdstopread,
-  st_cvsdstartwrite,
-  st_cvsdwrite,
-  st_cvsdstopwrite,
-  st_format_nothing_seek
+  sox_cvsdstartread,
+  sox_cvsdread,
+  sox_cvsdstopread,
+  sox_cvsdstartwrite,
+  sox_cvsdwrite,
+  sox_cvsdstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_cvsd_format_fn(void)
+const sox_format_t *sox_cvsd_format_fn(void)
 {
-    return &st_cvsd_format;
+    return &sox_cvsd_format;
 }
 /* Cont. Variable Solot Delta */
 static const char *dvmsnames[] = {
@@ -597,20 +597,20 @@
   NULL
 };
 
-static st_format_t st_dvms_format = {
+static sox_format_t sox_dvms_format = {
   dvmsnames,
   NULL,
   0,
-  st_dvmsstartread,
-  st_cvsdread,
-  st_cvsdstopread,
-  st_dvmsstartwrite,
-  st_cvsdwrite,
-  st_dvmsstopwrite,
-  st_format_nothing_seek
+  sox_dvmsstartread,
+  sox_cvsdread,
+  sox_cvsdstopread,
+  sox_dvmsstartwrite,
+  sox_cvsdwrite,
+  sox_dvmsstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_dvms_format_fn(void)
+const sox_format_t *sox_dvms_format_fn(void)
 {
-    return &st_dvms_format;
+    return &sox_dvms_format;
 }
--- a/src/dat.c
+++ b/src/dat.c
@@ -10,7 +10,7 @@
  * the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <string.h>
 
 #define LINEWIDTH 256
@@ -22,7 +22,7 @@
     char prevline[LINEWIDTH]; 
 } *dat_t;
 
-static int st_datstartread(ft_t ft)
+static int sox_datstartread(ft_t ft)
 {
     char inpstr[LINEWIDTH];
     long rate;
@@ -31,7 +31,7 @@
     char sc;
 
     /* Read lines until EOF or first non-comment line */
-    while ((status = st_reads(ft, inpstr, LINEWIDTH-1)) != ST_EOF) {
+    while ((status = sox_reads(ft, inpstr, LINEWIDTH-1)) != SOX_EOF) {
       inpstr[LINEWIDTH-1] = 0;
       if ((sscanf(inpstr," %c", &sc) != 0) && (sc != ';')) break;
       if (sscanf(inpstr," ; Sample Rate %ld", &rate)) {
@@ -41,7 +41,7 @@
       }
     }
     /* Hold a copy of the last line we read (first non-comment) */
-    if (status != ST_EOF) {
+    if (status != SOX_EOF) {
       strncpy(((dat_t)ft->priv)->prevline, inpstr, LINEWIDTH);
       ((dat_t)ft->priv)->buffered = 1;
     } else {
@@ -52,31 +52,31 @@
     if (ft->signal.channels == 0)
        ft->signal.channels = 1;
 
-    ft->signal.size = ST_SIZE_64BIT;
-    ft->signal.encoding = ST_ENCODING_FLOAT;
+    ft->signal.size = SOX_SIZE_64BIT;
+    ft->signal.encoding = SOX_ENCODING_FLOAT;
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-static int st_datstartwrite(ft_t ft)
+static int sox_datstartwrite(ft_t ft)
 {
     dat_t dat = (dat_t) ft->priv;
     char s[LINEWIDTH];
 
-    ft->signal.size = ST_SIZE_64BIT;
-    ft->signal.encoding = ST_ENCODING_FLOAT;
+    ft->signal.size = SOX_SIZE_64BIT;
+    ft->signal.encoding = SOX_ENCODING_FLOAT;
     dat->timevalue = 0.0;
     dat->deltat = 1.0 / (double)ft->signal.rate;
     /* Write format comments to start of file */
     sprintf(s,"; Sample Rate %ld\015\n", (long)ft->signal.rate);
-    st_writes(ft, s);
+    sox_writes(ft, s);
     sprintf(s,"; Channels %d\015\n", (int)ft->signal.channels);
-    st_writes(ft, s);
+    sox_writes(ft, s);
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-static st_size_t st_datread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
+static sox_size_t sox_datread(ft_t ft, sox_sample_t *buf, sox_size_t nsamp)
 {
     char inpstr[LINEWIDTH];
     int  inpPtr = 0;
@@ -84,8 +84,8 @@
     double sampval = 0.0;
     int retc = 0;
     char sc = 0;
-    st_size_t done = 0;
-    st_size_t i=0;
+    sox_size_t done = 0;
+    sox_size_t i=0;
 
     /* Always read a complete set of channels */
     nsamp -= (nsamp % ft->signal.channels);
@@ -97,9 +97,9 @@
         strncpy(inpstr, ((dat_t)ft->priv)->prevline, LINEWIDTH);
         ((dat_t)ft->priv)->buffered=0;
       } else {
-        st_reads(ft, inpstr, LINEWIDTH-1);
+        sox_reads(ft, inpstr, LINEWIDTH-1);
         inpstr[LINEWIDTH-1] = 0;
-        if (st_eof(ft)) return (done);
+        if (sox_eof(ft)) return (done);
       }
 
       /* Skip over comments - ie. 0 or more whitespace, then ';' */
@@ -111,11 +111,11 @@
         retc = sscanf(&inpstr[inpPtr]," %lg%n", &sampval, &inpPtrInc);
         inpPtr += inpPtrInc;
         if (retc != 1) {
-          st_fail_errno(ft,ST_EOF,"Unable to read sample.");
-          return (ST_EOF);
+          sox_fail_errno(ft,SOX_EOF,"Unable to read sample.");
+          return (SOX_EOF);
         }
-        sampval *= ST_SAMPLE_MAX;
-        *buf++ = ST_ROUND_CLIP_COUNT(sampval, ft->clips);
+        sampval *= SOX_SAMPLE_MAX;
+        *buf++ = SOX_ROUND_CLIP_COUNT(sampval, ft->clips);
         done++;
       }
     }
@@ -123,13 +123,13 @@
     return (done);
 }
 
-static st_size_t st_datwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
+static sox_size_t sox_datwrite(ft_t ft, const sox_sample_t *buf, sox_size_t nsamp)
 {
     dat_t dat = (dat_t) ft->priv;
-    st_size_t done = 0;
+    sox_size_t done = 0;
     double sampval=0.0;
     char s[LINEWIDTH];
-    st_size_t i=0;
+    sox_size_t i=0;
 
     /* Always write a complete set of channels */
     nsamp -= (nsamp % ft->signal.channels);
@@ -137,15 +137,15 @@
     /* Write time, then sample values, then CRLF newline */
     while(done < nsamp) {
       sprintf(s," %15.8g ",dat->timevalue);
-      st_writes(ft, s);
+      sox_writes(ft, s);
       for (i=0; i<ft->signal.channels; i++) {
-        sampval = ST_SAMPLE_TO_FLOAT_DDWORD(*buf++, ft->clips);
+        sampval = SOX_SAMPLE_TO_FLOAT_DDWORD(*buf++, ft->clips);
         sprintf(s," %15.8g", sampval);
-        st_writes(ft, s);
+        sox_writes(ft, s);
         done++;
       }
       sprintf(s," \015\n");
-      st_writes(ft, s);
+      sox_writes(ft, s);
       dat->timevalue += dat->deltat;
     }
     return done;
@@ -157,20 +157,20 @@
   NULL
 };
 
-static st_format_t st_dat_format = {
+static sox_format_t sox_dat_format = {
   datnames,
   NULL,
   0,
-  st_datstartread,
-  st_datread,
-  st_format_nothing,
-  st_datstartwrite,
-  st_datwrite,
-  st_format_nothing,
-  st_format_nothing_seek
+  sox_datstartread,
+  sox_datread,
+  sox_format_nothing,
+  sox_datstartwrite,
+  sox_datwrite,
+  sox_format_nothing,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_dat_format_fn(void)
+const sox_format_t *sox_dat_format_fn(void)
 {
-    return &st_dat_format;
+    return &sox_dat_format;
 }
--- a/src/dcshift.c
+++ b/src/dcshift.c
@@ -11,11 +11,11 @@
  * Cannot handle rate change.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <math.h>   /* exp(), sqrt() */
 
-static st_effect_t st_dcshift_effect;
+static sox_effect_t sox_dcshift_effect;
 
 typedef struct {
     double dcshift; /* DC shift. */
@@ -30,7 +30,7 @@
 /*
  * Process options: dcshift (double) type (amplitude, power, dB)
  */
-static int st_dcshift_getopts(eff_t effp, int n, char **argv)
+static int sox_dcshift_getopts(eff_t effp, int n, char **argv)
 {
     dcs_t dcs = (dcs_t) effp->priv;
     dcs->dcshift = 1.0; /* default is no change */
@@ -38,14 +38,14 @@
 
     if (n < 1)
     {
-        st_fail(st_dcshift_effect.usage);
-        return ST_EOF;
+        sox_fail(sox_dcshift_effect.usage);
+        return SOX_EOF;
     }
 
     if (n && (!sscanf(argv[0], "%lf", &dcs->dcshift)))
     {
-        st_fail(st_dcshift_effect.usage);
-        return ST_EOF;
+        sox_fail(sox_dcshift_effect.usage);
+        return SOX_EOF;
     }
 
     if (n>1)
@@ -52,43 +52,43 @@
     {
         if (!sscanf(argv[1], "%lf", &dcs->limitergain))
         {
-                st_fail(st_dcshift_effect.usage);
-                return ST_EOF;
+                sox_fail(sox_dcshift_effect.usage);
+                return SOX_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 ST_SAMPLE_MAX input always maps to a ST_SAMPLE_MAX output 
+        /* and a SOX_SAMPLE_MAX input always maps to a SOX_SAMPLE_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 = ST_SAMPLE_MAX * (1.0 - (fabs(dcs->dcshift) - dcs->limitergain));
+        dcs->limiterthreshhold = SOX_SAMPLE_MAX * (1.0 - (fabs(dcs->dcshift) - dcs->limitergain));
     }
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
  * Start processing
  */
-static int st_dcshift_start(eff_t effp)
+static int sox_dcshift_start(eff_t effp)
 {
     dcs_t dcs = (dcs_t) effp->priv;
 
     if (dcs->dcshift == 0)
-      return ST_EFF_NULL;
+      return SOX_EFF_NULL;
 
     if (effp->outinfo.channels != effp->ininfo.channels) {
-        st_fail("DCSHIFT cannot handle different channels (in=%d, out=%d)"
+        sox_fail("DCSHIFT cannot handle different channels (in=%d, out=%d)"
              " use avg or pan", effp->ininfo.channels, effp->outinfo.channels);
-        return ST_EOF;
+        return SOX_EOF;
     }
 
     if (effp->outinfo.rate != effp->ininfo.rate) {
-        st_fail("DCSHIFT cannot handle different rates (in=%ld, out=%ld)"
+        sox_fail("DCSHIFT cannot handle different rates (in=%ld, out=%ld)"
              " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
-        return ST_EOF;
+        return SOX_EOF;
     }
 
     dcs->clipped = 0;
@@ -95,14 +95,14 @@
     dcs->limited = 0;
     dcs->totalprocessed = 0;
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
  * Process data.
  */
-static int st_dcshift_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                    st_size_t *isamp, st_size_t *osamp)
+static int sox_dcshift_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                    sox_size_t *isamp, sox_size_t *osamp)
 {
     dcs_t dcs = (dcs_t) effp->priv;
     double dcshift = dcs->dcshift;
@@ -109,7 +109,7 @@
     double limitergain = dcs->limitergain;
     double limiterthreshhold = dcs->limiterthreshhold;
     double sample;
-    st_size_t len;
+    sox_size_t len;
 
     len = min(*osamp, *isamp);
 
@@ -126,26 +126,26 @@
 
                 if (sample > limiterthreshhold && dcshift > 0)
                 {
-                        sample =  (sample - limiterthreshhold) * limitergain / (ST_SAMPLE_MAX - limiterthreshhold) + limiterthreshhold + dcshift;
+                        sample =  (sample - limiterthreshhold) * limitergain / (SOX_SAMPLE_MAX - limiterthreshhold) + limiterthreshhold + dcshift;
                         dcs->limited++;
                 }
                 else if (sample < -limiterthreshhold && dcshift < 0)
                 {
-                        /* Note this should really be ST_SAMPLE_MIN but
+                        /* Note this should really be SOX_SAMPLE_MIN but
                          * the clip() below will take care of the overflow.
                          */
-                        sample =  (sample + limiterthreshhold) * limitergain / (ST_SAMPLE_MAX - limiterthreshhold) - limiterthreshhold + dcshift;
+                        sample =  (sample + limiterthreshhold) * limitergain / (SOX_SAMPLE_MAX - limiterthreshhold) - limiterthreshhold + dcshift;
                         dcs->limited++;
                 }
                 else
                 {
-                        /* Note this should consider ST_SAMPLE_MIN but
+                        /* Note this should consider SOX_SAMPLE_MIN but
                          * the clip() below will take care of the overflow.
                          */
-                        sample = dcshift * ST_SAMPLE_MAX + sample;
+                        sample = dcshift * SOX_SAMPLE_MAX + sample;
                 }
 
-                ST_SAMPLE_CLIP_COUNT(sample, dcs->clipped);
+                SOX_SAMPLE_CLIP_COUNT(sample, dcs->clipped);
                 *obuf++ = sample;
             }
     }
@@ -156,12 +156,12 @@
         {
                 double f;
 
-                f = dcshift * ST_SAMPLE_MAX + *ibuf++;
-                ST_SAMPLE_CLIP_COUNT(f, dcs->clipped);
+                f = dcshift * SOX_SAMPLE_MAX + *ibuf++;
+                SOX_SAMPLE_CLIP_COUNT(f, dcs->clipped);
                 *obuf++ = f;
         }
     }
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
@@ -168,13 +168,13 @@
  * Do anything required when you stop reading samples.
  * Don't close input file!
  */
-static int st_dcshift_stop(eff_t effp)
+static int sox_dcshift_stop(eff_t effp)
 {
     dcs_t dcs = (dcs_t) effp->priv;
 
     if (dcs->limited)
     {
-        st_warn("DCSHIFT limited %d values (%d percent).",
+        sox_warn("DCSHIFT limited %d values (%d percent).",
              dcs->limited, (int) (dcs->limited * 100.0 / dcs->totalprocessed));
     }
     if (dcs->clipped)
@@ -181,33 +181,33 @@
     {
         if (dcs->dcshift > 0)
         {
-             st_warn("DCSHIFT clipped %d values, dcshift=%f too high...",
+             sox_warn("DCSHIFT clipped %d values, dcshift=%f too high...",
                   dcs->clipped, dcs->dcshift);
         }
         else
         {
-             st_warn("DCSHIFT clipped %d values, dcshift=%f too low...",
+             sox_warn("DCSHIFT clipped %d values, dcshift=%f too low...",
                   dcs->clipped, dcs->dcshift);
         }
     }
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
-static st_effect_t st_dcshift_effect = {
+static sox_effect_t sox_dcshift_effect = {
    "dcshift",
    "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)",
-   ST_EFF_MCHAN,
-   st_dcshift_getopts,
-   st_dcshift_start,
-   st_dcshift_flow,
-   st_effect_nothing_drain,
-   st_dcshift_stop,
-  st_effect_nothing
+   SOX_EFF_MCHAN,
+   sox_dcshift_getopts,
+   sox_dcshift_start,
+   sox_dcshift_flow,
+   sox_effect_nothing_drain,
+   sox_dcshift_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_dcshift_effect_fn(void)
+const sox_effect_t *sox_dcshift_effect_fn(void)
 {
-    return &st_dcshift_effect;
+    return &sox_dcshift_effect;
 }
--- a/src/deemph.h
+++ b/src/deemph.h
@@ -104,6 +104,6 @@
  * pre-calculated filter coefficients.
  */
 if (effp->ininfo.rate != 44100) {
-  st_fail("Sample rate must be 44100 (audio-CD)");
-  return ST_EOF;
+  sox_fail("Sample rate must be 44100 (audio-CD)");
+  return SOX_EOF;
 }
--- a/src/dither.c
+++ b/src/dither.c
@@ -14,13 +14,13 @@
 
 #include <stdlib.h>
 #include <math.h>
-#include "st_i.h"
+#include "sox_i.h"
 
 typedef struct dither {
   double amount;
 } * dither_t;
 
-assert_static(sizeof(struct dither) <= ST_MAX_EFFECT_PRIVSIZE,
+assert_static(sizeof(struct dither) <= SOX_MAX_EFFECT_PRIVSIZE,
               /* else */ dither_PRIVSIZE_too_big);
 
 static int getopts(eff_t effp, int n, char * * argv)
@@ -28,8 +28,8 @@
   dither_t dither = (dither_t) effp->priv;
 
   if (n > 1) {
-    st_fail(effp->h->usage);
-    return ST_EOF;
+    sox_fail(effp->h->usage);
+    return SOX_EOF;
   }
   
   dither->amount = sqrt(2); /* M_SQRT2 missing in some places */   /* Default to half a bit. */
@@ -40,12 +40,12 @@
     if (scanned == 1 && amount > 0)
       dither->amount *= amount;
     else {
-      st_fail(effp->h->usage);
-      return ST_EOF;
+      sox_fail(effp->h->usage);
+      return SOX_EOF;
     }
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static int start(eff_t effp)
@@ -52,47 +52,47 @@
 {
   dither_t dither = (dither_t) effp->priv;
 
-  if (effp->outinfo.encoding == ST_ENCODING_ULAW ||
-      effp->outinfo.encoding == ST_ENCODING_ALAW) {
+  if (effp->outinfo.encoding == SOX_ENCODING_ULAW ||
+      effp->outinfo.encoding == SOX_ENCODING_ALAW) {
     dither->amount *= 16;
-    return ST_SUCCESS;
-  } else if (effp->outinfo.size == ST_SIZE_BYTE) {
+    return SOX_SUCCESS;
+  } else if (effp->outinfo.size == SOX_SIZE_BYTE) {
     dither->amount *= 256;
-    return ST_SUCCESS;
-  } else if (effp->outinfo.size == ST_SIZE_16BIT)
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
+  } else if (effp->outinfo.size == SOX_SIZE_16BIT)
+    return SOX_SUCCESS;
 
-  return ST_EFF_NULL;   /* Dithering not needed at >= 24 bits */
+  return SOX_EFF_NULL;   /* Dithering not needed at >= 24 bits */
 }
 
-static int flow(eff_t effp, const st_sample_t * ibuf,
-    st_sample_t * obuf, st_size_t * isamp, st_size_t * osamp)
+static int flow(eff_t effp, const sox_sample_t * ibuf,
+    sox_sample_t * obuf, sox_size_t * isamp, sox_size_t * osamp)
 {
   dither_t dither = (dither_t)effp->priv;
-  st_size_t len = min(*isamp, *osamp);
+  sox_size_t len = min(*isamp, *osamp);
 
   *isamp = *osamp = len;
   while (len--) {             /* 16 signed bits of triangular noise */
     int tri16 = ((rand() % 32768) + (rand() % 32768)) - 32767;
     double l = *ibuf++ + tri16 * dither->amount;
-    *obuf++ = ST_ROUND_CLIP_COUNT(l, effp->clips);
+    *obuf++ = SOX_ROUND_CLIP_COUNT(l, effp->clips);
   }
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-st_effect_t const * st_dither_effect_fn(void)
+sox_effect_t const * sox_dither_effect_fn(void)
 {
-  static st_effect_t driver = {
-    "dither", "Usage: dither [amount]", ST_EFF_MCHAN,
+  static sox_effect_t driver = {
+    "dither", "Usage: dither [amount]", SOX_EFF_MCHAN,
     getopts, start, flow, 0, 0, 0
   };
   return &driver;
 }
 
-st_effect_t const * st_mask_effect_fn(void)
+sox_effect_t const * sox_mask_effect_fn(void)
 {
-  static st_effect_t driver = {
-    "mask", "Usage: mask [amount]", ST_EFF_MCHAN | ST_EFF_DEPRECATED,
+  static sox_effect_t driver = {
+    "mask", "Usage: mask [amount]", SOX_EFF_MCHAN | SOX_EFF_DEPRECATED,
     getopts, start, flow, 0, 0, 0
   };
   return &driver;
--- a/src/earwax.c
+++ b/src/earwax.c
@@ -22,9 +22,9 @@
  * the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
-static st_effect_t st_earwax_effect;
+static sox_effect_t sox_earwax_effect;
 
 #define EARWAX_SCALE 64
 
@@ -31,7 +31,7 @@
 /* A stereo fir filter. One side filters as if the signal was from
    30 degrees from the ear, the other as if 330 degrees. */
 /*                           30   330  */
-static const st_sample_t filt[]    =
+static const sox_sample_t filt[]    =
 {   4,  -6,
     4,  -11,
     -1,  -5,
@@ -69,13 +69,13 @@
 #define EARWAX_NUMTAPS  64
 
 typedef struct earwaxstuff {
-  st_sample_t *tap; /* taps are z^-1 delays for the FIR filter */
+  sox_sample_t *tap; /* taps are z^-1 delays for the FIR filter */
 } *earwax_t;
 
 /*
  * Prepare for processing.
  */
-static int st_earwax_start(eff_t effp)
+static int sox_earwax_start(eff_t effp)
 {
   earwax_t earwax = (earwax_t) effp->priv;
   int i;
@@ -82,12 +82,12 @@
 
   /* check the input format */
   if (effp->ininfo.rate != 44100 || effp->ininfo.channels != 2) {
-    st_fail("The earwax effect works only with 44.1 kHz, stereo audio.");
-    return (ST_EOF);
+    sox_fail("The earwax effect works only with 44.1 kHz, stereo audio.");
+    return (SOX_EOF);
   }
 
   /* allocate tap memory */
-  earwax->tap = (st_sample_t*)xmalloc( sizeof(st_sample_t) * EARWAX_NUMTAPS );
+  earwax->tap = (sox_sample_t*)xmalloc( sizeof(sox_sample_t) * EARWAX_NUMTAPS );
 
   /* zero out the delayed taps */
   for(i=0; i < EARWAX_NUMTAPS; i++ ){
@@ -94,7 +94,7 @@
     earwax->tap[i] = 0;
   }
 
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 /*
@@ -102,13 +102,13 @@
  * Return number of samples processed.
  */
 
-static int st_earwax_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                   st_size_t *isamp, st_size_t *osamp)
+static int sox_earwax_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                   sox_size_t *isamp, sox_size_t *osamp)
 {
   earwax_t earwax = (earwax_t) effp->priv;
   int len, done;
   int i;
-  st_sample_t output;
+  sox_sample_t output;
 
   len = ((*isamp > *osamp) ? *osamp : *isamp);
 
@@ -128,17 +128,17 @@
   }
 
   *isamp = *osamp = len;
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 /*
  * Drain out taps.
  */
-static int st_earwax_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_earwax_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
   earwax_t earwax = (earwax_t) effp->priv;
   int i,j;
-  st_sample_t output;  
+  sox_sample_t output;  
 
   for(i = EARWAX_NUMTAPS-1; i >= 0; i--){
     output = 0;
@@ -149,34 +149,34 @@
   }
   *osamp = EARWAX_NUMTAPS-1;
 
-  return (ST_EOF);
+  return (SOX_EOF);
 }
 
 /*
  * Clean up taps.
  */
-static int st_earwax_stop(eff_t effp)
+static int sox_earwax_stop(eff_t effp)
 {
   earwax_t earwax = (earwax_t) effp->priv;
 
   free((char *)earwax->tap);
 
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
-static st_effect_t st_earwax_effect = {
+static sox_effect_t sox_earwax_effect = {
   "earwax",
   "Usage: The earwax filtering effect takes no options",
-  ST_EFF_MCHAN,
-  st_effect_nothing_getopts,
-  st_earwax_start,
-  st_earwax_flow,
-  st_earwax_drain,
-  st_earwax_stop,
-  st_effect_nothing
+  SOX_EFF_MCHAN,
+  sox_effect_nothing_getopts,
+  sox_earwax_start,
+  sox_earwax_flow,
+  sox_earwax_drain,
+  sox_earwax_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_earwax_effect_fn(void)
+const sox_effect_t *sox_earwax_effect_fn(void)
 {
-    return &st_earwax_effect;
+    return &sox_earwax_effect;
 }
--- a/src/echo.c
+++ b/src/echo.c
@@ -57,11 +57,11 @@
 
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
 #include <math.h>
-#include "st_i.h"
+#include "sox_i.h"
 
-static st_effect_t st_echo_effect;
+static sox_effect_t sox_echo_effect;
 
-#define DELAY_BUFSIZ ( 50 * ST_MAXRATE )
+#define DELAY_BUFSIZ ( 50 * SOX_MAXRATE )
 #define MAX_ECHOS 7     /* 24 bit x ( 1 + MAX_ECHOS ) = */
                         /* 24 bit x 8 = 32 bit !!!      */
 
@@ -72,8 +72,8 @@
         double  *delay_buf;
         float   in_gain, out_gain;
         float   delay[MAX_ECHOS], decay[MAX_ECHOS];
-        st_ssize_t samples[MAX_ECHOS], maxsamples;
-        st_size_t fade_out;
+        sox_ssize_t samples[MAX_ECHOS], maxsamples;
+        sox_size_t fade_out;
 } *echo_t;
 
 /* Private data for SKEL file */
@@ -82,7 +82,7 @@
 /*
  * Process options
  */
-static int st_echo_getopts(eff_t effp, int n, char **argv) 
+static int sox_echo_getopts(eff_t effp, int n, char **argv) 
 {
         echo_t echo = (echo_t) effp->priv;
         int i;
@@ -91,8 +91,8 @@
 
         if ((n < 4) || (n % 2))
         {
-            st_fail(st_echo_effect.usage);
-            return (ST_EOF);
+            sox_fail(sox_echo_effect.usage);
+            return (SOX_EOF);
         }
 
         i = 0;
@@ -100,7 +100,7 @@
         sscanf(argv[i++], "%f", &echo->out_gain);
         while (i < n) {
                 if ( echo->num_delays >= MAX_ECHOS )
-                        st_fail("echo: to many delays, use less than %i delays",
+                        sox_fail("echo: to many delays, use less than %i delays",
                                 MAX_ECHOS);
                 /* Linux bug and it's cleaner. */
                 sscanf(argv[i++], "%f", &echo->delay[echo->num_delays]);
@@ -107,13 +107,13 @@
                 sscanf(argv[i++], "%f", &echo->decay[echo->num_delays]);
                 echo->num_delays++;
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Prepare for processing.
  */
-static int st_echo_start(eff_t effp)
+static int sox_echo_start(eff_t effp)
 {
         echo_t echo = (echo_t) effp->priv;
         int i;
@@ -123,41 +123,41 @@
         echo->maxsamples = 0;
         if ( echo->in_gain < 0.0 )
         {
-                st_fail("echo: gain-in must be positive!");
-                return (ST_EOF);
+                sox_fail("echo: gain-in must be positive!");
+                return (SOX_EOF);
         }
         if ( echo->in_gain > 1.0 )
         {
-                st_fail("echo: gain-in must be less than 1.0!");
-                return (ST_EOF);
+                sox_fail("echo: gain-in must be less than 1.0!");
+                return (SOX_EOF);
         }
         if ( echo->out_gain < 0.0 )
         {
-                st_fail("echo: gain-in must be positive!");
-                return (ST_EOF);
+                sox_fail("echo: gain-in must be positive!");
+                return (SOX_EOF);
         }
         for ( i = 0; i < echo->num_delays; i++ ) {
                 echo->samples[i] = echo->delay[i] * effp->ininfo.rate / 1000.0;
                 if ( echo->samples[i] < 1 )
                 {
-                    st_fail("echo: delay must be positive!");
-                    return (ST_EOF);
+                    sox_fail("echo: delay must be positive!");
+                    return (SOX_EOF);
                 }
-                if ( echo->samples[i] > (st_ssize_t)DELAY_BUFSIZ )
+                if ( echo->samples[i] > (sox_ssize_t)DELAY_BUFSIZ )
                 {
-                        st_fail("echo: delay must be less than %g seconds!",
+                        sox_fail("echo: delay must be less than %g seconds!",
                                 DELAY_BUFSIZ / (float) effp->ininfo.rate );
-                        return (ST_EOF);
+                        return (SOX_EOF);
                 }
                 if ( echo->decay[i] < 0.0 )
                 {
-                    st_fail("echo: decay must be positive!" );
-                    return (ST_EOF);
+                    sox_fail("echo: decay must be positive!" );
+                    return (SOX_EOF);
                 }
                 if ( echo->decay[i] > 1.0 )
                 {
-                    st_fail("echo: decay must be less than 1.0!" );
-                    return (ST_EOF);
+                    sox_fail("echo: decay must be less than 1.0!" );
+                    return (SOX_EOF);
                 }
                 if ( echo->samples[i] > echo->maxsamples )
                         echo->maxsamples = echo->samples[i];
@@ -170,10 +170,10 @@
         for ( i = 0; i < echo->num_delays; i++ ) 
                 sum_in_volume += echo->decay[i];
         if ( sum_in_volume * echo->in_gain > 1.0 / echo->out_gain )
-                st_warn("echo: warning >>> gain-out can cause saturation of output <<<");
+                sox_warn("echo: warning >>> gain-out can cause saturation of output <<<");
         echo->counter = 0;
         echo->fade_out = echo->maxsamples;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
@@ -180,8 +180,8 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_echo_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                 st_size_t *isamp, st_size_t *osamp)
+static int sox_echo_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                 sox_size_t *isamp, sox_size_t *osamp)
 {
         echo_t echo = (echo_t) effp->priv;
         int len, done;
@@ -188,7 +188,7 @@
         int j;
         
         double d_in, d_out;
-        st_sample_t out;
+        sox_sample_t out;
 
         len = ((*isamp > *osamp) ? *osamp : *isamp);
         for(done = 0; done < len; done++) {
@@ -203,7 +203,7 @@
                 }
                 /* Adjust the output volume and size to 24 bit */
                 d_out = d_out * echo->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 *obuf++ = out * 256;
                 /* Store input in delay buffer */
                 echo->delay_buf[echo->counter] = d_in;
@@ -211,19 +211,19 @@
                 echo->counter = ( echo->counter + 1 ) % echo->maxsamples;
         }
         /* processed all samples */
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Drain out reverb lines. 
  */
-static int st_echo_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_echo_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
         echo_t echo = (echo_t) effp->priv;
         double d_in, d_out;
-        st_sample_t out;
+        sox_sample_t out;
         int j;
-        st_size_t done;
+        sox_size_t done;
 
         done = 0;
         /* drain out delay samples */
@@ -237,7 +237,7 @@
                 }
                 /* Adjust the output volume and size to 24 bit */
                 d_out = d_out * echo->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 *obuf++ = out * 256;
                 /* Store input in delay buffer */
                 echo->delay_buf[echo->counter] = d_in;
@@ -249,36 +249,36 @@
         /* samples played, it remains */
         *osamp = done;
         if (echo->fade_out == 0)
-            return ST_EOF;
+            return SOX_EOF;
         else
-            return ST_SUCCESS;
+            return SOX_SUCCESS;
 }
 
 /*
  * Clean up reverb effect.
  */
-static int st_echo_stop(eff_t effp)
+static int sox_echo_stop(eff_t effp)
 {
         echo_t echo = (echo_t) effp->priv;
 
         free((char *) echo->delay_buf);
         echo->delay_buf = (double *) -1;   /* guaranteed core dump */
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_effect_t st_echo_effect = {
+static sox_effect_t sox_echo_effect = {
   "echo",
   "Usage: echo gain-in gain-out delay decay [ delay decay ... ]",
   0,
-  st_echo_getopts,
-  st_echo_start,
-  st_echo_flow,
-  st_echo_drain,
-  st_echo_stop,
-  st_effect_nothing
+  sox_echo_getopts,
+  sox_echo_start,
+  sox_echo_flow,
+  sox_echo_drain,
+  sox_echo_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_echo_effect_fn(void)
+const sox_effect_t *sox_echo_effect_fn(void)
 {
-    return &st_echo_effect;
+    return &sox_echo_effect;
 }
--- a/src/echos.c
+++ b/src/echos.c
@@ -48,11 +48,11 @@
 
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
 #include <math.h>
-#include "st_i.h"
+#include "sox_i.h"
 
-static st_effect_t st_echos_effect;
+static sox_effect_t sox_echos_effect;
 
-#define DELAY_BUFSIZ ( 50 * ST_MAXRATE )
+#define DELAY_BUFSIZ ( 50 * SOX_MAXRATE )
 #define MAX_ECHOS 7     /* 24 bit x ( 1 + MAX_ECHOS ) = */
                         /* 24 bit x 8 = 32 bit !!!      */
 
@@ -63,8 +63,8 @@
         double  *delay_buf;
         float   in_gain, out_gain;
         float   delay[MAX_ECHOS], decay[MAX_ECHOS];
-        st_ssize_t samples[MAX_ECHOS], pointer[MAX_ECHOS];
-        st_size_t sumsamples;
+        sox_ssize_t samples[MAX_ECHOS], pointer[MAX_ECHOS];
+        sox_size_t sumsamples;
 } *echos_t;
 
 /* Private data for SKEL file */
@@ -72,7 +72,7 @@
 /*
  * Process options
  */
-static int st_echos_getopts(eff_t effp, int n, char **argv) 
+static int sox_echos_getopts(eff_t effp, int n, char **argv) 
 {
         echos_t echos = (echos_t) effp->priv;
         int i;
@@ -81,8 +81,8 @@
 
         if ((n < 4) || (n % 2))
         {
-            st_fail(st_echos_effect.usage);
-            return (ST_EOF);
+            sox_fail(sox_echos_effect.usage);
+            return (SOX_EOF);
         }
 
         i = 0;
@@ -95,19 +95,19 @@
                 echos->num_delays++;
                 if ( echos->num_delays > MAX_ECHOS )
                 {
-                        st_fail("echos: to many delays, use less than %i delays",
+                        sox_fail("echos: to many delays, use less than %i delays",
                                 MAX_ECHOS);
-                        return (ST_EOF);
+                        return (SOX_EOF);
                 }
         }
         echos->sumsamples = 0;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Prepare for processing.
  */
-static int st_echos_start(eff_t effp)
+static int sox_echos_start(eff_t effp)
 {
         echos_t echos = (echos_t) effp->priv;
         int i;
@@ -116,41 +116,41 @@
 
         if ( echos->in_gain < 0.0 )
         {
-                st_fail("echos: gain-in must be positive!");
-                return (ST_EOF);
+                sox_fail("echos: gain-in must be positive!");
+                return (SOX_EOF);
         }
         if ( echos->in_gain > 1.0 )
         {
-                st_fail("echos: gain-in must be less than 1.0!");
-                return (ST_EOF);
+                sox_fail("echos: gain-in must be less than 1.0!");
+                return (SOX_EOF);
         }
         if ( echos->out_gain < 0.0 )
         {
-                st_fail("echos: gain-in must be positive!");
-                return (ST_EOF);
+                sox_fail("echos: gain-in must be positive!");
+                return (SOX_EOF);
         }
         for ( i = 0; i < echos->num_delays; i++ ) {
                 echos->samples[i] = echos->delay[i] * effp->ininfo.rate / 1000.0;
                 if ( echos->samples[i] < 1 )
                 {
-                    st_fail("echos: delay must be positive!");
-                    return (ST_EOF);
+                    sox_fail("echos: delay must be positive!");
+                    return (SOX_EOF);
                 }
-                if ( echos->samples[i] > (st_ssize_t)DELAY_BUFSIZ )
+                if ( echos->samples[i] > (sox_ssize_t)DELAY_BUFSIZ )
                 {
-                        st_fail("echos: delay must be less than %g seconds!",
+                        sox_fail("echos: delay must be less than %g seconds!",
                                 DELAY_BUFSIZ / (float) effp->ininfo.rate );
-                        return (ST_EOF);
+                        return (SOX_EOF);
                 }
                 if ( echos->decay[i] < 0.0 )
                 {
-                    st_fail("echos: decay must be positive!" );
-                    return (ST_EOF);
+                    sox_fail("echos: decay must be positive!" );
+                    return (SOX_EOF);
                 }
                 if ( echos->decay[i] > 1.0 )
                 {
-                    st_fail("echos: decay must be less than 1.0!" );
-                    return (ST_EOF);
+                    sox_fail("echos: decay must be less than 1.0!" );
+                    return (SOX_EOF);
                 }
                 echos->counter[i] = 0;
                 echos->pointer[i] = echos->sumsamples;
@@ -164,8 +164,8 @@
         for ( i = 0; i < echos->num_delays; i++ ) 
                 sum_in_volume += echos->decay[i];
         if ( sum_in_volume * echos->in_gain > 1.0 / echos->out_gain )
-                st_warn("echos: warning >>> gain-out can cause saturation of output <<<");
-        return (ST_SUCCESS);
+                sox_warn("echos: warning >>> gain-out can cause saturation of output <<<");
+        return (SOX_SUCCESS);
 }
 
 /*
@@ -172,8 +172,8 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_echos_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                st_size_t *isamp, st_size_t *osamp)
+static int sox_echos_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                sox_size_t *isamp, sox_size_t *osamp)
 {
         echos_t echos = (echos_t) effp->priv;
         int len, done;
@@ -180,7 +180,7 @@
         int j;
         
         double d_in, d_out;
-        st_sample_t out;
+        sox_sample_t out;
 
         len = ((*isamp > *osamp) ? *osamp : *isamp);
         for(done = 0; done < len; done++) {
@@ -193,7 +193,7 @@
                 }
                 /* Adjust the output volume and size to 24 bit */
                 d_out = d_out * echos->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 *obuf++ = out * 256;
                 /* Mix decay of delays and input */
                 for ( j = 0; j < echos->num_delays; j++ ) {
@@ -209,19 +209,19 @@
                            ( echos->counter[j] + 1 ) % echos->samples[j];
         }
         /* processed all samples */
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Drain out reverb lines. 
  */
-static int st_echos_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_echos_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
         echos_t echos = (echos_t) effp->priv;
         double d_in, d_out;
-        st_sample_t out;
+        sox_sample_t out;
         int j;
-        st_size_t done;
+        sox_size_t done;
 
         done = 0;
         /* drain out delay samples */
@@ -233,7 +233,7 @@
                 }
                 /* Adjust the output volume and size to 24 bit */
                 d_out = d_out * echos->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 *obuf++ = out * 256;
                 /* Mix decay of delays and input */
                 for ( j = 0; j < echos->num_delays; j++ ) {
@@ -253,36 +253,36 @@
         /* samples played, it remains */
         *osamp = done;
         if (echos->sumsamples == 0)
-            return ST_EOF;
+            return SOX_EOF;
         else
-            return ST_SUCCESS;
+            return SOX_SUCCESS;
 }
 
 /*
  * Clean up echos effect.
  */
-static int st_echos_stop(eff_t effp)
+static int sox_echos_stop(eff_t effp)
 {
         echos_t echos = (echos_t) effp->priv;
 
         free((char *) echos->delay_buf);
         echos->delay_buf = (double *) -1;   /* guaranteed core dump */
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_effect_t st_echos_effect = {
+static sox_effect_t sox_echos_effect = {
   "echos",
   "Usage: echos gain-in gain-out delay decay [ delay decay ... ]",
   0,
-  st_echos_getopts,
-  st_echos_start,
-  st_echos_flow,
-  st_echos_drain,
-  st_echos_stop,
-  st_effect_nothing
+  sox_echos_getopts,
+  sox_echos_start,
+  sox_echos_flow,
+  sox_echos_drain,
+  sox_echos_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_echos_effect_fn(void)
+const sox_effect_t *sox_echos_effect_fn(void)
 {
-    return &st_echos_effect;
+    return &sox_echos_effect;
 }
--- a/src/fade.c
+++ b/src/fade.c
@@ -21,14 +21,14 @@
 
 #include <math.h>
 #include <string.h>
-#include "st_i.h"
+#include "sox_i.h"
 
-static st_effect_t st_fade_effect;
+static sox_effect_t sox_fade_effect;
 
 /* Private data for fade file */
 typedef struct fadestuff
 { /* These are measured as samples */
-    st_size_t in_start, in_stop, out_start, out_stop, samplesdone;
+    sox_size_t in_start, in_stop, out_start, out_stop, samplesdone;
     char *in_stop_str, *out_start_str, *out_stop_str;
     char in_fadetype, out_fadetype;
     char do_out;
@@ -36,7 +36,7 @@
 } *fade_t;
 
 /* prototypes */
-static double fade_gain(st_size_t index, st_size_t range, char fadetype);
+static double fade_gain(sox_size_t index, sox_size_t range, char fadetype);
 
 /*
  * Process options
@@ -45,7 +45,7 @@
  * The 'info' fields are not yet filled in.
  */
 
-static int st_fade_getopts(eff_t effp, int n, char **argv)
+static int sox_fade_getopts(eff_t effp, int n, char **argv)
 {
 
     fade_t fade = (fade_t) effp->priv;
@@ -54,8 +54,8 @@
 
     if (n < 1 || n > 4)
     { /* Wrong number of arguments. */
-        st_fail(st_fade_effect.usage);
-        return(ST_EOF);
+        sox_fail(sox_fade_effect.usage);
+        return(SOX_EOF);
     }
 
     /* because sample rate is unavailable at this point we store the
@@ -80,10 +80,10 @@
     fade->in_stop_str = (char *)xmalloc(strlen(argv[0])+1);
     strcpy(fade->in_stop_str,argv[0]);
     /* Do a dummy parse to see if it will fail */
-    if (st_parsesamples(0, fade->in_stop_str, &fade->in_stop, 't') == NULL)
+    if (sox_parsesamples(0, fade->in_stop_str, &fade->in_stop, 't') == NULL)
     {
-        st_fail(st_fade_effect.usage);
-        return(ST_EOF);
+        sox_fail(sox_fade_effect.usage);
+        return(SOX_EOF);
     }
 
     fade->out_start_str = fade->out_stop_str = 0;
@@ -97,10 +97,10 @@
             strcpy(fade->out_stop_str,argv[t_argno]);
 
             /* Do a dummy parse to see if it will fail */
-            if (st_parsesamples(0, fade->out_stop_str, 
+            if (sox_parsesamples(0, fade->out_stop_str, 
                                 &fade->out_stop, 't') == NULL) {
-              st_fail(st_fade_effect.usage);
-              return(ST_EOF);
+              sox_fail(sox_fade_effect.usage);
+              return(SOX_EOF);
             }
         }
         else
@@ -109,15 +109,15 @@
             strcpy(fade->out_start_str,argv[t_argno]);
 
             /* Do a dummy parse to see if it will fail */
-            if (st_parsesamples(0, fade->out_start_str, 
+            if (sox_parsesamples(0, fade->out_start_str, 
                                 &fade->out_start, 't') == NULL) {
-              st_fail(st_fade_effect.usage);
-              return(ST_EOF);
+              sox_fail(sox_fade_effect.usage);
+              return(SOX_EOF);
             }
         }
     } /* End for(t_argno) */
 
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
 }
 
 /*
@@ -124,17 +124,17 @@
  * Prepare processing.
  * Do all initializations.
  */
-static int st_fade_start(eff_t effp)
+static int sox_fade_start(eff_t effp)
 {
     fade_t fade = (fade_t) effp->priv;
 
     /* converting time values to samples */
     fade->in_start = 0;
-    if (st_parsesamples(effp->ininfo.rate, fade->in_stop_str,
+    if (sox_parsesamples(effp->ininfo.rate, fade->in_stop_str,
                         &fade->in_stop, 't') == NULL)
     {
-        st_fail(st_fade_effect.usage);
-        return(ST_EOF);
+        sox_fail(sox_fade_effect.usage);
+        return(SOX_EOF);
     }
 
     fade->do_out = 0;
@@ -142,21 +142,21 @@
     if (fade->out_stop_str)
     {
         fade->do_out = 1;
-        if (st_parsesamples(effp->ininfo.rate, fade->out_stop_str,
+        if (sox_parsesamples(effp->ininfo.rate, fade->out_stop_str,
                             &fade->out_stop, 't') == NULL)
         {
-            st_fail(st_fade_effect.usage);
-            return(ST_EOF);
+            sox_fail(sox_fade_effect.usage);
+            return(SOX_EOF);
         }
 
         /* See if user wants to fade out. */
         if (fade->out_start_str)
         {
-            if (st_parsesamples(effp->ininfo.rate, fade->out_start_str,
+            if (sox_parsesamples(effp->ininfo.rate, fade->out_start_str,
                         &fade->out_start, 't') == NULL)
             {
-                st_fail(st_fade_effect.usage);
-                return(ST_EOF);
+                sox_fail(sox_fade_effect.usage);
+                return(SOX_EOF);
             }
             /* Fade time is relative to stop time. */
             fade->out_start = fade->out_stop - fade->out_start;
@@ -178,19 +178,19 @@
     /* Sanity check for fade times vs total time */
     if (fade->in_stop > fade->out_start && fade->out_start != 0)
     { /* Fades too long */
-        st_fail("Fade: End of fade-in should not happen before beginning of fade-out");
-        return(ST_EOF);
+        sox_fail("Fade: End of fade-in should not happen before beginning of fade-out");
+        return(SOX_EOF);
     } /* endif fade time sanity */
 
     fade->samplesdone = fade->in_start;
     fade->endpadwarned = 0;
 
-    st_debug("fade: in_start = %d in_stop = %d out_start = %d out_stop = %d", fade->in_start, fade->in_stop, fade->out_start, fade->out_stop);
+    sox_debug("fade: in_start = %d in_stop = %d out_start = %d out_stop = %d", fade->in_start, fade->in_stop, fade->out_start, fade->out_stop);
 
     if (fade->in_start == fade->in_stop && fade->out_start == fade->out_stop)
-      return ST_EFF_NULL;
+      return SOX_EFF_NULL;
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
@@ -197,14 +197,14 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_fade_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                 st_size_t *isamp, st_size_t *osamp)
+static int sox_fade_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                 sox_size_t *isamp, sox_size_t *osamp)
 {
     fade_t fade = (fade_t) effp->priv;
     /* len is total samples, chcnt counts channels */
     int len = 0, t_output = 1, more_output = 1;
-    st_sample_t t_ibuf;
-    st_size_t chcnt = 0;
+    sox_sample_t t_ibuf;
+    sox_size_t chcnt = 0;
 
     len = ((*isamp > *osamp) ? *osamp : *isamp);
 
@@ -270,19 +270,19 @@
      * this.
      */
     if (fade->do_out && fade->samplesdone >= fade->out_stop)
-        return ST_EOF;
+        return SOX_EOF;
     else
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
 }
 
 /*
  * Drain out remaining samples if the effect generates any.
  */
-static int st_fade_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_fade_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
     fade_t fade = (fade_t) effp->priv;
     int len;
-    st_size_t t_chan = 0;
+    sox_size_t t_chan = 0;
 
     len = *osamp;
     *osamp = 0;
@@ -290,7 +290,7 @@
     if (fade->do_out && fade->samplesdone < fade->out_stop &&
         !(fade->endpadwarned))
     { /* Warning about padding silence into end of sample */
-        st_warn("Fade: warning: End time passed end-of-file. Padding with silence");
+        sox_warn("Fade: warning: End time passed end-of-file. Padding with silence");
         fade->endpadwarned = 1;
     } /* endif endpadwarned */
 
@@ -310,9 +310,9 @@
     } /* endfor */
 
     if (fade->do_out && fade->samplesdone >= fade->out_stop)
-        return ST_EOF;
+        return SOX_EOF;
     else
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
 }
 
 /*
@@ -326,13 +326,13 @@
     free(fade->in_stop_str);
     free(fade->out_start_str);
     free(fade->out_stop_str);
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /* Function returns gain value 0.0 - 1.0 according index / range ratio
 * and -1.0 if  type is invalid
 * todo: to optimize performance calculate gain every now and then and interpolate */
-static double fade_gain(st_size_t index, st_size_t range, char type)
+static double fade_gain(sox_size_t index, sox_size_t range, char type)
 {
     double retval = 0.0, findex = 0.0;
 
@@ -371,21 +371,21 @@
     return retval;
 }
 
-static st_effect_t st_fade_effect = {
+static sox_effect_t sox_fade_effect = {
   "fade",
   "Usage: fade [ type ] fade-in-length [ stop-time [ fade-out-length ] ]\n"
   "       Time is in hh:mm:ss.frac format.\n"
   "       Fade type one of q, h, t, l or p.",
-  ST_EFF_MCHAN,
-  st_fade_getopts,
-  st_fade_start,
-  st_fade_flow,
-  st_fade_drain,
-  st_effect_nothing,
+  SOX_EFF_MCHAN,
+  sox_fade_getopts,
+  sox_fade_start,
+  sox_fade_flow,
+  sox_fade_drain,
+  sox_effect_nothing,
   delete
 };
 
-const st_effect_t *st_fade_effect_fn(void)
+const sox_effect_t *sox_fade_effect_fn(void)
 {
-    return &st_fade_effect;
+    return &sox_fade_effect;
 }
--- a/src/filter.c
+++ b/src/filter.c
@@ -25,9 +25,9 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "st_i.h"
+#include "sox_i.h"
 
-static st_effect_t st_filter_effect;
+static sox_effect_t sox_filter_effect;
 
 #define ISCALE 0x10000
 #define BUFFSIZE 8192
@@ -34,9 +34,9 @@
 
 /* Private data for Lerp via LCM file */
 typedef struct filterstuff {
-        st_rate_t rate;
-        st_sample_t freq0;/* low  corner freq */
-        st_sample_t freq1;/* high corner freq */
+        sox_rate_t rate;
+        sox_sample_t freq0;/* low  corner freq */
+        sox_sample_t freq1;/* high corner freq */
         double beta;/* >2 is kaiser window beta, <=2 selects nuttall window */
         long Nwin;
         double *Fp;/* [Xh+1] Filter coefficients */
@@ -54,7 +54,7 @@
 /*
  * Process options
  */
-static int st_filter_getopts(eff_t effp, int n, char **argv)
+static int sox_filter_getopts(eff_t effp, int n, char **argv)
 {
         filter_t f = (filter_t) effp->priv;
 
@@ -74,37 +74,37 @@
                 }
                 if (*p) f->freq1 = f->freq0 = 0;
         }
-        st_debug("freq: %d-%d", f->freq0, f->freq1);
+        sox_debug("freq: %d-%d", f->freq0, f->freq1);
         if (f->freq0 == 0 && f->freq1 == 0)
         {
-                st_fail(st_filter_effect.usage);
-                return (ST_EOF);
+                sox_fail(sox_filter_effect.usage);
+                return (SOX_EOF);
         }
 
         if ((n >= 2) && !sscanf(argv[1], "%ld", &f->Nwin))
         {
-                st_fail(st_filter_effect.usage);
-                return (ST_EOF);
+                sox_fail(sox_filter_effect.usage);
+                return (SOX_EOF);
         }
         else if (f->Nwin < 4) {
-                st_fail("filter: window length (%ld) <4 is too short", f->Nwin);
-                return (ST_EOF);
+                sox_fail("filter: window length (%ld) <4 is too short", f->Nwin);
+                return (SOX_EOF);
         }
 
         if ((n >= 3) && !sscanf(argv[2], "%lf", &f->beta))
         {
-                st_fail(st_filter_effect.usage);
-                return (ST_EOF);
+                sox_fail(sox_filter_effect.usage);
+                return (SOX_EOF);
         }
 
-        st_debug("filter opts: %d-%d, window-len %d, beta %f", f->freq0, f->freq1, f->Nwin, f->beta);
-        return (ST_SUCCESS);
+        sox_debug("filter opts: %d-%d, window-len %d, beta %f", f->freq0, f->freq1, f->Nwin, f->beta);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Prepare processing.
  */
-static int st_filter_start(eff_t effp)
+static int sox_filter_start(eff_t effp)
 {
         filter_t f = (filter_t) effp->priv;
         double *Fp0, *Fp1;
@@ -114,24 +114,24 @@
         f->rate = effp->ininfo.rate;
 
         /* adjust upper frequency to Nyquist if necessary */
-        if (f->freq1 > (st_sample_t)f->rate/2 || f->freq1 <= 0)
+        if (f->freq1 > (sox_sample_t)f->rate/2 || f->freq1 <= 0)
                 f->freq1 = f->rate/2;
 
         if ((f->freq0 < 0) || (f->freq0 > f->freq1))
         {
-                st_fail("filter: low(%d),high(%d) parameters must satisfy 0 <= low <= high <= %d",
+                sox_fail("filter: low(%d),high(%d) parameters must satisfy 0 <= low <= high <= %d",
                                         f->freq0, f->freq1, f->rate/2);
-                return (ST_EOF);
+                return (SOX_EOF);
         }
         
         Xh = f->Nwin/2;
         Fp0 = (double *) xmalloc(sizeof(double) * (Xh + 2)) + 1;
-        if (f->freq0 > (st_sample_t)f->rate/200) {
+        if (f->freq0 > (sox_sample_t)f->rate/200) {
                 Xh0 = makeFilter(Fp0, Xh, 2.0*(double)f->freq0/f->rate, f->beta, 1, 0);
                 if (Xh0 <= 1)
                 {
-                        st_fail("filter: Unable to make low filter");
-                        return (ST_EOF);
+                        sox_fail("filter: Unable to make low filter");
+                        return (SOX_EOF);
                 }
         } else {
                 Xh0 = 0;
@@ -138,12 +138,12 @@
         }
         Fp1 = (double *) xmalloc(sizeof(double) * (Xh + 2)) + 1;
         /* need Fp[-1] and Fp[Xh] for makeFilter */
-        if (f->freq1 < (st_sample_t)f->rate/2) {
+        if (f->freq1 < (sox_sample_t)f->rate/2) {
                 Xh1 = makeFilter(Fp1, Xh, 2.0*(double)f->freq1/f->rate, f->beta, 1, 0);
                 if (Xh1 <= 1)
                 {
-                        st_fail("filter: Unable to make high filter");
-                        return (ST_EOF);
+                        sox_fail("filter: Unable to make high filter");
+                        return (SOX_EOF);
                 }
         } else {
                 Fp1[0] = 1.0;
@@ -163,7 +163,7 @@
 
         Xh -= 1;       /* Xh = 0 can only happen if filter was identity 0-Nyquist */
         if (Xh<=0)
-                st_warn("filter: adjusted freq %d-%d is identity", f->freq0, f->freq1);
+                sox_warn("filter: adjusted freq %d-%d is identity", f->freq0, f->freq1);
 
         f->Nwin = 2*Xh + 1;  /* not really used afterwards */
         f->Xh = Xh;
@@ -175,7 +175,7 @@
         /* Need Xh zeros at beginning of X */
         for (i = 0; i < Xh; i++)
                 f->X[i] = 0;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
@@ -182,14 +182,14 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_filter_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                   st_size_t *isamp, st_size_t *osamp)
+static int sox_filter_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                   sox_size_t *isamp, sox_size_t *osamp)
 {
         filter_t f = (filter_t) effp->priv;
-        st_size_t i, Nx, Nproc;
+        sox_size_t i, Nx, Nproc;
 
         /* constrain amount we actually process */
-        /* st_debug("Xh %d, Xt %d, isamp %d, ",f->Xh, f->Xt, *isamp); */
+        /* sox_debug("Xh %d, Xt %d, isamp %d, ",f->Xh, f->Xt, *isamp); */
         Nx = BUFFSIZE + 2*f->Xh - f->Xt;
         if (Nx > *isamp) Nx = *isamp;
         if (Nx > *osamp) Nx = *osamp;
@@ -213,9 +213,9 @@
         if (Nproc <= 0) {
                 f->Xt += Nx;
                 *osamp = 0;
-                return (ST_SUCCESS);
+                return (SOX_SUCCESS);
         }
-        st_debug("flow Nproc %d",Nproc);
+        sox_debug("flow Nproc %d",Nproc);
         FiltWin(f, Nproc);
 
         /* Copy back portion of input signal that must be re-used */
@@ -228,19 +228,19 @@
                 *obuf++ = f->Y[i] * ISCALE;
 
         *osamp = Nproc;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Process tail of input samples.
  */
-static int st_filter_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_filter_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
         filter_t f = (filter_t) effp->priv;
         long isamp_res, osamp_res;
-        st_sample_t *Obuf;
+        sox_sample_t *Obuf;
 
-        st_debug("Xh %d, Xt %d  <--- DRAIN",f->Xh, f->Xt);
+        sox_debug("Xh %d, Xt %d  <--- DRAIN",f->Xh, f->Xt);
 
         /* stuff end with Xh zeros */
         isamp_res = f->Xh;
@@ -247,11 +247,11 @@
         osamp_res = *osamp;
         Obuf = obuf;
         while (isamp_res>0 && osamp_res>0) {
-                st_sample_t Isamp, Osamp;
+                sox_sample_t Isamp, Osamp;
                 Isamp = isamp_res;
                 Osamp = osamp_res;
-                st_filter_flow(effp, NULL, Obuf, (st_size_t *)&Isamp, (st_size_t *)&Osamp);
-          /* st_debug("DRAIN isamp,osamp  (%d,%d) -> (%d,%d)",
+                sox_filter_flow(effp, NULL, Obuf, (sox_size_t *)&Isamp, (sox_size_t *)&Osamp);
+          /* sox_debug("DRAIN isamp,osamp  (%d,%d) -> (%d,%d)",
                  * isamp_res,osamp_res,Isamp,Osamp); */
                 Obuf += Osamp;
                 osamp_res -= Osamp;
@@ -258,13 +258,13 @@
                 isamp_res -= Isamp;
         };
         *osamp -= osamp_res;
-        /* st_debug("DRAIN osamp %d", *osamp); */
+        /* sox_debug("DRAIN osamp %d", *osamp); */
         if (isamp_res)
-                st_warn("drain overran obuf by %d", isamp_res);
+                sox_warn("drain overran obuf by %d", isamp_res);
         /* FIXME: This is very picky. osamp better be big enough to grab
          * all remaining samples or they will be discarded.
          */
-        return (ST_EOF);
+        return (SOX_EOF);
 }
 
 /*
@@ -271,13 +271,13 @@
  * Do anything required when you stop reading samples.  
  * Don't close input file! 
  */
-static int st_filter_stop(eff_t effp)
+static int sox_filter_stop(eff_t effp)
 {
         filter_t f = (filter_t) effp->priv;
 
         free(f->Fp - 1);
         free(f->X);
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 static double jprod(const double *Fp, const double *Xp, long ct)
@@ -310,19 +310,19 @@
         }
 }
 
-static st_effect_t st_filter_effect = {
+static sox_effect_t sox_filter_effect = {
   "filter",
   "Usage: filter low-high [ windowlength [ beta ] ]",
   0,
-  st_filter_getopts,
-  st_filter_start,
-  st_filter_flow,
-  st_filter_drain,
-  st_filter_stop,
-  st_effect_nothing
+  sox_filter_getopts,
+  sox_filter_start,
+  sox_filter_flow,
+  sox_filter_drain,
+  sox_filter_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_filter_effect_fn(void)
+const sox_effect_t *sox_filter_effect_fn(void)
 {
-    return &st_filter_effect;
+    return &sox_filter_effect;
 }
--- a/src/flac.c
+++ b/src/flac.c
@@ -18,7 +18,7 @@
 
 
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #ifdef HAVE_LIBFLAC
 
@@ -62,7 +62,7 @@
 
 
 
-assert_static(sizeof(Decoder) <= ST_MAX_FILE_PRIVSIZE, /* else */ Decoder__PRIVSIZE_too_big);
+assert_static(sizeof(Decoder) <= SOX_MAX_FILE_PRIVSIZE, /* else */ Decoder__PRIVSIZE_too_big);
 
 
 
@@ -86,7 +86,7 @@
       return;
 
     if (format->comment != NULL) {
-      st_warn("FLAC: multiple Vorbis comment block ignored");
+      sox_warn("FLAC: multiple Vorbis comment block ignored");
       return;
     }
 
@@ -111,7 +111,7 @@
 
   (void) flac;
 
-  st_fail_errno(format, ST_EINVAL, "%s", FLAC__StreamDecoderErrorStatusString[status]);
+  sox_fail_errno(format, SOX_EINVAL, "%s", FLAC__StreamDecoderErrorStatusString[status]);
 }
 
 
@@ -124,7 +124,7 @@
   (void) flac;
 
   if (frame->header.bits_per_sample != decoder->bits_per_sample || frame->header.channels != decoder->channels || frame->header.sample_rate != decoder->sample_rate) {
-    st_fail_errno(format, ST_EINVAL, "FLAC ERROR: parameters differ between frame and header");
+    sox_fail_errno(format, SOX_EINVAL, "FLAC ERROR: parameters differ between frame and header");
     return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
   }
 
@@ -143,11 +143,11 @@
   memset(decoder, 0, sizeof(*decoder));
   decoder->flac = FLAC__stream_decoder_new();
   if (decoder->flac == NULL) {
-    st_fail_errno(format, ST_ENOMEM, "FLAC ERROR creating the decoder instance");
-    return ST_EOF;
+    sox_fail_errno(format, SOX_ENOMEM, "FLAC ERROR creating the decoder instance");
+    return SOX_EOF;
   }
 
-  FLAC__stream_decoder_set_md5_checking(decoder->flac, st_true);
+  FLAC__stream_decoder_set_md5_checking(decoder->flac, sox_true);
   FLAC__stream_decoder_set_metadata_respond_all(decoder->flac);
 #if FLAC_API_VERSION_CURRENT <= 7
   FLAC__file_decoder_set_filename(decoder->flac, format->filename);
@@ -165,14 +165,14 @@
     FLAC__decoder_error_callback,
     format) != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
 #endif
-    st_fail_errno(format, ST_EHDR, "FLAC ERROR initialising decoder");
-    return ST_EOF;
+    sox_fail_errno(format, SOX_EHDR, "FLAC ERROR initialising decoder");
+    return SOX_EOF;
   }
 
 
   if (!FLAC__stream_decoder_process_until_end_of_metadata(decoder->flac)) {
-    st_fail_errno(format, ST_EHDR, "FLAC ERROR whilst decoding metadata");
-    return ST_EOF;
+    sox_fail_errno(format, SOX_EHDR, "FLAC ERROR whilst decoding metadata");
+    return SOX_EOF;
   }
 
 #if FLAC_API_VERSION_CURRENT <= 7
@@ -180,20 +180,20 @@
 #else
   if (FLAC__stream_decoder_get_state(decoder->flac) > FLAC__STREAM_DECODER_END_OF_STREAM) {
 #endif
-    st_fail_errno(format, ST_EHDR, "FLAC ERROR during metadata decoding");
-    return ST_EOF;
+    sox_fail_errno(format, SOX_EHDR, "FLAC ERROR during metadata decoding");
+    return SOX_EOF;
   }
 
-  format->signal.encoding = ST_ENCODING_FLAC;
+  format->signal.encoding = SOX_ENCODING_FLAC;
   format->signal.rate = decoder->sample_rate;
   format->signal.size = decoder->bits_per_sample >> 3;
   format->signal.channels = decoder->channels;
   format->length = decoder->total_samples * decoder->channels;
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
-static st_size_t read(ft_t const format, st_sample_t * sampleBuffer, st_size_t const requested)
+static sox_size_t read(ft_t const format, sox_sample_t * sampleBuffer, sox_size_t const requested)
 {
   Decoder * decoder = (Decoder *) format->priv;
   size_t actual = 0;
@@ -202,7 +202,7 @@
     if (decoder->wide_sample_number >= decoder->number_of_wide_samples)
       FLAC__stream_decoder_process_single(decoder->flac);
     if (decoder->wide_sample_number >= decoder->number_of_wide_samples)
-      decoder->eof = st_true;
+      decoder->eof = sox_true;
     else {
       unsigned channel;
 
@@ -209,10 +209,10 @@
       for (channel = 0; channel < decoder->channels; channel++, actual++) {
         FLAC__int32 d = decoder->decoded_wide_samples[channel][decoder->wide_sample_number];
         switch (decoder->bits_per_sample) {
-        case  8: *sampleBuffer++ = ST_SIGNED_BYTE_TO_SAMPLE(d,); break;
-        case 16: *sampleBuffer++ = ST_SIGNED_WORD_TO_SAMPLE(d,); break;
-        case 24: *sampleBuffer++ = ST_SIGNED_24BIT_TO_SAMPLE(d,); break;
-        case 32: *sampleBuffer++ = ST_SIGNED_DWORD_TO_SAMPLE(d,); break;
+        case  8: *sampleBuffer++ = SOX_SIGNED_BYTE_TO_SAMPLE(d,); break;
+        case 16: *sampleBuffer++ = SOX_SIGNED_WORD_TO_SAMPLE(d,); break;
+        case 24: *sampleBuffer++ = SOX_SIGNED_24BIT_TO_SAMPLE(d,); break;
+        case 32: *sampleBuffer++ = SOX_SIGNED_DWORD_TO_SAMPLE(d,); break;
         }
       }
       ++decoder->wide_sample_number;
@@ -228,9 +228,9 @@
   Decoder * decoder = (Decoder *) format->priv;
 
   if (!FLAC__stream_decoder_finish(decoder->flac) && decoder->eof)
-    st_warn("FLAC decoder MD5 checksum mismatch.");
+    sox_warn("FLAC decoder MD5 checksum mismatch.");
   FLAC__stream_decoder_delete(decoder->flac);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
@@ -249,7 +249,7 @@
 
 
 
-assert_static(sizeof(Encoder) <= ST_MAX_FILE_PRIVSIZE, /* else */ Encoder__PRIVSIZE_too_big);
+assert_static(sizeof(Encoder) <= SOX_MAX_FILE_PRIVSIZE, /* else */ Encoder__PRIVSIZE_too_big);
 
 
 
@@ -258,7 +258,7 @@
   ft_t const format = (ft_t) client_data;
   (void) flac, (void) samples, (void) current_frame;
 
-  return st_writebuf(format, buffer, 1, bytes) == bytes ? FLAC__STREAM_ENCODER_WRITE_STATUS_OK : FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
+  return sox_writebuf(format, buffer, 1, bytes) == bytes ? FLAC__STREAM_ENCODER_WRITE_STATUS_OK : FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
 }
 
 
@@ -277,7 +277,7 @@
   (void) encoder;
   if (!format->seekable)
     return FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED;
-  else if (st_seeki(format, (st_size_t)absolute_byte_offset, SEEK_SET) != ST_SUCCESS)
+  else if (sox_seeki(format, (sox_size_t)absolute_byte_offset, SEEK_SET) != SOX_SUCCESS)
     return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR;
   else
     return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
@@ -311,10 +311,10 @@
   memset(encoder, 0, sizeof(*encoder));
   encoder->flac = FLAC__stream_encoder_new();
   if (encoder->flac == NULL) {
-    st_fail_errno(format, ST_ENOMEM, "FLAC ERROR creating the encoder instance");
-    return ST_EOF;
+    sox_fail_errno(format, SOX_ENOMEM, "FLAC ERROR creating the encoder instance");
+    return SOX_EOF;
   }
-  encoder->decoded_samples = xmalloc(ST_BUFSIZ * sizeof(FLAC__int32));
+  encoder->decoded_samples = xmalloc(SOX_BUFSIZ * sizeof(FLAC__int32));
 
   {     /* Select and set FLAC encoder options: */
     static struct {
@@ -326,15 +326,15 @@
       unsigned max_residual_partition_order;
       unsigned min_residual_partition_order;
     } const options[] = {
-      {1152, st_false, st_false, st_false, 0, 2, 2},
-      {1152, st_false, st_true, st_true, 0, 2, 2},
-      {1152, st_false, st_true, st_false, 0, 3, 0},
-      {4608, st_false, st_false, st_false, 6, 3, 3},
-      {4608, st_false, st_true, st_true, 8, 3, 3},
-      {4608, st_false, st_true, st_false, 8, 3, 3},
-      {4608, st_false, st_true, st_false, 8, 4, 0},
-      {4608, st_true, st_true, st_false, 8, 6, 0},
-      {4608, st_true, st_true, st_false, 12, 6, 0},
+      {1152, sox_false, sox_false, sox_false, 0, 2, 2},
+      {1152, sox_false, sox_true, sox_true, 0, 2, 2},
+      {1152, sox_false, sox_true, sox_false, 0, 3, 0},
+      {4608, sox_false, sox_false, sox_false, 6, 3, 3},
+      {4608, sox_false, sox_true, sox_true, 8, 3, 3},
+      {4608, sox_false, sox_true, sox_false, 8, 3, 3},
+      {4608, sox_false, sox_true, sox_false, 8, 4, 0},
+      {4608, sox_true, sox_true, sox_false, 8, 6, 0},
+      {4608, sox_true, sox_true, sox_false, 12, 6, 0},
     };
     unsigned compression_level = array_length(options) - 1; /* Default to "best" */
 
@@ -342,15 +342,15 @@
       compression_level = format->signal.compression;
       if (compression_level != format->signal.compression || 
           compression_level >= array_length(options)) {
-        st_fail_errno(format, ST_EINVAL,
+        sox_fail_errno(format, SOX_EINVAL,
                       "FLAC compression level must be a whole number from 0 to %i",
                       array_length(options) - 1);
-        return ST_EOF;
+        return SOX_EOF;
       }
     }
 
 #define SET_OPTION(x) do {\
-  st_report("FLAC "#x" = %i", options[compression_level].x); \
+  sox_report("FLAC "#x" = %i", options[compression_level].x); \
   FLAC__stream_encoder_set_##x(encoder->flac, options[compression_level].x);\
 } while (0)
     SET_OPTION(blocksize);
@@ -366,12 +366,12 @@
   }
 
   /* FIXME: FLAC should not need to know about this oddity */
-  if (format->signal.encoding < ST_ENCODING_SIZE_IS_WORD)
-    format->signal.size = ST_SIZE_16BIT;
+  if (format->signal.encoding < SOX_ENCODING_SIZE_IS_WORD)
+    format->signal.size = SOX_SIZE_16BIT;
 
   encoder->bits_per_sample = (format->signal.size > 4 ? 4 : format->signal.size) << 3;
 
-  st_report("FLAC encoding at %i bits per sample", encoder->bits_per_sample);
+  sox_report("FLAC encoding at %i bits per sample", encoder->bits_per_sample);
 
   FLAC__stream_encoder_set_channels(encoder->flac, format->signal.channels);
   FLAC__stream_encoder_set_bits_per_sample(encoder->flac, encoder->bits_per_sample);
@@ -381,12 +381,12 @@
     static const unsigned streamable_rates[] =
       {8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000};
     size_t i;
-    st_bool streamable = st_false;
+    sox_bool streamable = sox_false;
     for (i = 0; !streamable && i < array_length(streamable_rates); ++i)
        streamable = (streamable_rates[i] == format->signal.rate);
     if (!streamable) {
-      st_report("FLAC: non-standard rate; output may not be streamable");
-      FLAC__stream_encoder_set_streamable_subset(encoder->flac, st_false);
+      sox_report("FLAC: non-standard rate; output may not be streamable");
+      FLAC__stream_encoder_set_streamable_subset(encoder->flac, sox_false);
     }
   }
 
@@ -421,7 +421,7 @@
       }
       entry.length = strlen((char const *) entry.entry);
 
-      FLAC__metadata_object_vorbiscomment_append_comment(metadata[0], entry, /*copy= */ st_true);
+      FLAC__metadata_object_vorbiscomment_append_comment(metadata[0], entry, /*copy= */ sox_true);
     } while (end_of_comment != NULL);
 
     FLAC__stream_encoder_set_metadata(encoder->flac, metadata, 1);
@@ -439,15 +439,15 @@
 #endif
 
   if (status != FLAC__STREAM_ENCODER_OK) {
-    st_fail_errno(format, ST_EINVAL, "%s", FLAC__StreamEncoderStateString[status]);
-    return ST_EOF;
+    sox_fail_errno(format, SOX_EINVAL, "%s", FLAC__StreamEncoderStateString[status]);
+    return SOX_EOF;
   }
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
 
-static st_size_t write(ft_t const format, st_sample_t const * const sampleBuffer, st_size_t const len)
+static sox_size_t write(ft_t const format, sox_sample_t const * const sampleBuffer, sox_size_t const len)
 {
   Encoder * encoder = (Encoder *) format->priv;
   unsigned i;
@@ -454,10 +454,10 @@
 
   for (i = 0; i < len; ++i) {
     switch (encoder->bits_per_sample) {
-      case  8: encoder->decoded_samples[i] = ST_SAMPLE_TO_SIGNED_BYTE(sampleBuffer[i], format->clips); break;
-      case 16: encoder->decoded_samples[i] = ST_SAMPLE_TO_SIGNED_WORD(sampleBuffer[i], format->clips); break;
-      case 24: encoder->decoded_samples[i] = ST_SAMPLE_TO_SIGNED_24BIT(sampleBuffer[i],format->clips); break;
-      case 32: encoder->decoded_samples[i] = ST_SAMPLE_TO_SIGNED_DWORD(sampleBuffer[i],format->clips); break;
+      case  8: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_BYTE(sampleBuffer[i], format->clips); break;
+      case 16: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_WORD(sampleBuffer[i], format->clips); break;
+      case 24: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_24BIT(sampleBuffer[i],format->clips); break;
+      case 32: encoder->decoded_samples[i] = SOX_SAMPLE_TO_SIGNED_DWORD(sampleBuffer[i],format->clips); break;
     }
   }
   FLAC__stream_encoder_process_interleaved(encoder->flac, encoder->decoded_samples, len / format->signal.channels);
@@ -476,18 +476,18 @@
   FLAC__stream_encoder_delete(encoder->flac);
   free(encoder->decoded_samples);
   if (state != FLAC__STREAM_ENCODER_OK) {
-    st_fail_errno(format, ST_EINVAL, "FLAC ERROR: failed to encode to end of stream");
-    return ST_EOF;
+    sox_fail_errno(format, SOX_EINVAL, "FLAC ERROR: failed to encode to end of stream");
+    return SOX_EOF;
   }
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
 
-st_format_t const * st_flac_format_fn(void)
+sox_format_t const * sox_flac_format_fn(void)
 {
   static char const * const names[] = {"flac", NULL};
-  static st_format_t const driver = {
+  static sox_format_t const driver = {
     names, NULL, 0,
     start_read, read, stop_read,
     start_write, write, stop_write,
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -16,7 +16,7 @@
 
 /* Effect: Stereo Flanger   (c) 2006 robs@users.sourceforge.net */
 
-#define st_flanger_usage \
+#define sox_flanger_usage \
   "Usage: flanger [delay depth regen width speed shape phase interp]\n"
 /*
   "                  .\n" \
@@ -53,7 +53,7 @@
 
 
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <math.h>
 #include <string.h>
 
@@ -72,26 +72,26 @@
   double     feedback_gain;
   double     delay_gain;
   double     speed;
-  st_wave_t  wave_shape;
+  sox_wave_t  wave_shape;
   double     channel_phase;
   interp_t   interpolation;
             
   /* Delay buffers */
   double *   delay_bufs[MAX_CHANNELS];
-  st_size_t  delay_buf_length;
-  st_size_t  delay_buf_pos;
+  sox_size_t  delay_buf_length;
+  sox_size_t  delay_buf_pos;
   double     delay_last[MAX_CHANNELS];
             
   /* Low Frequency Oscillator */
   float *    lfo;
-  st_size_t  lfo_length;
-  st_size_t  lfo_pos;
+  sox_size_t  lfo_length;
+  sox_size_t  lfo_pos;
             
   /* Balancing */
   double     in_gain;
 } * flanger_t;
 
-assert_static(sizeof(struct flanger) <= ST_MAX_EFFECT_PRIVSIZE,
+assert_static(sizeof(struct flanger) <= SOX_MAX_EFFECT_PRIVSIZE,
               /* else */ flanger_PRIVSIZE_too_big);
 
 
@@ -110,8 +110,8 @@
   d = strtod(*argv, &end_ptr); \
   if (end_ptr != *argv) { \
     if (d < min || d > max || *end_ptr != '\0') { \
-      st_fail(effp->h->usage); \
-      return ST_EOF; \
+      sox_fail(effp->h->usage); \
+      return SOX_EOF; \
     } \
     f->p = d; \
     --argc, ++argv; \
@@ -132,7 +132,7 @@
 
 
 
-static int st_flanger_getopts(eff_t effp, int argc, char *argv[])
+static int sox_flanger_getopts(eff_t effp, int argc, char *argv[])
 {
   flanger_t f = (flanger_t) effp->priv;
 
@@ -148,17 +148,17 @@
     NUMERIC_PARAMETER(feedback_gain,-95 , 95 )
     NUMERIC_PARAMETER(delay_gain   , 0  , 100)
     NUMERIC_PARAMETER(speed        , 0.1, 10 )
-    TEXTUAL_PARAMETER(wave_shape, st_wave_enum)
+    TEXTUAL_PARAMETER(wave_shape, sox_wave_enum)
     NUMERIC_PARAMETER(channel_phase, 0  , 100)
     TEXTUAL_PARAMETER(interpolation, interp_enum)
   } while (0);
 
   if (argc != 0) {
-    st_fail(effp->h->usage);
-    return ST_EOF;
+    sox_fail(effp->h->usage);
+    return SOX_EOF;
   }
 
-  st_report("parameters:\n"
+  sox_report("parameters:\n"
       "delay = %gms\n"
       "depth = %gms\n"
       "regen = %g%%\n"
@@ -172,23 +172,23 @@
       f->feedback_gain,
       f->delay_gain,
       f->speed,
-      st_wave_enum[f->wave_shape].text,
+      sox_wave_enum[f->wave_shape].text,
       f->channel_phase,
       interp_enum[f->interpolation].text);
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
 
-static int st_flanger_start(eff_t effp)
+static int sox_flanger_start(eff_t effp)
 {
   flanger_t f = (flanger_t) effp->priv;
   int c, channels = effp->ininfo.channels;
 
   if (channels > MAX_CHANNELS) {
-    st_fail("Can not operate with more than %i channels", MAX_CHANNELS);
-    return ST_EOF;
+    sox_fail("Can not operate with more than %i channels", MAX_CHANNELS);
+    return SOX_EOF;
   }
 
   /* Scale percentages to unity: */
@@ -203,7 +203,7 @@
   /* Balance feedback loop: */
   f->delay_gain *= 1 - fabs(f->feedback_gain);
 
-  st_debug("in_gain=%g feedback_gain=%g delay_gain=%g\n",
+  sox_debug("in_gain=%g feedback_gain=%g delay_gain=%g\n",
       f->in_gain, f->feedback_gain, f->delay_gain);
 
   /* Create the delay buffers, one for each channel: */
@@ -217,29 +217,29 @@
   /* Create the LFO lookup table: */
   f->lfo_length = effp->ininfo.rate / f->speed;
   f->lfo = xcalloc(f->lfo_length, sizeof(*f->lfo));
-  st_generate_wave_table(
+  sox_generate_wave_table(
       f->wave_shape,
-      ST_FLOAT,
+      SOX_FLOAT,
       f->lfo,
       f->lfo_length,
-      (st_size_t)(f->delay_min / 1000 * effp->ininfo.rate + .5),
+      (sox_size_t)(f->delay_min / 1000 * effp->ininfo.rate + .5),
       f->delay_buf_length - 2,
       3 * M_PI_2);  /* Start the sweep at minimum delay (for mono at least) */
 
-  st_debug("delay_buf_length=%u lfo_length=%u\n",
+  sox_debug("delay_buf_length=%u lfo_length=%u\n",
       f->delay_buf_length, f->lfo_length);
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
 
-static int st_flanger_flow(eff_t effp, st_sample_t const * ibuf,
-    st_sample_t * obuf, st_size_t * isamp, st_size_t * osamp)
+static int sox_flanger_flow(eff_t effp, sox_sample_t const * ibuf,
+    sox_sample_t * obuf, sox_size_t * isamp, sox_size_t * osamp)
 {
   flanger_t f = (flanger_t) effp->priv;
   int c, channels = effp->ininfo.channels;
-  st_size_t len = (*isamp > *osamp ? *osamp : *isamp) / channels;
+  sox_size_t len = (*isamp > *osamp ? *osamp : *isamp) / channels;
 
   *isamp = *osamp = len * channels;
 
@@ -250,10 +250,10 @@
       double delayed_0, delayed_1;
       double delayed;
       double in, out;
-      st_size_t channel_phase = c * f->lfo_length * f->channel_phase + .5;
+      sox_size_t channel_phase = c * f->lfo_length * f->channel_phase + .5;
       double delay = f->lfo[(f->lfo_pos + channel_phase) % f->lfo_length];
       double frac_delay = modf(delay, &delay);
-      st_size_t int_delay = (size_t)delay;
+      sox_size_t int_delay = (size_t)delay;
 
       in = *ibuf++;
       f->delay_bufs[c][f->delay_buf_pos] = in + f->delay_last[c] * f->feedback_gain;
@@ -279,17 +279,17 @@
 
       f->delay_last[c] = delayed;
       out = in * f->in_gain + delayed * f->delay_gain;
-      *obuf++ = ST_ROUND_CLIP_COUNT(out, effp->clips);
+      *obuf++ = SOX_ROUND_CLIP_COUNT(out, effp->clips);
     }
     f->lfo_pos = (f->lfo_pos + 1) % f->lfo_length;
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
 
-static int st_flanger_stop(eff_t effp)
+static int sox_flanger_stop(eff_t effp)
 {
   flanger_t f = (flanger_t) effp->priv;
   int c, channels = effp->ininfo.channels;
@@ -301,26 +301,26 @@
 
   memset(f, 0, sizeof(*f));
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
 
-static st_effect_t st_flanger_effect = {
+static sox_effect_t sox_flanger_effect = {
   "flanger",
-  st_flanger_usage,
-  ST_EFF_MCHAN,
-  st_flanger_getopts,
-  st_flanger_start,
-  st_flanger_flow,
-  st_effect_nothing_drain,
-  st_flanger_stop,
-  st_effect_nothing
+  sox_flanger_usage,
+  SOX_EFF_MCHAN,
+  sox_flanger_getopts,
+  sox_flanger_start,
+  sox_flanger_flow,
+  sox_effect_nothing_drain,
+  sox_flanger_stop,
+  sox_effect_nothing
 };
 
 
 
-st_effect_t const * st_flanger_effect_fn(void)
+sox_effect_t const * sox_flanger_effect_fn(void)
 {
-  return &st_flanger_effect;
+  return &sox_flanger_effect;
 }
--- a/src/g711.c
+++ b/src/g711.c
@@ -11,10 +11,10 @@
  * implied warranty.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "g711.h"
 
-int16_t _st_alaw2linear16[256] = {
+int16_t _sox_alaw2linear16[256] = {
      -5504,   -5248,   -6016,   -5760,   -4480,   -4224,   -4992,
      -4736,   -7552,   -7296,   -8064,   -7808,   -6528,   -6272,
      -7040,   -6784,   -2752,   -2624,   -3008,   -2880,   -2240,
@@ -54,7 +54,7 @@
        816,     784,     880,     848
 };
 
-uint8_t _st_13linear2alaw[0x2000] = {
+uint8_t _sox_13linear2alaw[0x2000] = {
    0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
    0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
    0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
@@ -740,7 +740,7 @@
    0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
 };
 
-int16_t _st_ulaw2linear16[256] = {
+int16_t _sox_ulaw2linear16[256] = {
     -32124,  -31100,  -30076,  -29052,  -28028,  -27004,  -25980,
     -24956,  -23932,  -22908,  -21884,  -20860,  -19836,  -18812,
     -17788,  -16764,  -15996,  -15484,  -14972,  -14460,  -13948,
@@ -780,7 +780,7 @@
         24,      16,       8,       0
 };
 
-uint8_t _st_14linear2ulaw[0x4000] = {
+uint8_t _sox_14linear2ulaw[0x4000] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -2197,7 +2197,7 @@
  * For further information see John C. Bellamy's Digital Telephony, 1982,
  * John Wiley & Sons, pps 98-111 and 472-476.
  */
-unsigned char st_13linear2alaw(
+unsigned char sox_13linear2alaw(
 	int16_t		pcm_val)	/* 2's complement (13-bit range) */
 {
 	int16_t		mask;
@@ -2237,7 +2237,7 @@
  * alaw2linear() - Convert an A-law value to 16-bit signed linear PCM
  *
  */
-int16_t st_alaw2linear16(
+int16_t sox_alaw2linear16(
 	unsigned char	a_val)
 {
 	int16_t t;
@@ -2296,7 +2296,7 @@
  * For further information see John C. Bellamy's Digital Telephony, 1982,
  * John Wiley & Sons, pps 98-111 and 472-476.
  */
-unsigned char st_14linear2ulaw(
+unsigned char sox_14linear2ulaw(
 	int16_t		pcm_val)	/* 2's complement (14-bit range) */
 {
 	int16_t		mask;
@@ -2343,7 +2343,7 @@
  * Note that this function expects to be passed the complement of the
  * original code word. This is in keeping with ISDN conventions.
  */
-int16_t st_ulaw2linear16(
+int16_t sox_ulaw2linear16(
 	unsigned char	u_val)
 {
 	int16_t		t;
@@ -2366,10 +2366,10 @@
     int x, y, find2a = 0;
 
     y = 0;
-    printf("int16_t _st_alaw2linear16[256] = {\n  ");
+    printf("int16_t _sox_alaw2linear16[256] = {\n  ");
     for (x = 0; x < 256; x++)
     {
-	printf("%8d,", st_alaw2linear16(x));
+	printf("%8d,", sox_alaw2linear16(x));
 	y++;
 	if (y == 7)
 	{
@@ -2378,11 +2378,11 @@
 	}
     }
 
-    printf("\n};\n\nuint8_t _st_13linear2alaw[0x2000] = {\n  ");
+    printf("\n};\n\nuint8_t _sox_13linear2alaw[0x2000] = {\n  ");
     y = 0;
     for (x = 0; x < 0x2000; x++)
     {
-	printf(" 0x%02x,", st_13linear2alaw((-0x1000)+x));
+	printf(" 0x%02x,", sox_13linear2alaw((-0x1000)+x));
 	y++;
 	if (y == 12)
 	{
@@ -2391,11 +2391,11 @@
 	}
     }
 
-    printf("\n};\n\nint16_t _st_ulaw2linear16[256] = {\n  ");
+    printf("\n};\n\nint16_t _sox_ulaw2linear16[256] = {\n  ");
     y = 0;
     for (x = 0; x < 256; x++)
     {
-	printf("%8d,", st_ulaw2linear16(x));
+	printf("%8d,", sox_ulaw2linear16(x));
 	y++;
 	if (y == 7)
 	{
@@ -2404,11 +2404,11 @@
 	}
     }
 
-    printf("\n};\n\nuint8_t _st_14linear2ulaw[0x4000] = {\n  ");
+    printf("\n};\n\nuint8_t _sox_14linear2ulaw[0x4000] = {\n  ");
     y = 0;
     for (x = 0; x < 0x4000; x++)
     {
-	printf(" 0x%02x,", st_14linear2ulaw((-0x2000)+x));
+	printf(" 0x%02x,", sox_14linear2ulaw((-0x2000)+x));
 	y++;
 	if (y == 12)
 	{
--- a/src/g711.h
+++ b/src/g711.h
@@ -10,12 +10,12 @@
  * implied warranty.
  */
 
-extern uint8_t _st_13linear2alaw[0x2000];
-extern int16_t _st_alaw2linear16[256];
-#define st_13linear2alaw(sw) (_st_13linear2alaw[((sw) + 0x1000)])
-#define st_alaw2linear16(uc) (_st_alaw2linear16[uc])
+extern uint8_t _sox_13linear2alaw[0x2000];
+extern int16_t _sox_alaw2linear16[256];
+#define sox_13linear2alaw(sw) (_sox_13linear2alaw[((sw) + 0x1000)])
+#define sox_alaw2linear16(uc) (_sox_alaw2linear16[uc])
 
-extern uint8_t _st_14linear2ulaw[0x4000];
-extern int16_t _st_ulaw2linear16[256];
-#define st_14linear2ulaw(sw) (_st_14linear2ulaw[((sw) + 0x2000)])
-#define st_ulaw2linear16(uc) (_st_ulaw2linear16[uc])
+extern uint8_t _sox_14linear2ulaw[0x4000];
+extern int16_t _sox_ulaw2linear16[256];
+#define sox_14linear2ulaw(sw) (_sox_14linear2ulaw[((sw) + 0x2000)])
+#define sox_ulaw2linear16(uc) (_sox_ulaw2linear16[uc])
--- a/src/g721.c
+++ b/src/g721.c
@@ -49,7 +49,7 @@
  *
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "g72x.h"
 #include "g711.h"
 
@@ -89,10 +89,10 @@
 
 	switch (in_coding) {	/* linearize input sample to 14-bit PCM */
 	case AUDIO_ENCODING_ALAW:
-		sl = st_alaw2linear16(sl) >> 2;
+		sl = sox_alaw2linear16(sl) >> 2;
 		break;
 	case AUDIO_ENCODING_ULAW:
-		sl = st_ulaw2linear16(sl) >> 2;
+		sl = sox_ulaw2linear16(sl) >> 2;
 		break;
 	case AUDIO_ENCODING_LINEAR:
 		sl >>= 2;			/* 14-bit dynamic range */
--- a/src/g723_24.c
+++ b/src/g723_24.c
@@ -37,7 +37,7 @@
  * of workstation attributes, such as hardware 2's complement arithmetic.
  *
  */
-#include "st_i.h"
+#include "sox_i.h"
 #include "g711.h"
 #include "g72x.h"
 
@@ -76,10 +76,10 @@
 
 	switch (in_coding) {	/* linearize input sample to 14-bit PCM */
 	case AUDIO_ENCODING_ALAW:
-		sl = st_alaw2linear16(sl) >> 2;
+		sl = sox_alaw2linear16(sl) >> 2;
 		break;
 	case AUDIO_ENCODING_ULAW:
-		sl = st_ulaw2linear16(sl) >> 2;
+		sl = sox_ulaw2linear16(sl) >> 2;
 		break;
 	case AUDIO_ENCODING_LINEAR:
 		sl >>= 2;		/* sl of 14-bit dynamic range */
--- a/src/g723_40.c
+++ b/src/g723_40.c
@@ -45,7 +45,7 @@
  * the name of the module which it is implementing.
  *
  */
-#include "st_i.h"
+#include "sox_i.h"
 #include "g711.h"
 #include "g72x.h"
 
@@ -95,10 +95,10 @@
 
 	switch (in_coding) {	/* linearize input sample to 14-bit PCM */
 	case AUDIO_ENCODING_ALAW:
-		sl = st_alaw2linear16(sl) >> 2;
+		sl = sox_alaw2linear16(sl) >> 2;
 		break;
 	case AUDIO_ENCODING_ULAW:
-		sl = st_ulaw2linear16(sl) >> 2;
+		sl = sox_ulaw2linear16(sl) >> 2;
 		break;
 	case AUDIO_ENCODING_LINEAR:
 		sl >>= 2;		/* sl of 14-bit dynamic range */
--- a/src/g72x.c
+++ b/src/g72x.c
@@ -30,7 +30,7 @@
  * Common routines for G.721 and G.723 conversions.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "g711.h"
 #include "g72x.h"
 
@@ -455,8 +455,8 @@
 
         if (sr <= -32768)
                 sr = -1;
-        sp = st_13linear2alaw(((sr >> 1) << 3));/* short to A-law compression */
-        dx = (st_alaw2linear16(sp) >> 2) - se;  /* 16-bit prediction error */
+        sp = sox_13linear2alaw(((sr >> 1) << 3));/* short to A-law compression */
+        dx = (sox_alaw2linear16(sp) >> 2) - se;  /* 16-bit prediction error */
         id = quantize(dx, y, qtab, sign - 1);
 
         if (id == i) {                  /* no adjustment on sp */
@@ -497,8 +497,8 @@
 
         if (sr <= -32768)
                 sr = 0;
-        sp = st_14linear2ulaw((sr << 2));/* short to u-law compression */
-        dx = (st_ulaw2linear16(sp) >> 2) - se;  /* 16-bit prediction error */
+        sp = sox_14linear2ulaw((sr << 2));/* short to u-law compression */
+        dx = (sox_ulaw2linear16(sp) >> 2) - se;  /* 16-bit prediction error */
         id = quantize(dx, y, qtab, sign - 1);
         if (id == i) {
                 return (sp);
--- a/src/gsm.c
+++ b/src/gsm.c
@@ -11,7 +11,7 @@
  * Technische Universitaet Berlin
  *
  * More information on this format can be obtained from
- * http://www.cs.tu-berlin.de/~jutta/toast.html
+ * http://www.cs.tu-berlin.de/~jutta/toasox.html
  *
  * Source is available from ftp://ftp.cs.tu-berlin.de/pub/local/kbs/tubmik/gsm
  *
@@ -26,7 +26,7 @@
  *   Rewritten to support multiple channels
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #ifdef EXTERNAL_GSM
 #include <gsm/gsm.h>
@@ -58,8 +58,8 @@
         struct gsmpriv *p = (struct gsmpriv *) ft->priv;
         int ch;
         
-        ft->signal.encoding = ST_ENCODING_GSM;
-        ft->signal.size = ST_SIZE_BYTE;
+        ft->signal.encoding = SOX_ENCODING_GSM;
+        ft->signal.size = SOX_SIZE_BYTE;
         if (!ft->signal.rate)
                 ft->signal.rate = 8000;
 
@@ -69,8 +69,8 @@
         p->channels = ft->signal.channels;
         if (p->channels > MAXCHANS || p->channels <= 0)
         {
-                st_fail_errno(ft,ST_EFMT,"gsm: channels(%d) must be in 1-16", ft->signal.channels);
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EFMT,"gsm: channels(%d) must be in 1-16", ft->signal.channels);
+                return(SOX_EOF);
         }
 
         for (ch=0; ch<p->channels; ch++) {
@@ -77,8 +77,8 @@
                 p->handle[ch] = gsm_create();
                 if (!p->handle[ch])
                 {
-                        st_fail_errno(ft,errno,"unable to create GSM stream");
-                        return (ST_EOF);
+                        sox_fail_errno(ft,errno,"unable to create GSM stream");
+                        return (SOX_EOF);
                 }
         }
         p->frames = (gsm_byte*) xmalloc(p->channels*FRAMESIZE);
@@ -85,15 +85,15 @@
         p->samples = (gsm_signal*) xmalloc(BLOCKSIZE * (p->channels+1) * sizeof(gsm_signal));
         p->sampleTop = p->samples + BLOCKSIZE*p->channels;
         p->samplePtr = (w)? p->samples : p->sampleTop;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static int st_gsmstartread(ft_t ft) 
+static int sox_gsmstartread(ft_t ft) 
 {
         return gsmstart_rw(ft,0);
 }
 
-static int st_gsmstartwrite(ft_t ft)
+static int sox_gsmstartwrite(ft_t ft)
 {
         return gsmstart_rw(ft,1);
 }
@@ -105,7 +105,7 @@
  * Return number of samples read.
  */
 
-static st_size_t st_gsmread(ft_t ft, st_sample_t *buf, st_size_t samp)
+static sox_size_t sox_gsmread(ft_t ft, sox_sample_t *buf, sox_size_t samp)
 {
         size_t done = 0;
         int r, ch, chans;
@@ -118,11 +118,11 @@
         {
                 while (p->samplePtr < p->sampleTop && done < samp)
                         buf[done++] = 
-                            ST_SIGNED_WORD_TO_SAMPLE(*(p->samplePtr)++,);
+                            SOX_SIGNED_WORD_TO_SAMPLE(*(p->samplePtr)++,);
 
                 if (done>=samp) break;
 
-                r = st_readbuf(ft, p->frames, p->channels*FRAMESIZE, 1);
+                r = sox_readbuf(ft, p->frames, p->channels*FRAMESIZE, 1);
                 if (r != 1) break;
 
                 p->samplePtr = p->samples;
@@ -133,7 +133,7 @@
                         gbuff = p->sampleTop;
                         if (gsm_decode(p->handle[ch], p->frames + ch*FRAMESIZE, gbuff) < 0)
                         {
-                                st_fail_errno(ft,errno,"error during GSM decode");
+                                sox_fail_errno(ft,errno,"error during GSM decode");
                                 return (0);
                         }
                         
@@ -171,19 +171,19 @@
                         gsp += chans;
                 }
                 gsm_encode(p->handle[ch], gbuff, p->frames);
-                r = st_writebuf(ft, p->frames, FRAMESIZE, 1);
+                r = sox_writebuf(ft, p->frames, FRAMESIZE, 1);
                 if (r != 1)
                 {
-                        st_fail_errno(ft,errno,"write error");
-                        return(ST_EOF);
+                        sox_fail_errno(ft,errno,"write error");
+                        return(SOX_EOF);
                 }
         }
         p->samplePtr = p->samples;
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_size_t st_gsmwrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static sox_size_t sox_gsmwrite(ft_t ft, const sox_sample_t *buf, sox_size_t samp)
 {
         size_t done = 0;
         struct gsmpriv *p = (struct gsmpriv *) ft->priv;
@@ -192,7 +192,7 @@
         {
                 while ((p->samplePtr < p->sampleTop) && (done < samp))
                         *(p->samplePtr)++ = 
-                            ST_SAMPLE_TO_SIGNED_WORD(buf[done++], ft->clips);
+                            SOX_SAMPLE_TO_SIGNED_WORD(buf[done++], ft->clips);
 
                 if (p->samplePtr == p->sampleTop)
                 {
@@ -206,7 +206,7 @@
         return done;
 }
 
-static int st_gsmstopread(ft_t ft)
+static int sox_gsmstopread(ft_t ft)
 {
         struct gsmpriv *p = (struct gsmpriv *) ft->priv;
         int ch;
@@ -216,10 +216,10 @@
 
         free(p->samples);
         free(p->frames);
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static int st_gsmstopwrite(ft_t ft)
+static int sox_gsmstopwrite(ft_t ft)
 {
         int rc;
         struct gsmpriv *p = (struct gsmpriv *) ft->priv;
@@ -231,7 +231,7 @@
                     return rc;
         }
 
-        return st_gsmstopread(ft); /* destroy handles and free buffers */
+        return sox_gsmstopread(ft); /* destroy handles and free buffers */
 }
 
 /* GSM 06.10 */
@@ -240,20 +240,20 @@
   NULL
 };
 
-static st_format_t st_gsm_format = {
+static sox_format_t sox_gsm_format = {
   gsmnames,
   NULL,
   0,
-  st_gsmstartread,
-  st_gsmread,
-  st_gsmstopread,
-  st_gsmstartwrite,
-  st_gsmwrite,
-  st_gsmstopwrite,
-  st_format_nothing_seek
+  sox_gsmstartread,
+  sox_gsmread,
+  sox_gsmstopread,
+  sox_gsmstartwrite,
+  sox_gsmwrite,
+  sox_gsmstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_gsm_format_fn(void)
+const sox_format_t *sox_gsm_format_fn(void)
 {
-    return &st_gsm_format;
+    return &sox_gsm_format;
 }
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -7,7 +7,7 @@
  * the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 /*
  * Sound Tools file format and effect tables.
@@ -14,69 +14,69 @@
  */
 
 /* File format handlers. */
-st_format_fn_t st_format_fns[] = {
-  st_aiff_format_fn,
-  st_aifc_format_fn,
-  st_al_format_fn,
+sox_format_fn_t sox_format_fns[] = {
+  sox_aiff_format_fn,
+  sox_aifc_format_fn,
+  sox_al_format_fn,
 #ifdef HAVE_ALSA
-  st_alsa_format_fn,
+  sox_alsa_format_fn,
 #endif
-  st_amr_wb_format_fn,
-  st_au_format_fn,
-  st_auto_format_fn,
-  st_avr_format_fn,
-  st_cdr_format_fn,
-  st_cvsd_format_fn,
-  st_dat_format_fn,
-  st_dvms_format_fn,
+  sox_amr_wb_format_fn,
+  sox_au_format_fn,
+  sox_auto_format_fn,
+  sox_avr_format_fn,
+  sox_cdr_format_fn,
+  sox_cvsd_format_fn,
+  sox_dat_format_fn,
+  sox_dvms_format_fn,
 #ifdef HAVE_LIBFLAC
-  st_flac_format_fn,
+  sox_flac_format_fn,
 #endif
-  st_gsm_format_fn,
-  st_hcom_format_fn,
-  st_ima_format_fn,
-  st_la_format_fn,
-  st_lu_format_fn,
-  st_maud_format_fn,
+  sox_gsm_format_fn,
+  sox_hcom_format_fn,
+  sox_ima_format_fn,
+  sox_la_format_fn,
+  sox_lu_format_fn,
+  sox_maud_format_fn,
 #if defined(HAVE_LIBMAD) || defined(HAVE_LIBMP3LAME)
-  st_mp3_format_fn,
+  sox_mp3_format_fn,
 #endif
-  st_nul_format_fn,
+  sox_nul_format_fn,
 #ifdef HAVE_OSS
-  st_ossdsp_format_fn,
+  sox_ossdsp_format_fn,
 #endif
-  st_prc_format_fn,
-  st_raw_format_fn,
-  st_s3_format_fn,
-  st_sb_format_fn,
-  st_sf_format_fn,
-  st_sl_format_fn,
-  st_smp_format_fn,
-  st_snd_format_fn,
-  st_sphere_format_fn,
+  sox_prc_format_fn,
+  sox_raw_format_fn,
+  sox_s3_format_fn,
+  sox_sb_format_fn,
+  sox_sf_format_fn,
+  sox_sl_format_fn,
+  sox_smp_format_fn,
+  sox_snd_format_fn,
+  sox_sphere_format_fn,
 #ifdef HAVE_SUN_AUDIO
-  st_sun_format_fn,
+  sox_sun_format_fn,
 #endif
-  st_svx_format_fn,
-  st_sw_format_fn,
-  st_txw_format_fn,
-  st_u3_format_fn,
-  st_u4_format_fn,
-  st_ub_format_fn,
-  st_ul_format_fn,
-  st_uw_format_fn,
-  st_voc_format_fn,
+  sox_svx_format_fn,
+  sox_sw_format_fn,
+  sox_txw_format_fn,
+  sox_u3_format_fn,
+  sox_u4_format_fn,
+  sox_ub_format_fn,
+  sox_ul_format_fn,
+  sox_uw_format_fn,
+  sox_voc_format_fn,
 #if defined HAVE_LIBVORBISENC && defined HAVE_LIBVORBISFILE
-  st_vorbis_format_fn,
+  sox_vorbis_format_fn,
 #endif
-  st_vox_format_fn,
-  st_wav_format_fn,
-  st_wve_format_fn,
-  st_xa_format_fn,
+  sox_vox_format_fn,
+  sox_wav_format_fn,
+  sox_wve_format_fn,
+  sox_xa_format_fn,
   /* Prefer internal formats over libsndfile. Can be overridden
    * by using -t sndfile. */
 #ifdef HAVE_SNDFILE_H
-  st_sndfile_format_fn,
+  sox_sndfile_format_fn,
 #endif
   NULL
 };
@@ -84,64 +84,64 @@
 /* Effects handlers. */
 
 /*
- * ST_EFF_CHAN means that the number of channels can change.
- * ST_EFF_RATE means that the sample rate can change.
- * ST_EFF_MCHAN means that the effect is coded for multiple channels.
+ * SOX_EFF_CHAN means that the number of channels can change.
+ * SOX_EFF_RATE means that the sample rate can change.
+ * SOX_EFF_MCHAN means that the effect is coded for multiple channels.
  *
  */
 
-st_effect_fn_t st_effect_fns[] = {
-  st_allpass_effect_fn,
-  st_avg_effect_fn,
-  st_band_effect_fn,
-  st_bandpass_effect_fn,
-  st_bandreject_effect_fn,
-  st_bass_effect_fn,
-  st_chorus_effect_fn,
-  st_compand_effect_fn,
-  st_dcshift_effect_fn,
-  st_deemph_effect_fn,
-  st_dither_effect_fn,
-  st_earwax_effect_fn,
-  st_echo_effect_fn,
-  st_echos_effect_fn,
-  st_equalizer_effect_fn,
-  st_fade_effect_fn,
-  st_filter_effect_fn,
-  st_flanger_effect_fn,
-  st_highpass_effect_fn,
-  st_highp_effect_fn,
-  st_lowpass_effect_fn,
-  st_lowp_effect_fn,
-  st_mask_effect_fn,
-  st_mcompand_effect_fn,
-  st_mixer_effect_fn,
-  st_noiseprof_effect_fn,
-  st_noisered_effect_fn,
-  st_pad_effect_fn,
-  st_pan_effect_fn,
-  st_phaser_effect_fn,
-  st_pick_effect_fn,
-  st_pitch_effect_fn,
-  st_polyphase_effect_fn,
+sox_effect_fn_t sox_effect_fns[] = {
+  sox_allpass_effect_fn,
+  sox_avg_effect_fn,
+  sox_band_effect_fn,
+  sox_bandpass_effect_fn,
+  sox_bandreject_effect_fn,
+  sox_bass_effect_fn,
+  sox_chorus_effect_fn,
+  sox_compand_effect_fn,
+  sox_dcshift_effect_fn,
+  sox_deemph_effect_fn,
+  sox_dither_effect_fn,
+  sox_earwax_effect_fn,
+  sox_echo_effect_fn,
+  sox_echos_effect_fn,
+  sox_equalizer_effect_fn,
+  sox_fade_effect_fn,
+  sox_filter_effect_fn,
+  sox_flanger_effect_fn,
+  sox_highpass_effect_fn,
+  sox_highp_effect_fn,
+  sox_lowpass_effect_fn,
+  sox_lowp_effect_fn,
+  sox_mask_effect_fn,
+  sox_mcompand_effect_fn,
+  sox_mixer_effect_fn,
+  sox_noiseprof_effect_fn,
+  sox_noisered_effect_fn,
+  sox_pad_effect_fn,
+  sox_pan_effect_fn,
+  sox_phaser_effect_fn,
+  sox_pick_effect_fn,
+  sox_pitch_effect_fn,
+  sox_polyphase_effect_fn,
 #ifdef HAVE_SAMPLERATE_H
-  st_rabbit_effect_fn,
+  sox_rabbit_effect_fn,
 #endif
-  st_rate_effect_fn,
-  st_repeat_effect_fn,
-  st_resample_effect_fn,
-  st_reverb_effect_fn,
-  st_reverse_effect_fn,
-  st_silence_effect_fn,
-  st_speed_effect_fn,
-  st_stat_effect_fn,
-  st_stretch_effect_fn,
-  st_swap_effect_fn,
-  st_synth_effect_fn,
-  st_treble_effect_fn,
-  st_tremolo_effect_fn,
-  st_trim_effect_fn,
-  st_vibro_effect_fn,
-  st_vol_effect_fn,
+  sox_rate_effect_fn,
+  sox_repeat_effect_fn,
+  sox_resample_effect_fn,
+  sox_reverb_effect_fn,
+  sox_reverse_effect_fn,
+  sox_silence_effect_fn,
+  sox_speed_effect_fn,
+  sox_stat_effect_fn,
+  sox_stretch_effect_fn,
+  sox_swap_effect_fn,
+  sox_synth_effect_fn,
+  sox_treble_effect_fn,
+  sox_tremolo_effect_fn,
+  sox_trim_effect_fn,
+  sox_vibro_effect_fn,
+  sox_vol_effect_fn,
   NULL
 };
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -21,7 +21,7 @@
  *
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <assert.h>
 #include <string.h>
 #include <stdlib.h>
@@ -54,7 +54,7 @@
         int32_t curword;
 };
 
-static int st_hcomstartread(ft_t ft)
+static int sox_hcomstartread(ft_t ft)
 {
         struct readpriv *p = (struct readpriv *) ft->priv;
         int i;
@@ -66,58 +66,58 @@
 
 
         /* Skip first 65 bytes of header */
-        rc = st_skipbytes(ft, 65);
+        rc = sox_skipbytes(ft, 65);
         if (rc)
             return rc;
 
         /* Check the file type (bytes 65-68) */
-        if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "FSSD", 4) != 0)
+        if (sox_reads(ft, buf, 4) == SOX_EOF || strncmp(buf, "FSSD", 4) != 0)
         {
-                st_fail_errno(ft,ST_EHDR,"Mac header type is not FSSD");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"Mac header type is not FSSD");
+                return (SOX_EOF);
         }
 
         /* Skip to byte 83 */
-        rc = st_skipbytes(ft, 83-69);
+        rc = sox_skipbytes(ft, 83-69);
         if (rc)
             return rc;
 
         /* Get essential numbers from the header */
-        st_readdw(ft, &datasize); /* bytes 83-86 */
-        st_readdw(ft, &rsrcsize); /* bytes 87-90 */
+        sox_readdw(ft, &datasize); /* bytes 83-86 */
+        sox_readdw(ft, &rsrcsize); /* bytes 87-90 */
 
         /* Skip the rest of the header (total 128 bytes) */
-        rc = st_skipbytes(ft, 128-91);
+        rc = sox_skipbytes(ft, 128-91);
         if (rc != 0)
             return rc;
 
         /* The data fork must contain a "HCOM" header */
-        if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "HCOM", 4) != 0)
+        if (sox_reads(ft, buf, 4) == SOX_EOF || strncmp(buf, "HCOM", 4) != 0)
         {
-                st_fail_errno(ft,ST_EHDR,"Mac data fork is not HCOM");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"Mac data fork is not HCOM");
+                return (SOX_EOF);
         }
 
         /* Then follow various parameters */
-        st_readdw(ft, &huffcount);
-        st_readdw(ft, &checksum);
-        st_readdw(ft, &compresstype);
+        sox_readdw(ft, &huffcount);
+        sox_readdw(ft, &checksum);
+        sox_readdw(ft, &compresstype);
         if (compresstype > 1)
         {
-                st_fail_errno(ft,ST_EHDR,"Bad compression type in HCOM header");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"Bad compression type in HCOM header");
+                return (SOX_EOF);
         }
-        st_readdw(ft, &divisor);
+        sox_readdw(ft, &divisor);
         if (divisor == 0 || divisor > 4)
         {
-                st_fail_errno(ft,ST_EHDR,"Bad sampling rate divisor in HCOM header");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"Bad sampling rate divisor in HCOM header");
+                return (SOX_EOF);
         }
-        st_readw(ft, &dictsize);
+        sox_readw(ft, &dictsize);
 
         /* Translate to sox parameters */
-        ft->signal.encoding = ST_ENCODING_UNSIGNED;
-        ft->signal.size = ST_SIZE_BYTE;
+        ft->signal.encoding = SOX_ENCODING_UNSIGNED;
+        ft->signal.size = SOX_SIZE_BYTE;
         ft->signal.rate = 22050 / divisor;
         ft->signal.channels = 1;
 
@@ -126,13 +126,13 @@
 
         /* Read dictionary */
         for(i = 0; i < dictsize; i++) {
-                st_readw(ft, (unsigned short *)&(p->dictionary[i].dict_leftson));
-                st_readw(ft, (unsigned short *)&(p->dictionary[i].dict_rightson));
-                st_debug("%d %d",
+                sox_readw(ft, (unsigned short *)&(p->dictionary[i].dict_leftson));
+                sox_readw(ft, (unsigned short *)&(p->dictionary[i].dict_rightson));
+                sox_debug("%d %d",
                        p->dictionary[i].dict_leftson,
                        p->dictionary[i].dict_rightson);
         }
-        rc = st_skipbytes(ft, 1); /* skip pad byte */
+        rc = sox_skipbytes(ft, 1); /* skip pad byte */
         if (rc)
             return rc;
 
@@ -140,16 +140,16 @@
         p->checksum = checksum;
         p->deltacompression = compresstype;
         if (!p->deltacompression)
-                st_debug("HCOM data using value compression");
+                sox_debug("HCOM data using value compression");
         p->huffcount = huffcount;
         p->cksum = 0;
         p->dictentry = 0;
         p->nrbits = -1; /* Special case to get first byte */
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_size_t st_hcomread(ft_t ft, st_sample_t *buf, st_size_t len)
+static sox_size_t sox_hcomread(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
         register struct readpriv *p = (struct readpriv *) ft->priv;
         int done = 0;
@@ -159,13 +159,13 @@
                 /* The first byte is special */
                 if (p->huffcount == 0)
                         return 0; /* Don't know if this can happen... */
-                if (st_readb(ft, &sample_rate) == ST_EOF)
+                if (sox_readb(ft, &sample_rate) == SOX_EOF)
                 {
-                        st_fail_errno(ft,ST_EOF,"unexpected EOF at start of HCOM data");
+                        sox_fail_errno(ft,SOX_EOF,"unexpected EOF at start of HCOM data");
                         return (0);
                 }
                 p->sample = sample_rate;
-                *buf++ = ST_UNSIGNED_BYTE_TO_SAMPLE(p->sample,);
+                *buf++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(p->sample,);
                 p->huffcount--;
                 p->nrbits = 0;
                 done++;
@@ -176,10 +176,10 @@
 
         while (p->huffcount > 0) {
                 if(p->nrbits == 0) {
-                        st_readdw(ft, &(p->current));
-                        if (st_eof(ft))
+                        sox_readdw(ft, &(p->current));
+                        if (sox_eof(ft))
                         {
-                                st_fail_errno(ft,ST_EOF,"unexpected EOF in HCOM data");
+                                sox_fail_errno(ft,SOX_EOF,"unexpected EOF in HCOM data");
                                 return (0);
                         }
                         p->cksum += p->current;
@@ -201,7 +201,7 @@
                                 p->sample = 0;
                         p->sample = (p->sample + datum) & 0xff;
                         p->huffcount--;
-                        *buf++ = ST_UNSIGNED_BYTE_TO_SAMPLE(p->sample,);
+                        *buf++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(p->sample,);
                         p->dictentry = 0;
                         done++;
                         len--;
@@ -213,34 +213,34 @@
         return done;
 }
 
-static int st_hcomstopread(ft_t ft)
+static int sox_hcomstopread(ft_t ft)
 {
         register struct readpriv *p = (struct readpriv *) ft->priv;
 
         if (p->huffcount != 0)
         {
-                st_fail_errno(ft,ST_EFMT,"not all HCOM data read");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EFMT,"not all HCOM data read");
+                return (SOX_EOF);
         }
         if(p->cksum != p->checksum)
         {
-                st_fail_errno(ft,ST_EFMT,"checksum error in HCOM data");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EFMT,"checksum error in HCOM data");
+                return (SOX_EOF);
         }
         free((char *)p->dictionary);
         p->dictionary = NULL;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 struct writepriv {
   unsigned char *data;          /* Buffer allocated with xmalloc */
-  st_size_t size;               /* Size of allocated buffer */
-  st_size_t pos;                /* Where next byte goes */
+  sox_size_t size;               /* Size of allocated buffer */
+  sox_size_t pos;                /* Where next byte goes */
 };
 
 #define BUFINCR (10*BUFSIZ)
 
-static int st_hcomstartwrite(ft_t ft)
+static int sox_hcomstartwrite(ft_t ft)
 {
         register struct writepriv *p = (struct writepriv *) ft->priv;
 
@@ -251,24 +251,24 @@
         case 22050/4:
                 break;
         default:
-                st_fail_errno(ft,ST_EFMT,"unacceptable output rate for HCOM: try 5512, 7350, 11025 or 22050 hertz");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EFMT,"unacceptable output rate for HCOM: try 5512, 7350, 11025 or 22050 hertz");
+                return (SOX_EOF);
         }
-        ft->signal.size = ST_SIZE_BYTE;
-        ft->signal.encoding = ST_ENCODING_UNSIGNED;
+        ft->signal.size = SOX_SIZE_BYTE;
+        ft->signal.encoding = SOX_ENCODING_UNSIGNED;
         ft->signal.channels = 1;
 
         p->size = BUFINCR;
         p->pos = 0;
         p->data = (unsigned char *) xmalloc(p->size);
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_size_t st_hcomwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static sox_size_t sox_hcomwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
   struct writepriv *p = (struct writepriv *) ft->priv;
-  st_sample_t datum;
-  st_size_t i;
+  sox_sample_t datum;
+  sox_size_t i;
 
   if (len == 0)
     return 0;
@@ -280,7 +280,7 @@
 
   for (i = 0; i < len; i++) {
     datum = *buf++;
-    p->data[p->pos++] = ST_SAMPLE_TO_UNSIGNED_BYTE(datum, ft->clips);
+    p->data[p->pos++] = SOX_SAMPLE_TO_UNSIGNED_BYTE(datum, ft->clips);
   }
 
   return len;
@@ -391,8 +391,8 @@
   for (i = 0; i < 256; i++)
     l += frequtable[i] * codesize[i];
   l = (((l + 31) >> 5) << 2) + 24 + dictsize * 4;
-  st_debug("  Original size: %6d bytes", *dl);
-  st_debug("Compressed size: %6d bytes", l);
+  sox_debug("  Original size: %6d bytes", *dl);
+  sox_debug("Compressed size: %6d bytes", l);
   datafork = (unsigned char *)xmalloc((unsigned)l);
   ddf = datafork + 22;
   for(i = 0; i < dictsize; i++) {
@@ -425,12 +425,12 @@
 
 /* End of hcom utility routines */
 
-static int st_hcomstopwrite(ft_t ft)
+static int sox_hcomstopwrite(ft_t ft)
 {
   struct writepriv *p = (struct writepriv *) ft->priv;
   unsigned char *compressed_data = p->data;
-  st_size_t compressed_len = p->pos;
-  int rc = ST_SUCCESS;
+  sox_size_t compressed_len = p->pos;
+  int rc = SOX_SUCCESS;
 
   /* Compress it all at once */
   if (compressed_len)
@@ -438,26 +438,26 @@
   free((char *)p->data);
 
   /* Write the header */
-  st_writebuf(ft, (void *)"\000\001A", 1, 3); /* Dummy file name "A" */
-  st_padbytes(ft, 65-3);
-  st_writes(ft, "FSSD");
-  st_padbytes(ft, 83-69);
-  st_writedw(ft, (uint32_t)compressed_len); /* compressed_data size */
-  st_writedw(ft, 0); /* rsrc size */
-  st_padbytes(ft, 128 - 91);
-  if (st_error(ft)) {
-    st_fail_errno(ft, errno, "write error in HCOM header");
-    rc = ST_EOF;
-  } else if (st_writebuf(ft, compressed_data, 1, compressed_len) != compressed_len) {
+  sox_writebuf(ft, (void *)"\000\001A", 1, 3); /* Dummy file name "A" */
+  sox_padbytes(ft, 65-3);
+  sox_writes(ft, "FSSD");
+  sox_padbytes(ft, 83-69);
+  sox_writedw(ft, (uint32_t)compressed_len); /* compressed_data size */
+  sox_writedw(ft, 0); /* rsrc size */
+  sox_padbytes(ft, 128 - 91);
+  if (sox_error(ft)) {
+    sox_fail_errno(ft, errno, "write error in HCOM header");
+    rc = SOX_EOF;
+  } else if (sox_writebuf(ft, compressed_data, 1, compressed_len) != compressed_len) {
     /* Write the compressed_data fork */
-    st_fail_errno(ft, errno, "can't write compressed HCOM data");
-    rc = ST_EOF;
+    sox_fail_errno(ft, errno, "can't write compressed HCOM data");
+    rc = SOX_EOF;
   }
   free((char *)compressed_data);
 
-  if (rc == ST_SUCCESS)
+  if (rc == SOX_SUCCESS)
     /* Pad the compressed_data fork to a multiple of 128 bytes */
-    st_padbytes(ft, 128 - (int) (compressed_len % 128));
+    sox_padbytes(ft, 128 - (int) (compressed_len % 128));
 
   return rc;
 }
@@ -468,20 +468,20 @@
   NULL
 };
 
-static st_format_t st_hcom_format = {
+static sox_format_t sox_hcom_format = {
   hcomnames,
   NULL,
-  ST_FILE_BIG_END,
-  st_hcomstartread,
-  st_hcomread,
-  st_hcomstopread,
-  st_hcomstartwrite,
-  st_hcomwrite,
-  st_hcomstopwrite,
-  st_format_nothing_seek
+  SOX_FILE_BIG_END,
+  sox_hcomstartread,
+  sox_hcomread,
+  sox_hcomstopread,
+  sox_hcomstartwrite,
+  sox_hcomwrite,
+  sox_hcomstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_hcom_format_fn(void)
+const sox_format_t *sox_hcom_format_fn(void)
 {
-    return &st_hcom_format;
+    return &sox_hcom_format;
 }
--- a/src/ima_rw.c
+++ b/src/ima_rw.c
@@ -23,7 +23,7 @@
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "st_i.h"
+#include "sox_i.h"
 #include "ima_rw.h"
 /*
  *
@@ -83,7 +83,7 @@
         val = (short)(ip[0] + (ip[1]<<8)); /* need cast for sign-extend */
         state = ip[2];
         if (state > ISSTMAX) {
-                st_warn("IMA_ADPCM block ch%d initial-state (%d) out of range", ch, state);
+                sox_warn("IMA_ADPCM block ch%d initial-state (%d) out of range", ch, state);
                 state = 0;
         }
         /* specs say to ignore ip[3] , but write it as 0 */
@@ -320,14 +320,14 @@
  *  samplesPerBlock which would go into a block of size blockAlign
  *  Yes, it is confusing.
  */
-st_size_t ImaSamplesIn(
-  st_size_t dataLen,
+sox_size_t ImaSamplesIn(
+  sox_size_t dataLen,
   unsigned short chans,
   unsigned short blockAlign,
   unsigned short samplesPerBlock
 )
 {
-  st_size_t m, n;
+  sox_size_t m, n;
 
   if (samplesPerBlock) {
     n = (dataLen / blockAlign) * samplesPerBlock;
@@ -336,7 +336,7 @@
     n = 0;
     m = blockAlign;
   }
-  if (m >= (st_size_t)4*chans) {
+  if (m >= (sox_size_t)4*chans) {
     m -= 4*chans;    /* number of bytes beyond block-header */
     m /= 4*chans;    /* number of 4-byte blocks/channel beyond header */
     m = 8*m + 1;     /* samples/chan beyond header + 1 in header */
@@ -348,21 +348,21 @@
 }
 
 /*
- * st_size_t ImaBytesPerBlock(chans, samplesPerBlock)
+ * sox_size_t ImaBytesPerBlock(chans, samplesPerBlock)
  *   return minimum blocksize which would be required
  *   to encode number of chans with given samplesPerBlock
  */
-st_size_t ImaBytesPerBlock(
+sox_size_t ImaBytesPerBlock(
   unsigned short chans,
   unsigned short samplesPerBlock
 )
 {
-  st_size_t n;
+  sox_size_t n;
   /* per channel, ima has blocks of len 4, the 1st has 1st sample, the others
    * up to 8 samples per block,
    * so number of later blocks is (nsamp-1 + 7)/8, total blocks/chan is
    * (nsamp-1+7)/8 + 1 = (nsamp+14)/8
    */
-  n = ((st_size_t)samplesPerBlock + 14)/8 * 4 * chans;
+  n = ((sox_size_t)samplesPerBlock + 14)/8 * 4 * chans;
   return n;
 }
--- a/src/ima_rw.h
+++ b/src/ima_rw.h
@@ -19,7 +19,7 @@
  
 */
 
-#include "st.h"
+#include "sox.h"
 
 #ifndef SAMPL
 #define SAMPL short
@@ -67,8 +67,8 @@
  *  samplesPerBlock which would go into a block of size blockAlign
  *  Yes, it is confusing usage.
  */
-extern st_size_t ImaSamplesIn(
-	st_size_t dataLen,
+extern sox_size_t ImaSamplesIn(
+	sox_size_t dataLen,
 	unsigned short chans,
 	unsigned short blockAlign,
 	unsigned short samplesPerBlock
@@ -75,11 +75,11 @@
 );
 
 /*
- * st_size_t ImaBytesPerBlock(chans, samplesPerBlock)
+ * sox_size_t ImaBytesPerBlock(chans, samplesPerBlock)
  *   return minimum blocksize which would be required
  *   to encode number of chans with given samplesPerBlock
  */
-extern st_size_t ImaBytesPerBlock(
+extern sox_size_t ImaBytesPerBlock(
 	unsigned short chans,
 	unsigned short samplesPerBlock
 );
--- /dev/null
+++ b/src/libsox-config.in
@@ -1,0 +1,28 @@
+#! /bin/sh
+#
+# @configure_input@
+#
+
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+includedir="@includedir@"
+libdir="@libdir@"
+libs='@LIBS@'
+
+case "$1" in
+--prefix)
+        echo $prefix;;
+--includedir)
+        echo $includedir;;
+--libdir)
+        echo $libdir;;
+--libs)
+        echo $libs;;
+--cflags)
+        echo "-L'$libdir' -I'$includedir'";;
+*)
+        echo "Usage: $0 [--prefix|--includedir|--libdir|--cflags|--libs]"
+        exit 1;;
+esac
+
+exit 0
--- a/src/libst-config.in
+++ /dev/null
@@ -1,28 +1,0 @@
-#! /bin/sh
-#
-# @configure_input@
-#
-
-prefix="@prefix@"
-exec_prefix="@exec_prefix@"
-includedir="@includedir@"
-libdir="@libdir@"
-libs='@LIBS@'
-
-case "$1" in
---prefix)
-        echo $prefix;;
---includedir)
-        echo $includedir;;
---libdir)
-        echo $libdir;;
---libs)
-        echo $libs;;
---cflags)
-        echo "-L'$libdir' -I'$includedir'";;
-*)
-        echo "Usage: $0 [--prefix|--includedir|--libdir|--cflags|--libs]"
-        exit 1;;
-esac
-
-exit 0
--- a/src/maud.c
+++ b/src/maud.c
@@ -10,7 +10,7 @@
  * the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -33,7 +33,7 @@
  *      size and encoding of samples, 
  *      mono/stereo/quad.
  */
-static int st_maudstartread(ft_t ft) 
+static int sox_maudstartread(ft_t ft) 
 {
         struct maudstuff * p = (struct maudstuff *) ft->priv;
         
@@ -51,65 +51,65 @@
         int rc;
 
         /* Needed for rawread() */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
         /* read FORM chunk */
-        if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "FORM", 4) != 0)
+        if (sox_reads(ft, buf, 4) == SOX_EOF || strncmp(buf, "FORM", 4) != 0)
         {
-                st_fail_errno(ft,ST_EHDR,"MAUD: header does not begin with magic word 'FORM'");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"MAUD: header does not begin with magic word 'FORM'");
+                return (SOX_EOF);
         }
         
-        st_readdw(ft, &trash32); /* totalsize */
+        sox_readdw(ft, &trash32); /* totalsize */
         
-        if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "MAUD", 4) != 0)
+        if (sox_reads(ft, buf, 4) == SOX_EOF || strncmp(buf, "MAUD", 4) != 0)
         {
-                st_fail_errno(ft,ST_EHDR,"MAUD: 'FORM' chunk does not specify 'MAUD' as type");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"MAUD: 'FORM' chunk does not specify 'MAUD' as type");
+                return(SOX_EOF);
         }
         
         /* read chunks until 'BODY' (or end) */
         
-        while (st_reads(ft, buf, 4) == ST_SUCCESS && strncmp(buf,"MDAT",4) != 0) {
+        while (sox_reads(ft, buf, 4) == SOX_SUCCESS && strncmp(buf,"MDAT",4) != 0) {
                 
                 /*
                 buf[4] = 0;
-                st_debug("chunk %s",buf);
+                sox_debug("chunk %s",buf);
                 */
                 
                 if (strncmp(buf,"MHDR",4) == 0) {
                         
-                        st_readdw(ft, &chunksize);
+                        sox_readdw(ft, &chunksize);
                         if (chunksize != 8*4) 
                         {
-                            st_fail_errno(ft,ST_EHDR,"MAUD: MHDR chunk has bad size");
-                            return(ST_EOF);
+                            sox_fail_errno(ft,SOX_EHDR,"MAUD: MHDR chunk has bad size");
+                            return(SOX_EOF);
                         }
                         
                         /* fseeko(ft->fp,12,SEEK_CUR); */
 
                         /* number of samples stored in MDAT */
-                        st_readdw(ft, &(p->nsamples));
+                        sox_readdw(ft, &(p->nsamples));
 
                         /* number of bits per sample as stored in MDAT */
-                        st_readw(ft, &bitpersam);
+                        sox_readw(ft, &bitpersam);
 
                         /* number of bits per sample after decompression */
-                        st_readw(ft, (unsigned short *)&trash16);
+                        sox_readw(ft, (unsigned short *)&trash16);
 
-                        st_readdw(ft, &nom);         /* clock source frequency */
-                        st_readw(ft, &denom);       /* clock devide           */
+                        sox_readdw(ft, &nom);         /* clock source frequency */
+                        sox_readw(ft, &denom);       /* clock devide           */
                         if (denom == 0) 
                         {
-                            st_fail_errno(ft,ST_EHDR,"MAUD: frequency denominator == 0, failed");
-                            return (ST_EOF);
+                            sox_fail_errno(ft,SOX_EHDR,"MAUD: frequency denominator == 0, failed");
+                            return (SOX_EOF);
                         }
                         
                         ft->signal.rate = nom / denom;
                         
-                        st_readw(ft, &chaninf); /* channel information */
+                        sox_readw(ft, &chaninf); /* channel information */
                         switch (chaninf) {
                         case 0:
                                 ft->signal.channels = 1;
@@ -118,43 +118,43 @@
                                 ft->signal.channels = 2;
                                 break;
                         default:
-                                st_fail_errno(ft,ST_EFMT,"MAUD: unsupported number of channels in file");
-                                return (ST_EOF);
+                                sox_fail_errno(ft,SOX_EFMT,"MAUD: unsupported number of channels in file");
+                                return (SOX_EOF);
                         }
                         
-                        st_readw(ft, &chaninf); /* number of channels (mono: 1, stereo: 2, ...) */
+                        sox_readw(ft, &chaninf); /* number of channels (mono: 1, stereo: 2, ...) */
                         if (chaninf != ft->signal.channels) 
                         {
-                                st_fail_errno(ft,ST_EFMT,"MAUD: unsupported number of channels in file");
-                            return(ST_EOF);
+                                sox_fail_errno(ft,SOX_EFMT,"MAUD: unsupported number of channels in file");
+                            return(SOX_EOF);
                         }
                         
-                        st_readw(ft, &chaninf); /* compression type */
+                        sox_readw(ft, &chaninf); /* compression type */
                         
-                        st_readdw(ft, &trash32); /* rest of chunk, unused yet */
-                        st_readdw(ft, &trash32);
-                        st_readdw(ft, &trash32);
+                        sox_readdw(ft, &trash32); /* rest of chunk, unused yet */
+                        sox_readdw(ft, &trash32);
+                        sox_readdw(ft, &trash32);
                         
                         if (bitpersam == 8 && chaninf == 0) {
-                                ft->signal.size = ST_SIZE_BYTE;
-                                ft->signal.encoding = ST_ENCODING_UNSIGNED;
+                                ft->signal.size = SOX_SIZE_BYTE;
+                                ft->signal.encoding = SOX_ENCODING_UNSIGNED;
                         }
                         else if (bitpersam == 8 && chaninf == 2) {
-                                ft->signal.size = ST_SIZE_BYTE;
-                                ft->signal.encoding = ST_ENCODING_ALAW;
+                                ft->signal.size = SOX_SIZE_BYTE;
+                                ft->signal.encoding = SOX_ENCODING_ALAW;
                         }
                         else if (bitpersam == 8 && chaninf == 3) {
-                                ft->signal.size = ST_SIZE_BYTE;
-                                ft->signal.encoding = ST_ENCODING_ULAW;
+                                ft->signal.size = SOX_SIZE_BYTE;
+                                ft->signal.encoding = SOX_ENCODING_ULAW;
                         }
                         else if (bitpersam == 16 && chaninf == 0) {
-                                ft->signal.size = ST_SIZE_16BIT;
-                                ft->signal.encoding = ST_ENCODING_SIGN2;
+                                ft->signal.size = SOX_SIZE_16BIT;
+                                ft->signal.encoding = SOX_ENCODING_SIGN2;
                         }
                         else 
                         {
-                                st_fail_errno(ft,ST_EFMT,"MAUD: unsupported compression type detected");
-                                return(ST_EOF);
+                                sox_fail_errno(ft,SOX_EFMT,"MAUD: unsupported compression type detected");
+                                return(SOX_EOF);
                         }
                         
                         ft->comment = 0;
@@ -163,18 +163,18 @@
                 }
                 
                 if (strncmp(buf,"ANNO",4) == 0) {
-                        st_readdw(ft, &chunksize);
+                        sox_readdw(ft, &chunksize);
                         if (chunksize & 1)
                                 chunksize++;
                         chunk_buf = (char *) xmalloc(chunksize + 1);
-                        if (st_readbuf(ft, chunk_buf, 1, (int)chunksize) 
+                        if (sox_readbuf(ft, chunk_buf, 1, (int)chunksize) 
                             != chunksize)
                         {
-                                st_fail_errno(ft,ST_EOF,"MAUD: Unexpected EOF in ANNO header");
-                                return(ST_EOF);
+                                sox_fail_errno(ft,SOX_EOF,"MAUD: Unexpected EOF in ANNO header");
+                                return(SOX_EOF);
                         }
                         chunk_buf[chunksize] = '\0';
-                        st_debug("%s",chunk_buf);
+                        sox_debug("%s",chunk_buf);
                         free(chunk_buf);
                         
                         continue;
@@ -181,10 +181,10 @@
                 }
                 
                 /* some other kind of chunk */
-                st_readdw(ft, &chunksize);
+                sox_readdw(ft, &chunksize);
                 if (chunksize & 1)
                         chunksize++;
-                st_seeki(ft, chunksize, SEEK_CUR);
+                sox_seeki(ft, chunksize, SEEK_CUR);
                 continue;
                 
         }
@@ -191,20 +191,20 @@
         
         if (strncmp(buf,"MDAT",4) != 0) 
         {
-            st_fail_errno(ft,ST_EFMT,"MAUD: MDAT chunk not found");
-            return(ST_EOF);
+            sox_fail_errno(ft,SOX_EFMT,"MAUD: MDAT chunk not found");
+            return(SOX_EOF);
         }
-        st_readdw(ft, &(p->nsamples));
-        return(ST_SUCCESS);
+        sox_readdw(ft, &(p->nsamples));
+        return(SOX_SUCCESS);
 }
 
-static int st_maudstartwrite(ft_t ft) 
+static int sox_maudstartwrite(ft_t ft) 
 {
         struct maudstuff * p = (struct maudstuff *) ft->priv;
         int rc;
 
         /* Needed for rawwrite() */
-        rc = st_rawstartwrite(ft);
+        rc = sox_rawstartwrite(ft);
         if (rc)
             return rc;
 
@@ -211,55 +211,55 @@
         /* If you have to seek around the output file */
         if (! ft->seekable) 
         {
-            st_fail_errno(ft,ST_EOF,"Output .maud file must be a file, not a pipe");
-            return (ST_EOF);
+            sox_fail_errno(ft,SOX_EOF,"Output .maud file must be a file, not a pipe");
+            return (SOX_EOF);
         }
         
         if (ft->signal.channels != 1 && ft->signal.channels != 2) {
-                st_fail_errno(ft,ST_EFMT,"MAUD: unsupported number of channels, unable to store");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EFMT,"MAUD: unsupported number of channels, unable to store");
+                return(SOX_EOF);
         }
-        if (ft->signal.size == ST_SIZE_16BIT) ft->signal.encoding = ST_ENCODING_SIGN2;
-        if (ft->signal.encoding == ST_ENCODING_ULAW || 
-            ft->signal.encoding == ST_ENCODING_ALAW) ft->signal.size = ST_SIZE_BYTE;
-        if (ft->signal.size == ST_SIZE_BYTE && 
-            ft->signal.encoding == ST_ENCODING_SIGN2) 
-            ft->signal.encoding = ST_ENCODING_UNSIGNED;
+        if (ft->signal.size == SOX_SIZE_16BIT) ft->signal.encoding = SOX_ENCODING_SIGN2;
+        if (ft->signal.encoding == SOX_ENCODING_ULAW || 
+            ft->signal.encoding == SOX_ENCODING_ALAW) ft->signal.size = SOX_SIZE_BYTE;
+        if (ft->signal.size == SOX_SIZE_BYTE && 
+            ft->signal.encoding == SOX_ENCODING_SIGN2) 
+            ft->signal.encoding = SOX_ENCODING_UNSIGNED;
         
         p->nsamples = 0x7f000000;
         maudwriteheader(ft);
         p->nsamples = 0;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_size_t st_maudwrite(ft_t ft, const st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_maudwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len) 
 {
         struct maudstuff * p = (struct maudstuff *) ft->priv;
         
         p->nsamples += len;
         
-        return st_rawwrite(ft, buf, len);
+        return sox_rawwrite(ft, buf, len);
 }
 
-static int st_maudstopwrite(ft_t ft) 
+static int sox_maudstopwrite(ft_t ft) 
 {
         int rc;
 
         /* Flush out remaining samples*/
-        rc = st_rawstopwrite(ft);
+        rc = sox_rawstopwrite(ft);
         if (rc)
             return rc;
 
         /* All samples are already written out. */
         
-        if (st_seeki(ft, 0, 0) != 0) 
+        if (sox_seeki(ft, 0, 0) != 0) 
         {
-            st_fail_errno(ft,errno,"can't rewind output file to rewrite MAUD header");
-            return(ST_EOF);
+            sox_fail_errno(ft,errno,"can't rewind output file to rewrite MAUD header");
+            return(SOX_EOF);
         }
         
         maudwriteheader(ft);
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 #define MAUDHEADERSIZE (4+(4+4+32)+(4+4+32)+(4+4))
@@ -267,30 +267,30 @@
 {
         struct maudstuff * p = (struct maudstuff *) ft->priv;
         
-        st_writes(ft, "FORM");
-        st_writedw(ft, (p->nsamples*ft->signal.size) + MAUDHEADERSIZE);  /* size of file */
-        st_writes(ft, "MAUD"); /* File type */
+        sox_writes(ft, "FORM");
+        sox_writedw(ft, (p->nsamples*ft->signal.size) + MAUDHEADERSIZE);  /* size of file */
+        sox_writes(ft, "MAUD"); /* File type */
         
-        st_writes(ft, "MHDR");
-        st_writedw(ft,  8*4); /* number of bytes to follow */
-        st_writedw(ft, p->nsamples);  /* number of samples stored in MDAT */
+        sox_writes(ft, "MHDR");
+        sox_writedw(ft,  8*4); /* number of bytes to follow */
+        sox_writedw(ft, p->nsamples);  /* number of samples stored in MDAT */
         
         switch (ft->signal.encoding) {
                 
-        case ST_ENCODING_UNSIGNED:
-                st_writew(ft, (int) 8); /* number of bits per sample as stored in MDAT */
-                st_writew(ft, (int) 8); /* number of bits per sample after decompression */
+        case SOX_ENCODING_UNSIGNED:
+                sox_writew(ft, (int) 8); /* number of bits per sample as stored in MDAT */
+                sox_writew(ft, (int) 8); /* number of bits per sample after decompression */
                 break;
                 
-        case ST_ENCODING_SIGN2:
-                st_writew(ft, (int) 16); /* number of bits per sample as stored in MDAT */
-                st_writew(ft, (int) 16); /* number of bits per sample after decompression */
+        case SOX_ENCODING_SIGN2:
+                sox_writew(ft, (int) 16); /* number of bits per sample as stored in MDAT */
+                sox_writew(ft, (int) 16); /* number of bits per sample after decompression */
                 break;
                 
-        case ST_ENCODING_ALAW:
-        case ST_ENCODING_ULAW:
-                st_writew(ft, (int) 8); /* number of bits per sample as stored in MDAT */
-                st_writew(ft, (int) 16); /* number of bits per sample after decompression */
+        case SOX_ENCODING_ALAW:
+        case SOX_ENCODING_ULAW:
+                sox_writew(ft, (int) 8); /* number of bits per sample as stored in MDAT */
+                sox_writew(ft, (int) 16); /* number of bits per sample after decompression */
                 break;
 
         default:
@@ -297,31 +297,31 @@
                 break;
         }
         
-        st_writedw(ft, ft->signal.rate); /* clock source frequency */
-        st_writew(ft, (int) 1); /* clock devide */
+        sox_writedw(ft, ft->signal.rate); /* clock source frequency */
+        sox_writew(ft, (int) 1); /* clock devide */
         
         if (ft->signal.channels == 1) {
-                st_writew(ft, (int) 0); /* channel information */
-                st_writew(ft, (int) 1); /* number of channels (mono: 1, stereo: 2, ...) */
+                sox_writew(ft, (int) 0); /* channel information */
+                sox_writew(ft, (int) 1); /* number of channels (mono: 1, stereo: 2, ...) */
         }
         else {
-                st_writew(ft, (int) 1);
-                st_writew(ft, (int) 2);
+                sox_writew(ft, (int) 1);
+                sox_writew(ft, (int) 2);
         }
         
         switch (ft->signal.encoding) {
                 
-        case ST_ENCODING_UNSIGNED:
-        case ST_ENCODING_SIGN2:
-                st_writew(ft, (int) 0); /* no compression */
+        case SOX_ENCODING_UNSIGNED:
+        case SOX_ENCODING_SIGN2:
+                sox_writew(ft, (int) 0); /* no compression */
                 break;
                 
-        case ST_ENCODING_ULAW:
-                st_writew(ft, (int) 3);
+        case SOX_ENCODING_ULAW:
+                sox_writew(ft, (int) 3);
                 break;
                 
-        case ST_ENCODING_ALAW:
-                st_writew(ft, (int) 2);
+        case SOX_ENCODING_ALAW:
+                sox_writew(ft, (int) 2);
                 break;
 
         default:
@@ -328,16 +328,16 @@
                 break;
         }
         
-        st_writedw(ft, 0); /* reserved */
-        st_writedw(ft, 0); /* reserved */
-        st_writedw(ft, 0); /* reserved */
+        sox_writedw(ft, 0); /* reserved */
+        sox_writedw(ft, 0); /* reserved */
+        sox_writedw(ft, 0); /* reserved */
         
-        st_writes(ft, "ANNO");
-        st_writedw(ft, 30); /* length of block */
-        st_writes(ft, "file create by Sound eXchange ");
+        sox_writes(ft, "ANNO");
+        sox_writedw(ft, 30); /* length of block */
+        sox_writes(ft, "file create by Sound eXchange ");
         
-        st_writes(ft, "MDAT");
-        st_writedw(ft, p->nsamples * ft->signal.size ); /* samples in file */
+        sox_writes(ft, "MDAT");
+        sox_writedw(ft, p->nsamples * ft->signal.size ); /* samples in file */
 }
 
 /* Amiga MAUD */
@@ -346,20 +346,20 @@
   NULL,
 };
 
-static st_format_t st_maud_format = {
+static sox_format_t sox_maud_format = {
   maudnames,
   NULL,
-  ST_FILE_BIG_END,
-  st_maudstartread,
-  st_rawread,
-  st_rawstopread,
-  st_maudstartwrite,
-  st_maudwrite,
-  st_maudstopwrite,
-  st_format_nothing_seek
+  SOX_FILE_BIG_END,
+  sox_maudstartread,
+  sox_rawread,
+  sox_rawstopread,
+  sox_maudstartwrite,
+  sox_maudwrite,
+  sox_maudstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_maud_format_fn(void)
+const sox_format_t *sox_maud_format_fn(void)
 {
-    return &st_maud_format;
+    return &sox_maud_format;
 }
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -90,7 +90,7 @@
   double bandwidth;
 } *butterworth_crossover_t;
 
-static int lowpass_setup (butterworth_crossover_t butterworth, double frequency, st_rate_t rate, st_size_t nchan) {
+static int lowpass_setup (butterworth_crossover_t butterworth, double frequency, sox_rate_t rate, sox_size_t nchan) {
   double c;
 
   butterworth->xy_low = (struct xy *)xcalloc(nchan, sizeof(struct xy));
@@ -120,17 +120,17 @@
   butterworth->b_high[0] = 2 * (c * c - 1.0) * butterworth->a_high[0];
   butterworth->b_high[1] = (1.0 - sqrt(2.0) * c + c * c) * butterworth->a_high[0];
 
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
-static int lowpass_flow(eff_t effp, butterworth_crossover_t butterworth, st_size_t nChan, st_sample_t *ibuf, st_sample_t *lowbuf, st_sample_t *highbuf,
-                         st_size_t len) {
-  st_size_t chan;
+static int lowpass_flow(eff_t effp, butterworth_crossover_t butterworth, sox_size_t nChan, sox_sample_t *ibuf, sox_sample_t *lowbuf, sox_sample_t *highbuf,
+                         sox_size_t len) {
+  sox_size_t chan;
   double in, out;
 
-  st_size_t done;
+  sox_size_t done;
 
-  st_sample_t *ibufptr, *lowbufptr, *highbufptr;
+  sox_sample_t *ibufptr, *lowbufptr, *highbufptr;
 
   for (chan=0;chan<nChan;++chan) {
     ibufptr = ibuf+chan;
@@ -159,7 +159,7 @@
       butterworth->xy_low[chan].y [1] = butterworth->xy_low[chan].y [0];
       butterworth->xy_low[chan].y [0] = out;
 
-      ST_SAMPLE_CLIP_COUNT(out, effp->clips);
+      SOX_SAMPLE_CLIP_COUNT(out, effp->clips);
 
       *lowbufptr = out;
 
@@ -175,7 +175,7 @@
       butterworth->xy_high[chan].y [1] = butterworth->xy_high[chan].y [0];
       butterworth->xy_high[chan].y [0] = out;
 
-      ST_SAMPLE_CLIP_COUNT(out, effp->clips);
+      SOX_SAMPLE_CLIP_COUNT(out, effp->clips);
 
       /* don't forget polarity reversal of high pass! */
 
@@ -186,13 +186,13 @@
     }
   }
 
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 typedef struct comp_band {
-  st_compandt_t transfer_fn;
+  sox_compandt_t transfer_fn;
 
-  st_size_t expectedChannels; /* Also flags that channels aren't to be treated
+  sox_size_t expectedChannels; /* Also flags that channels aren't to be treated
                            individually when = 1 and input not mono */
   double *attackRate;   /* An array of attack rates */
   double *decayRate;    /*    ... and of decay rates */
@@ -200,17 +200,17 @@
   double delay;         /* Delay to apply before companding */
   double topfreq;       /* upper bound crossover frequency */
   struct butterworth_crossover filter;
-  st_sample_t *delay_buf;   /* Old samples, used for delay processing */
-  st_size_t delay_size;    /* lookahead for this band (in samples) - function of delay, above */
-  st_ssize_t delay_buf_ptr; /* Index into delay_buf */
-  st_size_t delay_buf_cnt; /* No. of active entries in delay_buf */
+  sox_sample_t *delay_buf;   /* Old samples, used for delay processing */
+  sox_size_t delay_size;    /* lookahead for this band (in samples) - function of delay, above */
+  sox_ssize_t delay_buf_ptr; /* Index into delay_buf */
+  sox_size_t delay_buf_cnt; /* No. of active entries in delay_buf */
 } *comp_band_t;
 
 typedef struct {
-  st_size_t nBands;
-  st_sample_t *band_buf1, *band_buf2, *band_buf3;
-  st_size_t band_buf_len;
-  st_size_t delay_buf_size;/* Size of delay_buf in samples */
+  sox_size_t nBands;
+  sox_sample_t *band_buf1, *band_buf2, *band_buf3;
+  sox_size_t band_buf_len;
+  sox_size_t delay_buf_size;/* Size of delay_buf in samples */
   struct comp_band *bands;
 } *compand_t;
 
@@ -220,10 +220,10 @@
  * Don't do initialization now.
  * The 'info' fields are not yet filled in.
  */
-static int st_mcompand_getopts_1(comp_band_t l, st_size_t n, char **argv)
+static int sox_mcompand_getopts_1(comp_band_t l, sox_size_t n, char **argv)
 {
       char *s;
-      st_size_t rates, i, commas;
+      sox_size_t rates, i, commas;
 
       /* Start by checking the attack and decay rates */
 
@@ -233,8 +233,8 @@
       if (commas % 2 == 0) /* There must be an even number of
                               attack/decay parameters */
       {
-        st_fail("compander: Odd number of attack & decay rate parameters");
-        return (ST_EOF);
+        sox_fail("compander: Odd number of attack & decay rate parameters");
+        return (SOX_EOF);
       }
 
       rates = 1 + commas/2;
@@ -254,8 +254,8 @@
         ++i;
       } while (s != NULL);
 
-      if (!st_compandt_parse(&l->transfer_fn, argv[1], n>2 ? argv[2] : 0))
-        return ST_EOF;
+      if (!sox_compandt_parse(&l->transfer_fn, argv[1], n>2 ? argv[2] : 0))
+        return SOX_EOF;
 
       /* Set the initial "volume" to be attibuted to the input channels.
          Unless specified, choose 1.0 (maximum) otherwise clipping will
@@ -268,10 +268,10 @@
         if (n >= 5) l->delay = atof(argv[4]);
         else l->delay = 0.0;
       }
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-static int parse_subarg(char *s, char **subargv, st_size_t *subargc) {
+static int parse_subarg(char *s, char **subargv, sox_size_t *subargc) {
   char **ap;
   char *s_p;
 
@@ -291,19 +291,19 @@
 
   if (*subargc < 2 || *subargc > 5)
     {
-      st_fail("Wrong number of parameters for the compander effect within mcompand; usage:\n"
+      sox_fail("Wrong number of parameters for the compander effect within mcompand; usage:\n"
   "\tattack1,decay1{,attack2,decay2} [soft-knee-dB:]in-dB1[,out-dB1]{,in-dB2,out-dB2} [gain [initial-volume-dB [delay]]]\n"
   "\twhere {} means optional and repeatable and [] means optional.\n"
   "\tdB values are floating point or -inf'; times are in seconds.");
-      return (ST_EOF);
+      return (SOX_EOF);
     } else
-      return ST_SUCCESS;
+      return SOX_SUCCESS;
 }
 
-static int st_mcompand_getopts(eff_t effp, int n, char **argv) 
+static int sox_mcompand_getopts(eff_t effp, int n, char **argv) 
 {
   char *subargv[6], *cp;
-  st_size_t subargc, i, len;
+  sox_size_t subargc, i, len;
 
   compand_t c = (compand_t) effp->priv;
 
@@ -312,9 +312,9 @@
 
   /* how many bands? */
   if (! (n&1)) {
-    st_fail("mcompand accepts only an odd number of arguments:\n"
+    sox_fail("mcompand accepts only an odd number of arguments:\n"
             "  mcompand quoted_compand_args [xover_freq quoted_compand_args [...]");
-    return ST_EOF;
+    return SOX_EOF;
   }
   c->nBands = (n+1)>>1;
 
@@ -322,26 +322,26 @@
 
   for (i=0;i<c->nBands;++i) {
     len = strlen(argv[i<<1]);
-    if (parse_subarg(argv[i<<1],subargv,&subargc) != ST_SUCCESS)
-      return ST_EOF;
-    if (st_mcompand_getopts_1(&c->bands[i], subargc, &subargv[0]) != ST_SUCCESS)
-      return ST_EOF;
+    if (parse_subarg(argv[i<<1],subargv,&subargc) != SOX_SUCCESS)
+      return SOX_EOF;
+    if (sox_mcompand_getopts_1(&c->bands[i], subargc, &subargv[0]) != SOX_SUCCESS)
+      return SOX_EOF;
     if (i == (c->nBands-1))
       c->bands[i].topfreq = 0;
     else {
       c->bands[i].topfreq = strtod(argv[(i<<1)+1],&cp);
       if (*cp) {
-        st_fail("bad frequency in args to mcompand");
-        return ST_EOF;
+        sox_fail("bad frequency in args to mcompand");
+        return SOX_EOF;
       }
       if ((i>0) && (c->bands[i].topfreq < c->bands[i-1].topfreq)) {
-        st_fail("mcompand crossover frequencies must be in ascending order.");
-        return ST_EOF;
+        sox_fail("mcompand crossover frequencies must be in ascending order.");
+        return SOX_EOF;
       }
     }
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
@@ -348,12 +348,12 @@
  * Prepare processing.
  * Do all initializations.
  */
-static int st_mcompand_start(eff_t effp)
+static int sox_mcompand_start(eff_t effp)
 {
   compand_t c = (compand_t) effp->priv;
   comp_band_t l;
-  st_size_t i;
-  st_size_t band;
+  sox_size_t i;
+  sox_size_t band;
   
   for (band=0;band<c->nBands;++band) {
     l = &c->bands[band];
@@ -381,7 +381,7 @@
 
     /* Allocate the delay buffer */
     if (c->delay_buf_size > 0)
-      l->delay_buf = (st_sample_t *)xcalloc(sizeof(long), c->delay_buf_size);
+      l->delay_buf = (sox_sample_t *)xcalloc(sizeof(long), c->delay_buf_size);
     l->delay_buf_ptr = 0;
     l->delay_buf_cnt = 0;
 
@@ -388,7 +388,7 @@
     if (l->topfreq != 0)
       lowpass_setup(&l->filter, l->topfreq, effp->outinfo.rate, effp->outinfo.channels);
   }
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 /*
@@ -396,9 +396,9 @@
  * value, the attack rate and decay rate
  */
 
-static void doVolume(double *v, double samp, comp_band_t l, st_size_t chan)
+static void doVolume(double *v, double samp, comp_band_t l, sox_size_t chan)
 {
-  double s = samp/(~((st_sample_t)1<<31));
+  double s = samp/(~((sox_sample_t)1<<31));
   double delta = s - *v;
 
   if (delta > 0.0) /* increase volume according to attack rate */
@@ -407,9 +407,9 @@
     *v += delta * l->decayRate[chan];
 }
 
-static int st_mcompand_flow_1(eff_t effp, compand_t c, comp_band_t l, const st_sample_t *ibuf, st_sample_t *obuf, st_size_t len, st_size_t filechans)
+static int sox_mcompand_flow_1(eff_t effp, compand_t c, comp_band_t l, const sox_sample_t *ibuf, sox_sample_t *obuf, sox_size_t len, sox_size_t filechans)
 {
-  st_size_t done, chan;
+  sox_size_t done, chan;
 
   for (done = 0; done < len; ibuf += filechans) {
 
@@ -433,12 +433,12 @@
     for (chan = 0; chan < filechans; ++chan) {
       int ch = l->expectedChannels > 1 ? chan : 0;
       double level_in_lin = l->volume[ch];
-      double level_out_lin = st_compandt(&l->transfer_fn, level_in_lin);
+      double level_out_lin = sox_compandt(&l->transfer_fn, level_in_lin);
       double checkbuf;
 
       if (c->delay_buf_size <= 0) {
         checkbuf = ibuf[chan] * level_out_lin;
-        ST_SAMPLE_CLIP_COUNT(checkbuf, effp->clips);
+        SOX_SAMPLE_CLIP_COUNT(checkbuf, effp->clips);
         obuf[done++] = checkbuf;
 
       } else {
@@ -457,7 +457,7 @@
 
         if (l->delay_buf_cnt >= l->delay_size)
           checkbuf = l->delay_buf[(l->delay_buf_ptr + c->delay_buf_size - l->delay_size)%c->delay_buf_size] * level_out_lin;
-          ST_SAMPLE_CLIP_COUNT(checkbuf, effp->clips);
+          SOX_SAMPLE_CLIP_COUNT(checkbuf, effp->clips);
           l->delay_buf[(l->delay_buf_ptr + c->delay_buf_size - l->delay_size)%c->delay_buf_size] = checkbuf;
         if (l->delay_buf_cnt >= c->delay_buf_size)
           obuf[done++] = l->delay_buf[l->delay_buf_ptr];
@@ -469,7 +469,7 @@
     }
   }
 
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 /*
@@ -476,26 +476,26 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_mcompand_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                     st_size_t *isamp, st_size_t *osamp) {
+static int sox_mcompand_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                     sox_size_t *isamp, sox_size_t *osamp) {
   compand_t c = (compand_t) effp->priv;
   comp_band_t l;
-  st_size_t len = min(*isamp, *osamp);
-  st_size_t band, i;
-  st_sample_t *abuf, *bbuf, *cbuf, *oldabuf, *ibuf_copy;
+  sox_size_t len = min(*isamp, *osamp);
+  sox_size_t band, i;
+  sox_sample_t *abuf, *bbuf, *cbuf, *oldabuf, *ibuf_copy;
   double out;
 
   if (c->band_buf_len < len) {
-    c->band_buf1 = (st_sample_t *)xrealloc(c->band_buf1,len*sizeof(st_sample_t));
-    c->band_buf2 = (st_sample_t *)xrealloc(c->band_buf2,len*sizeof(st_sample_t));
-    c->band_buf3 = (st_sample_t *)xrealloc(c->band_buf3,len*sizeof(st_sample_t));
+    c->band_buf1 = (sox_sample_t *)xrealloc(c->band_buf1,len*sizeof(sox_sample_t));
+    c->band_buf2 = (sox_sample_t *)xrealloc(c->band_buf2,len*sizeof(sox_sample_t));
+    c->band_buf3 = (sox_sample_t *)xrealloc(c->band_buf3,len*sizeof(sox_sample_t));
     c->band_buf_len = len;
   }
 
-  ibuf_copy = (st_sample_t *)xmalloc(*isamp * sizeof(st_sample_t));
-  memcpy(ibuf_copy, ibuf, *isamp * sizeof(st_sample_t));
+  ibuf_copy = (sox_sample_t *)xmalloc(*isamp * sizeof(sox_sample_t));
+  memcpy(ibuf_copy, ibuf, *isamp * sizeof(sox_sample_t));
 
-  /* split ibuf into bands using butterworths, pipe each band through st_mcompand_flow_1, then add back together and write to obuf */
+  /* split ibuf into bands using butterworths, pipe each band through sox_mcompand_flow_1, then add back together and write to obuf */
 
   memset(obuf,0,len * sizeof *obuf);
   for (band=0,abuf=ibuf_copy,bbuf=c->band_buf2,cbuf=c->band_buf1;band<c->nBands;++band) {
@@ -509,11 +509,11 @@
     }
     if (abuf == ibuf_copy)
       abuf = c->band_buf3;
-    (void)st_mcompand_flow_1(effp, c,l,bbuf,abuf,len,effp->outinfo.channels);
+    (void)sox_mcompand_flow_1(effp, c,l,bbuf,abuf,len,effp->outinfo.channels);
     for (i=0;i<len;++i)
     {
       out = obuf[i] + abuf[i];
-      ST_SAMPLE_CLIP_COUNT(out, effp->clips);
+      SOX_SAMPLE_CLIP_COUNT(out, effp->clips);
       obuf[i] = out;
     }
     oldabuf = abuf;
@@ -525,12 +525,12 @@
 
   free(ibuf_copy);
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static int st_mcompand_drain_1(eff_t effp, compand_t c, comp_band_t l, st_sample_t *obuf, st_size_t maxdrain)
+static int sox_mcompand_drain_1(eff_t effp, compand_t c, comp_band_t l, sox_sample_t *obuf, sox_size_t maxdrain)
 {
-  st_size_t done;
+  sox_size_t done;
   double out;
 
   /*
@@ -538,7 +538,7 @@
    */
   for (done = 0;  done < maxdrain  &&  l->delay_buf_cnt > 0;  done++) {
     out = obuf[done] + l->delay_buf[l->delay_buf_ptr++];
-    ST_SAMPLE_CLIP_COUNT(out, effp->clips);
+    SOX_SAMPLE_CLIP_COUNT(out, effp->clips);
     obuf[done] = out;
     l->delay_buf_ptr %= c->delay_buf_size;
     l->delay_buf_cnt--;
@@ -552,9 +552,9 @@
 /*
  * Drain out compander delay lines. 
  */
-static int st_mcompand_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_mcompand_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
-  st_size_t band, drained, mostdrained = 0;
+  sox_size_t band, drained, mostdrained = 0;
   compand_t c = (compand_t)effp->priv;
   comp_band_t l;
 
@@ -561,7 +561,7 @@
   memset(obuf,0,*osamp * sizeof *obuf);
   for (band=0;band<c->nBands;++band) {
     l = &c->bands[band];
-    drained = st_mcompand_drain_1(effp, c,l,obuf,*osamp);
+    drained = sox_mcompand_drain_1(effp, c,l,obuf,*osamp);
     if (drained > mostdrained)
       mostdrained = drained;
   }
@@ -569,19 +569,19 @@
   *osamp = mostdrained;
 
   if (mostdrained)
-      return ST_SUCCESS;
+      return SOX_SUCCESS;
   else
-      return ST_EOF;
+      return SOX_EOF;
 }
 
 /*
  * Clean up compander effect.
  */
-static int st_mcompand_stop(eff_t effp)
+static int sox_mcompand_stop(eff_t effp)
 {
   compand_t c = (compand_t) effp->priv;
   comp_band_t l;
-  st_size_t band;
+  sox_size_t band;
 
   free(c->band_buf1);
   c->band_buf1 = NULL;
@@ -599,18 +599,18 @@
     }
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static int st_mcompand_delete(eff_t effp)
+static int sox_mcompand_delete(eff_t effp)
 {
   compand_t c = (compand_t) effp->priv;
   comp_band_t l;
-  st_size_t band;
+  sox_size_t band;
 
   for (band = 0; band < c->nBands; band++) {
     l = &c->bands[band];
-    st_compandt_kill(&l->transfer_fn);
+    sox_compandt_kill(&l->transfer_fn);
     free(l->decayRate);
     free(l->attackRate);
     free(l->volume);
@@ -618,10 +618,10 @@
   free(c->bands);
   c->bands = NULL;
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static st_effect_t st_mcompand_effect = {
+static sox_effect_t sox_mcompand_effect = {
   "mcompand",
   "Usage: mcompand quoted_compand_args [crossover_frequency quoted_compand_args [...]]\n"
   "\n"
@@ -630,16 +630,16 @@
   "  attack1,decay1[,attack2,decay2...]\n"
   "                 in-dB1,out-dB1[,in-dB2,out-dB2...]\n"
   "                [ gain [ initial-volume [ delay ] ] ]\n",
-  ST_EFF_MCHAN,
-  st_mcompand_getopts,
-  st_mcompand_start,
-  st_mcompand_flow,
-  st_mcompand_drain,
-  st_mcompand_stop,
-  st_mcompand_delete
+  SOX_EFF_MCHAN,
+  sox_mcompand_getopts,
+  sox_mcompand_start,
+  sox_mcompand_flow,
+  sox_mcompand_drain,
+  sox_mcompand_stop,
+  sox_mcompand_delete
 };
 
-const st_effect_t *st_mcompand_effect_fn(void)
+const sox_effect_t *sox_mcompand_effect_fn(void)
 {
-    return &st_mcompand_effect;
+    return &sox_mcompand_effect;
 }
--- a/src/misc.c
+++ b/src/misc.c
@@ -11,7 +11,7 @@
  * Sound Tools miscellaneous stuff.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -29,7 +29,7 @@
 #include <byteswap.h>
 #endif
 
-const char * const st_sizes_str[] = {
+const char * const sox_sizes_str[] = {
         "NONSENSE!",
         "1 byte",
         "2 bytes",
@@ -41,7 +41,7 @@
         "8 bytes"
 };
 
-const char * const st_size_bits_str[] = {
+const char * const sox_size_bits_str[] = {
         "NONSENSE!",
         "8-bit",
         "16-bit",
@@ -53,7 +53,7 @@
         "64-bit"
 };
 
-const char * const st_encodings_str[] = {
+const char * const sox_encodings_str[] = {
         "NONSENSE!",
 
         "u-law",
@@ -63,7 +63,7 @@
         "IMA-ADPCM",
         "OKI-ADPCM",
 
-        "",   /* FIXME, see st.h */
+        "",   /* FIXME, see sox.h */
 
         "unsigned",
         "signed (2's complement)",
@@ -75,8 +75,8 @@
         "AMR-WB",
 };
 
-assert_static(array_length(st_encodings_str) == ST_ENCODINGS,
-    SIZE_MISMATCH_BETWEEN_st_encodings_t_AND_st_encodings_str);
+assert_static(array_length(sox_encodings_str) == SOX_ENCODINGS,
+    SIZE_MISMATCH_BETWEEN_sox_encodings_t_AND_sox_encodings_str);
 
 static const char readerr[] = "Premature EOF while reading sample file.";
 static const char writerr[] = "Error writing sample file.  You are probably out of disk space.";
@@ -112,31 +112,31 @@
 /* Read in a buffer of data of length len and each element is size bytes.
  * Returns number of elements read, not bytes read.
  */
-size_t st_readbuf(ft_t ft, void *buf, size_t size, st_size_t len)
+size_t sox_readbuf(ft_t ft, void *buf, size_t size, sox_size_t len)
 {
     return fread(buf, size, len, ft->fp);
 }
 
 /* Skip input without seeking. */
-int st_skipbytes(ft_t ft, st_size_t n)
+int sox_skipbytes(ft_t ft, sox_size_t n)
 {
   unsigned char trash;
 
   while (n--)
-    if (st_readb(ft, &trash) == ST_EOF)
-      return (ST_EOF);
+    if (sox_readb(ft, &trash) == SOX_EOF)
+      return (SOX_EOF);
   
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 /* Pad output. */
-int st_padbytes(ft_t ft, st_size_t n)
+int sox_padbytes(ft_t ft, sox_size_t n)
 {
   while (n--)
-    if (st_writeb(ft, '\0') == ST_EOF)
-      return (ST_EOF);
+    if (sox_writeb(ft, '\0') == SOX_EOF)
+      return (SOX_EOF);
 
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 /* Write a buffer of data of length len and each element is size bytes.
@@ -143,57 +143,57 @@
  * Returns number of elements writen, not bytes written.
  */
 
-size_t st_writebuf(ft_t ft, void const *buf, size_t size, st_size_t len)
+size_t sox_writebuf(ft_t ft, void const *buf, size_t size, sox_size_t len)
 {
     return fwrite(buf, size, len, ft->fp);
 }
 
-st_size_t st_filelength(ft_t ft)
+sox_size_t sox_filelength(ft_t ft)
 {
   struct stat st;
 
   fstat(fileno(ft->fp), &st);
 
-  return (st_size_t)st.st_size;
+  return (sox_size_t)st.st_size;
 }
 
-int st_flush(ft_t ft)
+int sox_flush(ft_t ft)
 {
   return fflush(ft->fp);
 }
 
-st_size_t st_tell(ft_t ft)
+sox_size_t sox_tell(ft_t ft)
 {
-  return (st_size_t)ftello(ft->fp);
+  return (sox_size_t)ftello(ft->fp);
 }
 
-int st_eof(ft_t ft)
+int sox_eof(ft_t ft)
 {
   return feof(ft->fp);
 }
 
-int st_error(ft_t ft)
+int sox_error(ft_t ft)
 {
   return ferror(ft->fp);
 }
 
-void st_rewind(ft_t ft)
+void sox_rewind(ft_t ft)
 {
   rewind(ft->fp);
 }
 
-void st_clearerr(ft_t ft)
+void sox_clearerr(ft_t ft)
 {
   clearerr(ft->fp);
 }
 
 /* Read and write known datatypes in "machine format".  Swap if indicated.
- * They all return ST_EOF on error and ST_SUCCESS on success.
+ * They all return SOX_EOF on error and SOX_SUCCESS on success.
  */
 /* Read n-char string (and possibly null-terminating).
  * Stop reading and null-terminate string if either a 0 or \n is reached.
  */
-int st_reads(ft_t ft, char *c, st_size_t len)
+int sox_reads(ft_t ft, char *c, sox_size_t len)
 {
     char *sc;
     char in;
@@ -201,11 +201,11 @@
     sc = c;
     do
     {
-        if (st_readbuf(ft, &in, 1, 1) != 1)
+        if (sox_readbuf(ft, &in, 1, 1) != 1)
         {
             *sc = 0;
-                st_fail_errno(ft,errno,readerr);
-            return (ST_EOF);
+                sox_fail_errno(ft,errno,readerr);
+            return (SOX_EOF);
         }
         if (in == 0 || in == '\n')
             break;
@@ -214,178 +214,178 @@
         sc++;
     } while (sc - c < (ptrdiff_t)len);
     *sc = 0;
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
 }
 
 /* Write null-terminated string (without \0). */
-int st_writes(ft_t ft, char *c)
+int sox_writes(ft_t ft, char *c)
 {
-        if (st_writebuf(ft, c, 1, strlen(c)) != strlen(c))
+        if (sox_writebuf(ft, c, 1, strlen(c)) != strlen(c))
         {
-                st_fail_errno(ft,errno,writerr);
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,writerr);
+                return(SOX_EOF);
         }
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* Read byte. */
-int st_readb(ft_t ft, uint8_t *ub)
+int sox_readb(ft_t ft, uint8_t *ub)
 {
-  if (st_readbuf(ft, ub, 1, 1) != 1) {
-    st_fail_errno(ft,errno,readerr);
-    return ST_EOF;
+  if (sox_readbuf(ft, ub, 1, 1) != 1) {
+    sox_fail_errno(ft,errno,readerr);
+    return SOX_EOF;
   }
   if (ft->signal.reverse_bits)
     *ub = cswap[*ub];
   if (ft->signal.reverse_nibbles)
     *ub = ((*ub & 15) << 4) | (*ub >> 4);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /* Write byte. */
-int st_writeb(ft_t ft, uint8_t ub)
+int sox_writeb(ft_t ft, uint8_t ub)
 {
   if (ft->signal.reverse_nibbles)
     ub = ((ub & 15) << 4) | (ub >> 4);
   if (ft->signal.reverse_bits)
     ub = cswap[ub];
-  if (st_writebuf(ft, &ub, 1, 1) != 1) {
-    st_fail_errno(ft,errno,writerr);
-    return ST_EOF;
+  if (sox_writebuf(ft, &ub, 1, 1) != 1) {
+    sox_fail_errno(ft,errno,writerr);
+    return SOX_EOF;
   }
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /* Read word. */
-int st_readw(ft_t ft, uint16_t *uw)
+int sox_readw(ft_t ft, uint16_t *uw)
 {
-        if (st_readbuf(ft, uw, 2, 1) != 1)
+        if (sox_readbuf(ft, uw, 2, 1) != 1)
         {
-            st_fail_errno(ft,errno,readerr);
-            return (ST_EOF);
+            sox_fail_errno(ft,errno,readerr);
+            return (SOX_EOF);
         }
         if (ft->signal.reverse_bytes)
-                *uw = st_swapw(*uw);
-        return ST_SUCCESS;
+                *uw = sox_swapw(*uw);
+        return SOX_SUCCESS;
 }
 
 /* Write word. */
-int st_writew(ft_t ft, uint16_t uw)
+int sox_writew(ft_t ft, uint16_t uw)
 {
         if (ft->signal.reverse_bytes)
-                uw = st_swapw(uw);
-        if (st_writebuf(ft, &uw, 2, 1) != 1)
+                uw = sox_swapw(uw);
+        if (sox_writebuf(ft, &uw, 2, 1) != 1)
         {
-                st_fail_errno(ft,errno,writerr);
-                return (ST_EOF);
+                sox_fail_errno(ft,errno,writerr);
+                return (SOX_EOF);
         }
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* Read three bytes. */
-int st_read3(ft_t ft, uint24_t *u3)
+int sox_read3(ft_t ft, uint24_t *u3)
 {
-        if (st_readbuf(ft, u3, 3, 1) != 1)
+        if (sox_readbuf(ft, u3, 3, 1) != 1)
         {
-            st_fail_errno(ft,errno,readerr);
-            return (ST_EOF);
+            sox_fail_errno(ft,errno,readerr);
+            return (SOX_EOF);
         }
         if (ft->signal.reverse_bytes)
-                *u3 = st_swap24(*u3);
-        return ST_SUCCESS;
+                *u3 = sox_swap24(*u3);
+        return SOX_SUCCESS;
 }
 
 /* Write three bytes. */
-int st_write3(ft_t ft, uint24_t u3)
+int sox_write3(ft_t ft, uint24_t u3)
 {
         if (ft->signal.reverse_bytes)
-                u3 = st_swap24(u3);
-        if (st_writebuf(ft, &u3, 3, 1) != 1)
+                u3 = sox_swap24(u3);
+        if (sox_writebuf(ft, &u3, 3, 1) != 1)
         {
-                st_fail_errno(ft,errno,writerr);
-                return (ST_EOF);
+                sox_fail_errno(ft,errno,writerr);
+                return (SOX_EOF);
         }
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* Read double word. */
-int st_readdw(ft_t ft, uint32_t *udw)
+int sox_readdw(ft_t ft, uint32_t *udw)
 {
-        if (st_readbuf(ft, udw, 4, 1) != 1)
+        if (sox_readbuf(ft, udw, 4, 1) != 1)
         {
-            st_fail_errno(ft,errno,readerr);
-            return (ST_EOF);
+            sox_fail_errno(ft,errno,readerr);
+            return (SOX_EOF);
         }
         if (ft->signal.reverse_bytes)
-                *udw = st_swapdw(*udw);
-        return ST_SUCCESS;
+                *udw = sox_swapdw(*udw);
+        return SOX_SUCCESS;
 }
 
 /* Write double word. */
-int st_writedw(ft_t ft, uint32_t udw)
+int sox_writedw(ft_t ft, uint32_t udw)
 {
         if (ft->signal.reverse_bytes)
-                udw = st_swapdw(udw);
-        if (st_writebuf(ft, &udw, 4, 1) != 1)
+                udw = sox_swapdw(udw);
+        if (sox_writebuf(ft, &udw, 4, 1) != 1)
         {
-                st_fail_errno(ft,errno,writerr);
-                return (ST_EOF);
+                sox_fail_errno(ft,errno,writerr);
+                return (SOX_EOF);
         }
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* Read float. */
-int st_readf(ft_t ft, float *f)
+int sox_readf(ft_t ft, float *f)
 {
-        if (st_readbuf(ft, f, sizeof(float), 1) != 1)
+        if (sox_readbuf(ft, f, sizeof(float), 1) != 1)
         {
-            st_fail_errno(ft,errno,readerr);
-            return(ST_EOF);
+            sox_fail_errno(ft,errno,readerr);
+            return(SOX_EOF);
         }
         if (ft->signal.reverse_bytes)
-                *f = st_swapf(*f);
-        return ST_SUCCESS;
+                *f = sox_swapf(*f);
+        return SOX_SUCCESS;
 }
 
 /* Write float. */
-int st_writef(ft_t ft, float f)
+int sox_writef(ft_t ft, float f)
 {
         float t = f;
 
         if (ft->signal.reverse_bytes)
-                t = st_swapf(t);
-        if (st_writebuf(ft, &t, sizeof(float), 1) != 1)
+                t = sox_swapf(t);
+        if (sox_writebuf(ft, &t, sizeof(float), 1) != 1)
         {
-                st_fail_errno(ft,errno,writerr);
-                return (ST_EOF);
+                sox_fail_errno(ft,errno,writerr);
+                return (SOX_EOF);
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /* Read double. */
-int st_readdf(ft_t ft, double *d)
+int sox_readdf(ft_t ft, double *d)
 {
-        if (st_readbuf(ft, d, sizeof(double), 1) != 1)
+        if (sox_readbuf(ft, d, sizeof(double), 1) != 1)
         {
-            st_fail_errno(ft,errno,readerr);
-            return(ST_EOF);
+            sox_fail_errno(ft,errno,readerr);
+            return(SOX_EOF);
         }
         if (ft->signal.reverse_bytes)
-                *d = st_swapd(*d);
-        return ST_SUCCESS;
+                *d = sox_swapd(*d);
+        return SOX_SUCCESS;
 }
 
 /* Write double. */
-int st_writedf(ft_t ft, double d)
+int sox_writedf(ft_t ft, double d)
 {
         if (ft->signal.reverse_bytes)
-                d = st_swapd(d);
-        if (st_writebuf(ft, &d, sizeof(double), 1) != 1)
+                d = sox_swapd(d);
+        if (sox_writebuf(ft, &d, sizeof(double), 1) != 1)
         {
-                st_fail_errno(ft,errno,writerr);
-                return (ST_EOF);
+                sox_fail_errno(ft,errno,writerr);
+                return (SOX_EOF);
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 
@@ -433,7 +433,7 @@
 }
 
 /* generic swap routine. Swap l and place in to f (datatype length = n) */
-static void st_swapb(char *l, char *f, int n)
+static void sox_swapb(char *l, char *f, int n)
 {
     register int i;
 
@@ -442,7 +442,7 @@
 }
 
 /* return swapped 32-bit float */
-float st_swapf(float f)
+float sox_swapf(float f)
 {
     union {
         uint32_t dw;
@@ -454,69 +454,69 @@
     return u.f;
 }
 
-uint32_t st_swap24(uint24_t udw)
+uint32_t sox_swap24(uint24_t udw)
 {
     return ((udw >> 16) & 0xff) | (udw & 0xff00) | ((udw << 16) & 0xff0000);
 }
 
-double st_swapd(double df)
+double sox_swapd(double df)
 {
     double sdf;
-    st_swapb((char *)&df, (char *)&sdf, sizeof(double));
+    sox_swapb((char *)&df, (char *)&sdf, sizeof(double));
     return (sdf);
 }
 
 
 /* dummy format routines for do-nothing functions */
-int st_format_nothing(ft_t ft UNUSED) { return(ST_SUCCESS); }
-st_size_t st_format_nothing_read_io(ft_t ft UNUSED, st_sample_t *buf UNUSED, st_size_t len UNUSED) { return(0); }
-st_size_t st_format_nothing_write_io(ft_t ft UNUSED, const st_sample_t *buf UNUSED, st_size_t len UNUSED) { return(0); }
-int st_format_nothing_seek(ft_t ft UNUSED, st_size_t offset UNUSED) { st_fail_errno(ft, ST_ENOTSUP, "operation not supported"); return(ST_EOF); }
+int sox_format_nothing(ft_t ft UNUSED) { return(SOX_SUCCESS); }
+sox_size_t sox_format_nothing_read_io(ft_t ft UNUSED, sox_sample_t *buf UNUSED, sox_size_t len UNUSED) { return(0); }
+sox_size_t sox_format_nothing_write_io(ft_t ft UNUSED, const sox_sample_t *buf UNUSED, sox_size_t len UNUSED) { return(0); }
+int sox_format_nothing_seek(ft_t ft UNUSED, sox_size_t offset UNUSED) { sox_fail_errno(ft, SOX_ENOTSUP, "operation not supported"); return(SOX_EOF); }
 
 /* dummy effect routine for do-nothing functions */
-int st_effect_nothing(eff_t effp UNUSED)
+int sox_effect_nothing(eff_t effp UNUSED)
 {
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-int st_effect_nothing_flow(eff_t effp UNUSED, const st_sample_t *ibuf UNUSED, st_sample_t *obuf UNUSED, st_size_t *isamp, st_size_t *osamp)
+int sox_effect_nothing_flow(eff_t effp UNUSED, const sox_sample_t *ibuf UNUSED, sox_sample_t *obuf UNUSED, sox_size_t *isamp, sox_size_t *osamp)
 {
   /* Pass through samples verbatim */
   *isamp = *osamp = min(*isamp, *osamp);
-  memcpy(obuf, ibuf, *isamp * sizeof(st_sample_t));
-  return ST_SUCCESS;
+  memcpy(obuf, ibuf, *isamp * sizeof(sox_sample_t));
+  return SOX_SUCCESS;
 }
 
-int st_effect_nothing_drain(eff_t effp UNUSED, st_sample_t *obuf UNUSED, st_size_t *osamp)
+int sox_effect_nothing_drain(eff_t effp UNUSED, sox_sample_t *obuf UNUSED, sox_size_t *osamp)
 {
   /* Inform no more samples to drain */
   *osamp = 0;
-  return ST_EOF;
+  return SOX_EOF;
 }
 
-int st_effect_nothing_getopts(eff_t effp, int n, char **argv UNUSED)
+int sox_effect_nothing_getopts(eff_t effp, int n, char **argv UNUSED)
 {
   if (n) {
-    st_fail(effp->h->usage);
-    return (ST_EOF);
+    sox_fail(effp->h->usage);
+    return (SOX_EOF);
   }
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 
 /* here for linear interp.  might be useful for other things */
-st_sample_t st_gcd(st_sample_t a, st_sample_t b)
+sox_sample_t sox_gcd(sox_sample_t a, sox_sample_t b)
 {
   if (b == 0)
     return a;
   else
-    return st_gcd(b, a % b);
+    return sox_gcd(b, a % b);
 }
 
-st_sample_t st_lcm(st_sample_t a, st_sample_t b)
+sox_sample_t sox_lcm(sox_sample_t a, sox_sample_t b)
 {
-  /* parenthesize this way to avoid st_sample_t overflow in product term */
-  return a * (b / st_gcd(a, b));
+  /* parenthesize this way to avoid sox_sample_t overflow in product term */
+  return a * (b / sox_gcd(a, b));
 }
 
 #ifndef HAVE_STRCASECMP
@@ -550,9 +550,9 @@
 
 
 
-void st_generate_wave_table(
-    st_wave_t wave_type,
-    st_data_t data_type,
+void sox_generate_wave_table(
+    sox_wave_t wave_type,
+    sox_data_t data_type,
     void *table,
     uint32_t table_size,
     double min,
@@ -568,11 +568,11 @@
     double d;
     switch (wave_type)
     {
-      case ST_WAVE_SINE:
+      case SOX_WAVE_SINE:
       d = (sin((double)point / table_size * 2 * M_PI) + 1) / 2;
       break;
 
-      case ST_WAVE_TRIANGLE:
+      case SOX_WAVE_TRIANGLE:
       d = (double)point * 2 / table_size;
       switch (4 * point / table_size)
       {
@@ -589,7 +589,7 @@
     d  = d * (max - min) + min;
     switch (data_type)
     {
-      case ST_FLOAT:
+      case SOX_FLOAT:
         {
           float *fp = (float *)table;
           *fp++ = (float)d;
@@ -596,7 +596,7 @@
           table = fp;
           continue;
         }
-      case ST_DOUBLE:
+      case SOX_DOUBLE:
         {
           double *dp = (double *)table;
           *dp++ = d;
@@ -608,7 +608,7 @@
     d += d < 0? -0.5 : +0.5;
     switch (data_type)
     {
-      case ST_SHORT:
+      case SOX_SHORT:
         {
           short *sp = table;
           *sp++ = (short)d;
@@ -615,7 +615,7 @@
           table = sp;
           continue;
         }
-      case ST_INT:
+      case SOX_INT:
         {
           int *ip = table;
           *ip++ = (int)d;
@@ -629,14 +629,14 @@
 
 
 
-const char *st_version(void)
+const char *sox_version(void)
 {
     static char versionstr[20];
 
     sprintf(versionstr, "%d.%d.%d",
-            (ST_LIB_VERSION_CODE & 0xff0000) >> 16,
-            (ST_LIB_VERSION_CODE & 0x00ff00) >> 8,
-            (ST_LIB_VERSION_CODE & 0x0000ff));
+            (SOX_LIB_VERSION_CODE & 0xff0000) >> 16,
+            (SOX_LIB_VERSION_CODE & 0x00ff00) >> 8,
+            (SOX_LIB_VERSION_CODE & 0x0000ff));
     return(versionstr);
 }
 
@@ -646,7 +646,7 @@
  *
  * N.B. Can only seek forwards!
  */
-int st_seeki(ft_t ft, st_size_t offset, int whence)
+int sox_seeki(ft_t ft, sox_size_t offset, int whence)
 {
     if (ft->seekable == 0) {
         /* If a stream peel off chars else EPERM */
@@ -656,23 +656,23 @@
                 offset--;
             }
             if (offset)
-                st_fail_errno(ft,ST_EOF, "offset past EOF");
+                sox_fail_errno(ft,SOX_EOF, "offset past EOF");
             else
-                ft->st_errno = ST_SUCCESS;
+                ft->sox_errno = SOX_SUCCESS;
         } else
-            st_fail_errno(ft,ST_EPERM, "file not seekable");
+            sox_fail_errno(ft,SOX_EPERM, "file not seekable");
     } else {
         if (fseeko(ft->fp, offset, whence) == -1)
-            st_fail_errno(ft,errno,strerror(errno));
+            sox_fail_errno(ft,errno,strerror(errno));
         else
-            ft->st_errno = ST_SUCCESS;
+            ft->sox_errno = SOX_SUCCESS;
     }
 
     /* Empty the st file buffer */
-    if (ft->st_errno == ST_SUCCESS)
+    if (ft->sox_errno == SOX_SUCCESS)
         ft->eof = 0;
 
-    return ft->st_errno;
+    return ft->sox_errno;
 }
 
 enum_item const * find_enum_text(char const * text, enum_item const * enum_items)
@@ -692,8 +692,8 @@
   return result;
 }
 
-enum_item const st_wave_enum[] = {
-  ENUM_ITEM(ST_WAVE_,SINE)
-  ENUM_ITEM(ST_WAVE_,TRIANGLE)
+enum_item const sox_wave_enum[] = {
+  ENUM_ITEM(SOX_WAVE_,SINE)
+  ENUM_ITEM(SOX_WAVE_,TRIANGLE)
   {0, 0}};
 
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -15,12 +15,12 @@
  * and mono/stereo -> stereo/quad channel duplication.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
 
-static st_effect_t st_mixer_effect;
+static sox_effect_t sox_mixer_effect;
 
 typedef struct mixerstuff {
         /* How to generate each output channel.  sources[i][j] */
@@ -82,8 +82,8 @@
             mixer->mix = MIX_RIGHT_BACK;
         else if (argv[0][0] == '-' && !isdigit((int)argv[0][1])
                 && argv[0][1] != '.') {
-            st_fail(st_mixer_effect.usage);
-            return (ST_EOF);
+            sox_fail(sox_mixer_effect.usage);
+            return (SOX_EOF);
         }
         else {
             int commas;
@@ -94,8 +94,8 @@
                 if (*s == ',') {
                     ++commas;
                     if (commas >= 16) {
-                        st_fail("mixer can only take up to 16 pan values");
-                        return (ST_EOF);
+                        sox_fail("mixer can only take up to 16 pan values");
+                        return (SOX_EOF);
                     }
                     pans[commas] = atof(s+1);
                 }
@@ -107,11 +107,11 @@
         mixer->mix = MIX_CENTER;
     }
     else {
-        st_fail(st_mixer_effect.usage);
-        return ST_EOF;
+        sox_fail(sox_mixer_effect.usage);
+        return SOX_EOF;
     }
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /*
@@ -192,15 +192,15 @@
      ichan = effp->ininfo.channels;
      ochan = effp->outinfo.channels;
      if (ochan == -1) {
-         st_fail("Output must have known number of channels to use mixer effect");
-         return(ST_EOF);
+         sox_fail("Output must have known number of channels to use mixer effect");
+         return(SOX_EOF);
      }
 
      if ((ichan != 1 && ichan != 2 && ichan != 4)
              ||  (ochan != 1 && ochan != 2 && ochan != 4)) {
-         st_fail("Can't average %d channels into %d channels",
+         sox_fail("Can't average %d channels into %d channels",
                  ichan, ochan);
-         return (ST_EOF);
+         return (SOX_EOF);
      }
 
      /* Handle the special-case flags */
@@ -207,7 +207,7 @@
      switch (mixer->mix) {
          case MIX_CENTER:
              if (ichan == ochan)
-               return ST_EFF_NULL;
+               return SOX_EFF_NULL;
              break;             /* Code below will handle this case */
          case MIX_LEFT:
              if (ichan == 2 && ochan == 1)
@@ -226,9 +226,9 @@
              }
              else
              {
-                 st_fail("Can't average %d channels into %d channels",
+                 sox_fail("Can't average %d channels into %d channels",
                          ichan, ochan);
-                 return ST_EOF;
+                 return SOX_EOF;
              }
              break;
          case MIX_RIGHT:
@@ -248,9 +248,9 @@
              }
              else
              {
-                 st_fail("Can't average %d channels into %d channels",
+                 sox_fail("Can't average %d channels into %d channels",
                          ichan, ochan);
-                 return ST_EOF;
+                 return SOX_EOF;
              }
              break;
          case MIX_FRONT:
@@ -262,8 +262,8 @@
              }
              else
              {
-                 st_fail("-f option requires 4 channels input and 2 channel output");
-                 return ST_EOF;
+                 sox_fail("-f option requires 4 channels input and 2 channel output");
+                 return SOX_EOF;
              }
              break;
          case MIX_BACK:
@@ -275,8 +275,8 @@
              }
              else
              {
-                 st_fail("-b option requires 4 channels input and 2 channel output");
-                 return ST_EOF;
+                 sox_fail("-b option requires 4 channels input and 2 channel output");
+                 return SOX_EOF;
              }
              break;
          case MIX_LEFT_FRONT:
@@ -296,8 +296,8 @@
              }
              else
              {
-                 st_fail("-1 option requires 4 channels input and 1 channel output");
-                 return ST_EOF;
+                 sox_fail("-1 option requires 4 channels input and 1 channel output");
+                 return SOX_EOF;
              }
              break;
          case MIX_RIGHT_FRONT:
@@ -317,8 +317,8 @@
              }
              else
              {
-                 st_fail("-2 option requires 4 channels input and 1 channel output");
-                 return ST_EOF;
+                 sox_fail("-2 option requires 4 channels input and 1 channel output");
+                 return SOX_EOF;
              }
              break;
          case MIX_LEFT_BACK:
@@ -332,8 +332,8 @@
              }
              else
              {
-                 st_fail("-3 option requires 4 channels input and 1 channel output");
-                 return ST_EOF;
+                 sox_fail("-3 option requires 4 channels input and 1 channel output");
+                 return SOX_EOF;
              }
          case MIX_RIGHT_BACK:
              if (ichan == 4 && ochan == 1)
@@ -346,15 +346,15 @@
              }
              else
              {
-                 st_fail("-4 option requires 4 channels input and 1 channel output");
-                 return ST_EOF;
+                 sox_fail("-4 option requires 4 channels input and 1 channel output");
+                 return SOX_EOF;
              }
 
          case MIX_SPECIFIED:
              break;
          default:
-             st_fail("Unknown mix option in average effect");
-             return ST_EOF;
+             sox_fail("Unknown mix option in average effect");
+             return SOX_EOF;
      }
 
      /* If number of pans is 4 or less then its a shorthand
@@ -411,8 +411,8 @@
              mixer->sources[3][1] = 0.5;
          }
          else {
-             st_fail("You must specify at least one mix level when using mixer with an unusual number of channels.");
-             return(ST_EOF);
+             sox_fail("You must specify at least one mix level when using mixer with an unusual number of channels.");
+             return(SOX_EOF);
          }
      }
      else if (mixer->num_pans == 1) {
@@ -439,8 +439,8 @@
          }
          else
          {
-             st_fail("Invalid options specified to mixer while not mixing");
-             return ST_EOF;
+             sox_fail("Invalid options specified to mixer while not mixing");
+             return SOX_EOF;
          }
      }
      else if (mixer->num_pans == 2) {
@@ -466,8 +466,8 @@
          }
          else
          {
-             st_fail("Invalid options specified to mixer for this channel combination");
-             return ST_EOF;
+             sox_fail("Invalid options specified to mixer for this channel combination");
+             return SOX_EOF;
          }
      }
      else if (mixer->num_pans == 4) {
@@ -488,28 +488,28 @@
          }
          else
          {
-             st_fail("Invalid options specified to mixer for this channel combination");
-             return ST_EOF;
+             sox_fail("Invalid options specified to mixer for this channel combination");
+             return SOX_EOF;
          }
      }
      else
      {
-         st_fail("Invalid options specified to mixer while not mixing");
-         return ST_EOF;
+         sox_fail("Invalid options specified to mixer while not mixing");
+         return SOX_EOF;
      }
 
 #if 0  /* TODO: test the following: */
      if (effp->ininfo.channels != effp->outinfo.channels)
-       return ST_SUCCESS;
+       return SOX_SUCCESS;
 
      for (i = 0; i < (int)effp->ininfo.channels; ++i)
        for (j = 0; j < (int)effp->outinfo.channels; ++j)
          if (avg->sources[i][j] != (i == j))
-           return ST_SUCCESS;
+           return SOX_SUCCESS;
 
-     return ST_EFF_NULL;
+     return SOX_EFF_NULL;
 #else
-     return ST_SUCCESS;
+     return SOX_SUCCESS;
 #endif
 }
 
@@ -517,11 +517,11 @@
  * Process either isamp or osamp samples, whichever is smaller.
  */
 
-static int flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                st_size_t *isamp, st_size_t *osamp)
+static int flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                sox_size_t *isamp, sox_size_t *osamp)
 {
     mixer_t mixer = (mixer_t) effp->priv;
-    st_size_t len, done;
+    sox_size_t len, done;
     int ichan, ochan;
     int i, j;
     double samp;
@@ -536,43 +536,43 @@
             samp = 0.0;
             for (i = 0; i < ichan; i++)
                 samp += ibuf[i] * mixer->sources[i][j];
-            ST_SAMPLE_CLIP_COUNT(samp, effp->clips);
+            SOX_SAMPLE_CLIP_COUNT(samp, effp->clips);
             obuf[j] = samp;
         }
     }
     *isamp = len * ichan;
     *osamp = len * ochan;
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-st_effect_t const * st_mixer_effect_fn(void)
+sox_effect_t const * sox_mixer_effect_fn(void)
 {
-  static st_effect_t driver = {
+  static sox_effect_t driver = {
     "mixer",
     "Usage: mixer [ -l | -r | -f | -b | -1 | -2 | -3 | -4 | n,n,n...,n ]",
-    ST_EFF_MCHAN | ST_EFF_CHAN,
+    SOX_EFF_MCHAN | SOX_EFF_CHAN,
     getopts, start, flow, 0, 0, 0
   };
   return &driver;
 }
 
-st_effect_t const * st_avg_effect_fn(void)
+sox_effect_t const * sox_avg_effect_fn(void)
 {
-  static st_effect_t driver = {
+  static sox_effect_t driver = {
     "avg",
     "Usage: avg [ -l | -r | -f | -b | -1 | -2 | -3 | -4 | n,n,n...,n ]",
-    ST_EFF_MCHAN | ST_EFF_CHAN | ST_EFF_DEPRECATED,
+    SOX_EFF_MCHAN | SOX_EFF_CHAN | SOX_EFF_DEPRECATED,
     getopts, start, flow, 0, 0, 0
   };
   return &driver;
 }
 
-st_effect_t const * st_pick_effect_fn(void)
+sox_effect_t const * sox_pick_effect_fn(void)
 {
-  static st_effect_t driver = {
+  static sox_effect_t driver = {
     "pick",
     "Usage: pick [ -l | -r | -f | -b | -1 | -2 | -3 | -4 | n,n,n...,n ]",
-    ST_EFF_MCHAN | ST_EFF_CHAN | ST_EFF_DEPRECATED,
+    SOX_EFF_MCHAN | SOX_EFF_CHAN | SOX_EFF_DEPRECATED,
     getopts, start, flow, 0, 0, 0
   };
   return &driver;
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -10,7 +10,7 @@
  * written by Bertrand Petit <madlld@phoe.fmug.org>,
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <string.h>
 
@@ -25,7 +25,7 @@
 #include <math.h>
 #endif
 
-#define INPUT_BUFFER_SIZE       (ST_BUFSIZ)
+#define INPUT_BUFFER_SIZE       (SOX_BUFSIZ)
 
 /* Private data */
 struct mp3priv {
@@ -35,8 +35,8 @@
         struct mad_synth        *Synth;
         mad_timer_t             *Timer;
         unsigned char           *InputBuffer;
-        st_ssize_t              cursamp;
-        st_size_t               FrameCount;
+        sox_ssize_t              cursamp;
+        sox_size_t               FrameCount;
 #endif /*HAVE_LIBMAD*/
 #ifdef HAVE_LIBMP3LAME
         lame_global_flags       *gfp;
@@ -87,7 +87,7 @@
  * still exists in the buffer then they are first shifted to be
  * front of the stream buffer.
  */
-static int st_mp3_input(ft_t ft)
+static int sox_mp3_input(ft_t ft)
 {
     struct mp3priv *p = (struct mp3priv *) ft->priv;
     size_t bytes_read;
@@ -107,27 +107,27 @@
      */
     memmove(p->InputBuffer, p->Stream->next_frame, remaining);
 
-    bytes_read = st_readbuf(ft, p->InputBuffer+remaining, 1, 
+    bytes_read = sox_readbuf(ft, p->InputBuffer+remaining, 1, 
                             INPUT_BUFFER_SIZE-remaining);
     if (bytes_read == 0)
     {
-        return ST_EOF;
+        return SOX_EOF;
     }
 
     mad_stream_buffer(p->Stream, p->InputBuffer, bytes_read+remaining);
     p->Stream->error = 0;
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /* Attempts to read an ID3 tag at the current location in stream and
- * consume it all.  Returns ST_EOF if no tag is found.  Its up to
+ * consume it all.  Returns SOX_EOF if no tag is found.  Its up to
  * caller to recover.
  * */
-static int st_mp3_inputtag(ft_t ft)
+static int sox_mp3_inputtag(ft_t ft)
 {
     struct mp3priv *p = (struct mp3priv *) ft->priv;
-    int rc = ST_EOF;
+    int rc = SOX_EOF;
     size_t remaining;
     size_t tagsize;
 
@@ -147,7 +147,7 @@
     if ((tagsize = tagtype(p->Stream->this_frame, remaining)))
     {
         mad_stream_skip(p->Stream, tagsize);
-        rc = ST_SUCCESS;
+        rc = SOX_SUCCESS;
     }
 
     /* We know that a valid frame hasn't been found yet
@@ -159,7 +159,7 @@
     return rc;
 }
 
-static int st_mp3startread(ft_t ft) 
+static int sox_mp3startread(ft_t ft) 
 {
     struct mp3priv *p = (struct mp3priv *) ft->priv;
     size_t ReadSize;
@@ -181,21 +181,21 @@
     mad_synth_init(p->Synth);
     mad_timer_reset(p->Timer);
 
-    ft->signal.encoding = ST_ENCODING_MP3;
-    ft->signal.size = ST_SIZE_16BIT;
+    ft->signal.encoding = SOX_ENCODING_MP3;
+    ft->signal.size = SOX_SIZE_16BIT;
 
     /* Decode at least one valid frame to find out the input
      * format.  The decoded frame will be saved off so that it
      * can be processed later.
      */
-    ReadSize=st_readbuf(ft, p->InputBuffer, 1, INPUT_BUFFER_SIZE);
+    ReadSize=sox_readbuf(ft, p->InputBuffer, 1, INPUT_BUFFER_SIZE);
     if(ReadSize<=0)
     {
-        if(st_error(ft))
-            st_fail_errno(ft,ST_EOF,"read error on bitstream");
-        if(st_eof(ft))
-            st_fail_errno(ft,ST_EOF,"end of input stream");
-        return(ST_EOF);
+        if(sox_error(ft))
+            sox_fail_errno(ft,SOX_EOF,"read error on bitstream");
+        if(sox_eof(ft))
+            sox_fail_errno(ft,SOX_EOF,"end of input stream");
+        return(SOX_EOF);
     }
 
     mad_stream_buffer(p->Stream, p->InputBuffer, ReadSize);
@@ -210,14 +210,14 @@
         /* check whether input buffer needs a refill */
         if (p->Stream->error == MAD_ERROR_BUFLEN)
         {
-            if (st_mp3_input(ft) == ST_EOF)
-                return ST_EOF;
+            if (sox_mp3_input(ft) == SOX_EOF)
+                return SOX_EOF;
 
             continue;
         }
 
         /* Consume any ID3 tags */
-        st_mp3_inputtag(ft);
+        sox_mp3_inputtag(ft);
 
         /* FIXME: We should probably detect when we've read
          * a bunch of non-ID3 data and still haven't found a
@@ -229,8 +229,8 @@
 
     if (p->Stream->error)
     {
-        st_fail_errno(ft,ST_EOF,"No valid MP3 frame found");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"No valid MP3 frame found");
+        return SOX_EOF;
     }
 
     switch(p->Frame->header.mode)
@@ -242,8 +242,8 @@
             ft->signal.channels = MAD_NCHANNELS(&p->Frame->header);
             break;
         default:
-            st_fail_errno(ft, ST_EFMT, "Cannot determine number of channels");
-            return ST_EOF;
+            sox_fail_errno(ft, SOX_EFMT, "Cannot determine number of channels");
+            return SOX_EOF;
     }
 
     p->FrameCount=1;
@@ -254,7 +254,7 @@
 
     p->cursamp = 0;
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
@@ -263,10 +263,10 @@
  * Place in buf[].
  * Return number of samples read.
  */
-static st_size_t st_mp3read(ft_t ft, st_sample_t *buf, st_size_t len)
+static sox_size_t sox_mp3read(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
     struct mp3priv *p = (struct mp3priv *) ft->priv;
-    st_size_t donow,i,done=0;
+    sox_size_t donow,i,done=0;
     mad_fixed_t sample;
     size_t chan;
 
@@ -280,7 +280,7 @@
                     sample=-MAD_F_ONE;
                 else if (sample >= MAD_F_ONE)
                     sample=MAD_F_ONE-1;
-                *buf++=(st_sample_t)(sample<<(32-1-MAD_F_FRACBITS));
+                *buf++=(sox_sample_t)(sample<<(32-1-MAD_F_FRACBITS));
                 i++;
             }
             p->cursamp++;
@@ -294,7 +294,7 @@
         /* check whether input buffer needs a refill */
         if (p->Stream->error == MAD_ERROR_BUFLEN)
         {
-            if (st_mp3_input(ft) == ST_EOF)
+            if (sox_mp3_input(ft) == SOX_EOF)
                 return 0;
         }
 
@@ -302,7 +302,7 @@
         {
             if(MAD_RECOVERABLE(p->Stream->error))
             {
-                st_mp3_inputtag(ft);
+                sox_mp3_inputtag(ft);
                 continue;
             }
             else
@@ -311,7 +311,7 @@
                     continue;
                 else
                 {
-                    st_report("unrecoverable frame level error (%s).",
+                    sox_report("unrecoverable frame level error (%s).",
                               mad_stream_errorstr(p->Stream));
                     return done;
                 }
@@ -326,7 +326,7 @@
     return done;
 }
 
-static int st_mp3stopread(ft_t ft)
+static int sox_mp3stopread(ft_t ft)
 {
   struct mp3priv *p=(struct mp3priv*) ft->priv;
 
@@ -340,25 +340,25 @@
   free(p->Timer);
   free(p->InputBuffer);
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 #else /*HAVE_LIBMAD*/
-static int st_mp3startread(ft_t ft)
+static int sox_mp3startread(ft_t ft)
 {
-  st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 decoding support");
-  return ST_EOF;
+  sox_fail_errno(ft,SOX_EOF,"SoX was compiled without MP3 decoding support");
+  return SOX_EOF;
 }
 
-st_ssize_t st_mp3read(ft_t ft, st_sample_t *buf, st_size_t samp)
+sox_ssize_t sox_mp3read(ft_t ft, sox_sample_t *buf, sox_size_t samp)
 {
-  st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 decoding support");
-  return ST_EOF;
+  sox_fail_errno(ft,SOX_EOF,"SoX was compiled without MP3 decoding support");
+  return SOX_EOF;
 }
 
-int st_mp3stopread(ft_t ft)
+int sox_mp3stopread(ft_t ft)
 {
-  st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 decoding support");
-  return ST_EOF;
+  sox_fail_errno(ft,SOX_EOF,"SoX was compiled without MP3 decoding support");
+  return SOX_EOF;
 }
 #endif /*HAVE_LIBMAD*/
 
@@ -368,26 +368,26 @@
   return;
 }
 
-static int st_mp3startwrite(ft_t ft)
+static int sox_mp3startwrite(ft_t ft)
 {
   struct mp3priv *p = (struct mp3priv *) ft->priv;
   
-  if (ft->signal.encoding != ST_ENCODING_MP3) {
-    if(ft->signal.encoding != ST_ENCODING_UNKNOWN)
-      st_report("Encoding forced to MP3");
-    ft->signal.encoding = ST_ENCODING_MP3;
+  if (ft->signal.encoding != SOX_ENCODING_MP3) {
+    if(ft->signal.encoding != SOX_ENCODING_UNKNOWN)
+      sox_report("Encoding forced to MP3");
+    ft->signal.encoding = SOX_ENCODING_MP3;
   }
 
   p->gfp = lame_init();
   if (p->gfp == NULL){
-    st_fail_errno(ft,ST_EOF,"Initialization of LAME library failed");
-    return(ST_EOF);
+    sox_fail_errno(ft,SOX_EOF,"Initialization of LAME library failed");
+    return(SOX_EOF);
   }
 
-  if (ft->signal.channels != ST_ENCODING_UNKNOWN) {
+  if (ft->signal.channels != SOX_ENCODING_UNKNOWN) {
     if ( (lame_set_num_channels(p->gfp,ft->signal.channels)) < 0) {
-        st_fail_errno(ft,ST_EOF,"Unsupported number of channels");
-        return(ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"Unsupported number of channels");
+        return(SOX_EOF);
     }
   }
   else
@@ -404,28 +404,28 @@
      here.  E.g. by using the -C value as an index into a table of params or
      as a compressed bit-rate. */
   if (ft->signal.compression != HUGE_VAL)
-      st_warn("-C option not supported for mp3; using default compression rate");
+      sox_warn("-C option not supported for mp3; using default compression rate");
   if (lame_init_params(p->gfp) < 0){
-        st_fail_errno(ft,ST_EOF,"LAME initialization failed");
-        return(ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"LAME initialization failed");
+        return(SOX_EOF);
   }
   lame_set_errorf(p->gfp,null_error_func);
   lame_set_debugf(p->gfp,null_error_func);
   lame_set_msgf  (p->gfp,null_error_func);
 
-  return(ST_SUCCESS);
+  return(SOX_SUCCESS);
 }
 
-static st_size_t st_mp3write(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static sox_size_t sox_mp3write(ft_t ft, const sox_sample_t *buf, sox_size_t samp)
 {
     struct mp3priv *p = (struct mp3priv *)ft->priv;
     char *mp3buffer;
-    st_size_t mp3buffer_size;
+    sox_size_t mp3buffer_size;
     short signed int *buffer_l, *buffer_r = NULL;
     int nsamples = samp/ft->signal.channels;
     int i,j;
-    st_ssize_t done = 0;
-    st_size_t written;
+    sox_ssize_t done = 0;
+    sox_size_t written;
 
     /* NOTE: This logic assumes that "short int" is 16-bits
      * on all platforms.  It happens to be for all that I know
@@ -454,7 +454,7 @@
              (short signed int *)xmalloc(nsamples*
                                           sizeof(short signed int))) == NULL)
         {
-            st_fail_errno(ft,ST_ENOMEM,"Memory allocation failed");
+            sox_fail_errno(ft,SOX_ENOMEM,"Memory allocation failed");
             goto end3;
         }
 
@@ -461,8 +461,8 @@
         j=0;
         for (i=0; i<nsamples; i++)
         {
-            buffer_l[i]=ST_SAMPLE_TO_SIGNED_WORD(buf[j++], ft->clips);
-            buffer_r[i]=ST_SAMPLE_TO_SIGNED_WORD(buf[j++], ft->clips);
+            buffer_l[i]=SOX_SAMPLE_TO_SIGNED_WORD(buf[j++], ft->clips);
+            buffer_r[i]=SOX_SAMPLE_TO_SIGNED_WORD(buf[j++], ft->clips);
         }
     }
     else
@@ -470,7 +470,7 @@
         j=0;
         for (i=0; i<nsamples; i++)
         {
-            buffer_l[i]=ST_SAMPLE_TO_SIGNED_WORD(buf[j++], ft->clips); 
+            buffer_l[i]=SOX_SAMPLE_TO_SIGNED_WORD(buf[j++], ft->clips); 
         }
     }
 
@@ -477,7 +477,7 @@
     mp3buffer_size = 1.25 * nsamples + 7200;
     if ((mp3buffer=(char *)xmalloc(mp3buffer_size)) == NULL)
     {
-        st_fail_errno(ft,ST_ENOMEM,"Memory allocation failed");
+        sox_fail_errno(ft,SOX_ENOMEM,"Memory allocation failed");
         goto end2;
     }
 
@@ -484,13 +484,13 @@
     if ((written = lame_encode_buffer(p->gfp,buffer_l, buffer_r,
                                       nsamples, (unsigned char *)mp3buffer,
                                       mp3buffer_size)) > mp3buffer_size){
-        st_fail_errno(ft,ST_EOF,"Encoding failed");
+        sox_fail_errno(ft,SOX_EOF,"Encoding failed");
         goto end;
     }
 
-    if (st_writebuf(ft, mp3buffer, 1, written) < written)
+    if (sox_writebuf(ft, mp3buffer, 1, written) < written)
     {
-        st_fail_errno(ft,ST_EOF,"File write failed");
+        sox_fail_errno(ft,SOX_EOF,"File write failed");
         goto end;
     }
 
@@ -507,7 +507,7 @@
     return done;
 }
 
-static int st_mp3stopwrite(ft_t ft)
+static int sox_mp3stopwrite(ft_t ft)
 {
   struct mp3priv *p = (struct mp3priv *) ft->priv;
   char mp3buffer[7200];
@@ -514,33 +514,33 @@
   int written;
   
   if ( (written=lame_encode_flush(p->gfp, (unsigned char *)mp3buffer, 7200)) <0){
-    st_fail_errno(ft,ST_EOF,"Encoding failed");
+    sox_fail_errno(ft,SOX_EOF,"Encoding failed");
   }
-  else if ((int)st_writebuf(ft, mp3buffer, 1, written) < written){
-    st_fail_errno(ft,ST_EOF,"File write failed");
+  else if ((int)sox_writebuf(ft, mp3buffer, 1, written) < written){
+    sox_fail_errno(ft,SOX_EOF,"File write failed");
   }
 
   lame_close(p->gfp);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 #else /* HAVE_LIBMP3LAME */
-static int st_mp3startwrite(ft_t ft UNUSED)
+static int sox_mp3startwrite(ft_t ft UNUSED)
 {
-  st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support");
-  return ST_EOF;
+  sox_fail_errno(ft,SOX_EOF,"SoX was compiled without MP3 encoding support");
+  return SOX_EOF;
 }
 
-static st_size_t st_mp3write(ft_t ft UNUSED, const st_sample_t *buf UNUSED, st_size_t samp UNUSED)
+static sox_size_t sox_mp3write(ft_t ft UNUSED, const sox_sample_t *buf UNUSED, sox_size_t samp UNUSED)
 {
-  st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support");
+  sox_fail_errno(ft,SOX_EOF,"SoX was compiled without MP3 encoding support");
   return 0;
 }
 
-static int st_mp3stopwrite(ft_t ft)
+static int sox_mp3stopwrite(ft_t ft)
 {
-  st_fail_errno(ft,ST_EOF,"SoX was compiled without MP3 encoding support");
-  return ST_EOF;
+  sox_fail_errno(ft,SOX_EOF,"SoX was compiled without MP3 encoding support");
+  return SOX_EOF;
 }
 #endif /* HAVE_LIBMP3LAME */
 
@@ -551,21 +551,21 @@
   NULL,
 };
 
-static st_format_t st_mp3_format = {
+static sox_format_t sox_mp3_format = {
   mp3names,
   NULL,
   0,
-  st_mp3startread,
-  st_mp3read,
-  st_mp3stopread,
-  st_mp3startwrite,
-  st_mp3write,
-  st_mp3stopwrite,
-  st_format_nothing_seek
+  sox_mp3startread,
+  sox_mp3read,
+  sox_mp3stopread,
+  sox_mp3startwrite,
+  sox_mp3write,
+  sox_mp3stopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_mp3_format_fn(void)
+const sox_format_t *sox_mp3_format_fn(void)
 {
-    return &st_mp3_format;
+    return &sox_mp3_format;
 }
 #endif
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -19,7 +19,7 @@
 #include <string.h>
 #include <errno.h>
 
-static st_effect_t st_noiseprof_effect;
+static sox_effect_t sox_noiseprof_effect;
 
 typedef struct chandata {
     float *sum;
@@ -33,13 +33,13 @@
     FILE* output_file;
 
     chandata_t *chandata;
-    st_size_t bufdata;
+    sox_size_t bufdata;
 } * profdata_t;
 
 /*
- * Get the filename, if any. We don't open it until st_noiseprof_start.
+ * Get the filename, if any. We don't open it until sox_noiseprof_start.
  */
-static int st_noiseprof_getopts(eff_t effp, int n, char **argv) 
+static int sox_noiseprof_getopts(eff_t effp, int n, char **argv) 
 {
     profdata_t data = (profdata_t) effp->priv;
 
@@ -46,11 +46,11 @@
     if (n == 1) {
         data->output_filename = argv[0];
     } else if (n > 1) {
-        st_fail(st_noiseprof_effect.usage);
-        return (ST_EOF);
+        sox_fail(sox_noiseprof_effect.usage);
+        return (SOX_EOF);
     }
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /*
@@ -57,7 +57,7 @@
  * Prepare processing.
  * Do all initializations.
  */
-static int st_noiseprof_start(eff_t effp)
+static int sox_noiseprof_start(eff_t effp)
 {
     profdata_t data = (profdata_t) effp->priv;
     int channels = effp->ininfo.channels;
@@ -69,7 +69,7 @@
         else
           data->output_file = stdout;
         if (data->output_file == NULL) {
-            st_fail("Couldn't open output file %s: %s",
+            sox_fail("Couldn't open output file %s: %s",
                     data->output_filename, strerror(errno));            
         }
     } else {
@@ -85,7 +85,7 @@
         data->chandata[i].window = (float*)xcalloc(WINDOWSIZE, sizeof(float));
     }
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /* Collect statistics from the complete window on channel chan. */
@@ -109,13 +109,13 @@
 /*
  * Grab what we can from ibuf, and process if we have a whole window.
  */
-static int st_noiseprof_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                    st_size_t *isamp, st_size_t *osamp)
+static int sox_noiseprof_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                    sox_size_t *isamp, sox_size_t *osamp)
 {
     profdata_t data = (profdata_t) effp->priv;
     int samp = min(*isamp, *osamp);
     int tracks = effp->ininfo.channels;
-    st_size_t track_samples = samp / tracks;
+    sox_size_t track_samples = samp / tracks;
     int ncopy = 0;
     int i;
 
@@ -130,7 +130,7 @@
         int j;
         for (j = 0; j < ncopy; j ++) {
             chan->window[j+data->bufdata] =
-                ST_SAMPLE_TO_FLOAT_DWORD(ibuf[i+j*tracks], effp->clips);
+                SOX_SAMPLE_TO_FLOAT_DWORD(ibuf[i+j*tracks], effp->clips);
         }
         if (ncopy + data->bufdata == WINDOWSIZE)
             collect_data(chan);
@@ -144,7 +144,7 @@
     memcpy(obuf, ibuf, ncopy*tracks);
     *isamp = *osamp = ncopy*tracks;
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /*
@@ -151,7 +151,7 @@
  * Finish off the last window.
  */
 
-static int st_noiseprof_drain(eff_t effp, st_sample_t *obuf UNUSED, st_size_t *osamp)
+static int sox_noiseprof_drain(eff_t effp, sox_sample_t *obuf UNUSED, sox_size_t *osamp)
 {
     profdata_t data = (profdata_t) effp->priv;
     int tracks = effp->ininfo.channels;
@@ -160,7 +160,7 @@
     *osamp = 0;
 
     if (data->bufdata == 0) {
-        return ST_EOF;
+        return SOX_EOF;
     }
 
     for (i = 0; i < tracks; i ++) {
@@ -172,18 +172,18 @@
     }
 
     if (data->bufdata == WINDOWSIZE || data->bufdata == 0)
-        return ST_EOF;
+        return SOX_EOF;
     else
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
 }
 
 /*
  * Print profile and clean up.
  */
-static int st_noiseprof_stop(eff_t effp)
+static int sox_noiseprof_stop(eff_t effp)
 {
     profdata_t data = (profdata_t) effp->priv;
-    st_size_t i;
+    sox_size_t i;
 
     for (i = 0; i < effp->ininfo.channels; i ++) {
         int j;
@@ -206,22 +206,22 @@
     if (data->output_file != stderr && data->output_file != stdout)
         fclose(data->output_file);
     
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-static st_effect_t st_noiseprof_effect = {
+static sox_effect_t sox_noiseprof_effect = {
   "noiseprof",
   "Usage: noiseprof [filename]",
-  ST_EFF_MCHAN | ST_EFF_REPORT,
-  st_noiseprof_getopts,
-  st_noiseprof_start,
-  st_noiseprof_flow,
-  st_noiseprof_drain,
-  st_noiseprof_stop,
-  st_effect_nothing
+  SOX_EFF_MCHAN | SOX_EFF_REPORT,
+  sox_noiseprof_getopts,
+  sox_noiseprof_start,
+  sox_noiseprof_flow,
+  sox_noiseprof_drain,
+  sox_noiseprof_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_noiseprof_effect_fn(void)
+const sox_effect_t *sox_noiseprof_effect_fn(void)
 {
-    return &st_noiseprof_effect;
+    return &sox_noiseprof_effect;
 }
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -16,7 +16,7 @@
 #include <string.h>
 #include <assert.h>
 
-static st_effect_t st_noisered_effect;
+static sox_effect_t sox_noisered_effect;
 
 typedef struct chandata {
     float *window;
@@ -31,7 +31,7 @@
     float threshold;
 
     chandata_t *chandata;
-    st_size_t bufdata;
+    sox_size_t bufdata;
 } * reddata_t;
 
 /*
@@ -38,13 +38,13 @@
  * Get the options. Filename is mandatory, though a reasonable default would
  * be stdin (if the input file isn't coming from there, of course!)
  */
-static int st_noisered_getopts(eff_t effp, int n, char **argv) 
+static int sox_noisered_getopts(eff_t effp, int n, char **argv) 
 {
     reddata_t data = (reddata_t) effp->priv;
 
     if (n > 2 || n < 1) {
-            st_fail(st_noisered_effect.usage);
-            return (ST_EOF);
+            sox_fail(sox_noisered_effect.usage);
+            return (SOX_EOF);
     }
     data->threshold = 0.5;
     data->profile_filename = argv[0];
@@ -60,7 +60,7 @@
             data->threshold = 0;
         }
     }
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /*
@@ -67,7 +67,7 @@
  * Prepare processing.
  * Do all initializations.
  */
-static int st_noisered_start(eff_t effp)
+static int sox_noisered_start(eff_t effp)
 {
     reddata_t data = (reddata_t) effp->priv;
     int fchannels = 0;
@@ -89,9 +89,9 @@
     else
       ifp = fopen(data->profile_filename, "r");
     if (ifp == NULL) {
-        st_fail("Couldn't open profile file %s: %s",
+        sox_fail("Couldn't open profile file %s: %s",
                 data->profile_filename, strerror(errno));            
-        return ST_EOF;
+        return SOX_EOF;
     }
 
     while (1) {
@@ -100,17 +100,17 @@
         if (2 != fscanf(ifp, " Channel %d: %f", &i1, &f1))
             break;
         if (i1 != fchannels) {
-            st_fail("noisered: Got channel %d, expected channel %d.",
-                    i1, fchannels);
-            return ST_EOF;
+            sox_fail("noisered: Got channel %d, expected channel %d.",
+                    i1, fchannels);
+            return SOX_EOF;
         }
 
         data->chandata[fchannels].noisegate[0] = f1;
         for (i = 1; i < FREQCOUNT; i ++) {
             if (1 != fscanf(ifp, ", %f", &f1)) {
-                st_fail("noisered: Not enough datums for channel %d "
+                sox_fail("noisered: Not enough datums for channel %d "
                         "(expected %d, got %d)", fchannels, FREQCOUNT, i);
-                return ST_EOF;
+                return SOX_EOF;
             }
             data->chandata[fchannels].noisegate[i] = f1;
         }
@@ -117,14 +117,14 @@
         fchannels ++;
     }
     if (fchannels != channels) {
-        st_fail("noisered: channel mismatch: %d in input, %d in profile.",
+        sox_fail("noisered: channel mismatch: %d in input, %d in profile.",
                 channels, fchannels);
-        return ST_EOF;
+        return SOX_EOF;
     }
     if (strcmp(data->profile_filename, "-") != 0)
       fclose(ifp);
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /* Mangle a single window. Each output sample (except the first and last
@@ -206,7 +206,7 @@
 /* Do window management once we have a complete window, including mangling
  * the current window. */
 static int process_window(eff_t effp, reddata_t data, int chan_num, int num_chans,
-                          st_sample_t *obuf, int len) {
+                          sox_sample_t *obuf, int len) {
     int j;
     float* nextwindow;
     int use = min(len, WINDOWSIZE)-min(len,(WINDOWSIZE/2));
@@ -214,7 +214,7 @@
     int first = (chan->lastwindow == NULL);
 
     if ((nextwindow = (float*)xcalloc(WINDOWSIZE, sizeof(float))) == NULL)
-        return ST_EOF;
+        return SOX_EOF;
     
     memcpy(nextwindow, chan->window+WINDOWSIZE/2,
            sizeof(float)*(WINDOWSIZE/2));
@@ -224,7 +224,7 @@
         for (j = 0; j < use; j ++) {
             float s = chan->window[j] + chan->lastwindow[WINDOWSIZE/2 + j];
             obuf[chan_num + num_chans * j] =
-                ST_FLOAT_DWORD_TO_SAMPLE(s, effp->clips);
+                SOX_FLOAT_DWORD_TO_SAMPLE(s, effp->clips);
         }
         free(chan->lastwindow);
     } else {
@@ -231,7 +231,7 @@
         for (j = 0; j < use; j ++) {
             assert(chan->window[j] >= -1 && chan->window[j] <= 1);
             obuf[chan_num + num_chans * j] =
-                ST_FLOAT_DWORD_TO_SAMPLE(chan->window[j], effp->clips);
+                SOX_FLOAT_DWORD_TO_SAMPLE(chan->window[j], effp->clips);
         }
     }
     chan->lastwindow = chan->window;
@@ -243,17 +243,17 @@
 /*
  * Read in windows, and call process_window once we get a whole one.
  */
-static int st_noisered_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                    st_size_t *isamp, st_size_t *osamp)
+static int sox_noisered_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                    sox_size_t *isamp, sox_size_t *osamp)
 {
     reddata_t data = (reddata_t) effp->priv;
-    st_size_t samp = min(*isamp, *osamp);
-    st_size_t tracks = effp->ininfo.channels;
-    st_size_t track_samples = samp / tracks;
-    st_size_t ncopy = min(track_samples, WINDOWSIZE-data->bufdata);
-    st_size_t whole_window = (ncopy + data->bufdata == WINDOWSIZE);
+    sox_size_t samp = min(*isamp, *osamp);
+    sox_size_t tracks = effp->ininfo.channels;
+    sox_size_t track_samples = samp / tracks;
+    sox_size_t ncopy = min(track_samples, WINDOWSIZE-data->bufdata);
+    sox_size_t whole_window = (ncopy + data->bufdata == WINDOWSIZE);
     int oldbuf = data->bufdata;
-    st_size_t i;
+    sox_size_t i;
 
     assert(effp->ininfo.channels == effp->outinfo.channels);
 
@@ -265,7 +265,7 @@
     /* Reduce noise on every channel. */
     for (i = 0; i < tracks; i ++) {
         chandata_t* chan = &(data->chandata[i]);
-        st_size_t j;
+        sox_size_t j;
 
         if (chan->window == NULL)
             chan->window = (float*)xcalloc(WINDOWSIZE, sizeof(float));
@@ -272,7 +272,7 @@
         
         for (j = 0; j < ncopy; j ++)
             chan->window[oldbuf + j] =
-                ST_SAMPLE_TO_FLOAT_DWORD(ibuf[i + tracks * j], effp->clips);
+                SOX_SAMPLE_TO_FLOAT_DWORD(ibuf[i + tracks * j], effp->clips);
 
         if (!whole_window)
             continue;
@@ -286,7 +286,7 @@
     else
         *osamp = 0;
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
@@ -293,7 +293,7 @@
  * We have up to half a window left to dump.
  */
 
-static int st_noisered_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_noisered_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
     reddata_t data = (reddata_t)effp->priv;
     int i;
@@ -304,16 +304,16 @@
     /* FIXME: This is very picky.  osamp needs to be big enough to get all
      * remaining data or it will be discarded.
      */
-    return (ST_EOF);
+    return (SOX_EOF);
 }
 
 /*
  * Clean up.
  */
-static int st_noisered_stop(eff_t effp)
+static int sox_noisered_stop(eff_t effp)
 {
     reddata_t data = (reddata_t) effp->priv;
-    st_size_t i;
+    sox_size_t i;
 
     for (i = 0; i < effp->ininfo.channels; i ++) {
         chandata_t* chan = &(data->chandata[i]);
@@ -325,22 +325,22 @@
     
     free(data->chandata);
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-static st_effect_t st_noisered_effect = {
+static sox_effect_t sox_noisered_effect = {
   "noisered",
   "Usage: noiseprof profile-file [threshold]",
-  ST_EFF_MCHAN,
-  st_noisered_getopts,
-  st_noisered_start,
-  st_noisered_flow,
-  st_noisered_drain,
-  st_noisered_stop,
-  st_effect_nothing
+  SOX_EFF_MCHAN,
+  sox_noisered_getopts,
+  sox_noisered_start,
+  sox_noisered_flow,
+  sox_noisered_drain,
+  sox_noisered_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_noisered_effect_fn(void)
+const sox_effect_t *sox_noisered_effect_fn(void)
 {
-    return &st_noisered_effect;
+    return &sox_noisered_effect;
 }
--- a/src/noisered.h
+++ b/src/noisered.h
@@ -12,7 +12,7 @@
  * (at your option) any later version.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "FFT.h"
 
 #include <math.h>
--- a/src/nulfile.c
+++ b/src/nulfile.c
@@ -14,29 +14,29 @@
  * of using this software
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <string.h>
 
-static int st_nulstartread(ft_t ft) 
+static int sox_nulstartread(ft_t ft) 
 {
   /* If format parameters are not given, set somewhat arbitrary
    * (but commonly used) defaults: */
   if (ft->signal.rate     == 0) ft->signal.rate     = 44100;
   if (ft->signal.channels == 0) ft->signal.channels = 2;
-  if (ft->signal.size     ==-1) ft->signal.size     = ST_SIZE_16BIT;
-  if (ft->signal.encoding == ST_ENCODING_UNKNOWN) ft->signal.encoding = ST_ENCODING_SIGN2;
+  if (ft->signal.size     ==-1) ft->signal.size     = SOX_SIZE_16BIT;
+  if (ft->signal.encoding == SOX_ENCODING_UNKNOWN) ft->signal.encoding = SOX_ENCODING_SIGN2;
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static st_size_t st_nulread(ft_t ft UNUSED, st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_nulread(ft_t ft UNUSED, sox_sample_t *buf, sox_size_t len) 
 {
-  /* Reading from null generates silence i.e. (st_sample_t)0. */
-  memset(buf, 0, sizeof(st_sample_t) * len);
+  /* Reading from null generates silence i.e. (sox_sample_t)0. */
+  memset(buf, 0, sizeof(sox_sample_t) * len);
   return len; /* Return number of samples "read". */
 }
 
-static st_size_t st_nulwrite(ft_t ft UNUSED, const st_sample_t *buf UNUSED, st_size_t len) 
+static sox_size_t sox_nulwrite(ft_t ft UNUSED, const sox_sample_t *buf UNUSED, sox_size_t len) 
 {
   /* Writing to null just discards the samples */
   return len; /* Return number of samples "written". */
@@ -48,20 +48,20 @@
   NULL,
 };
 
-static st_format_t st_nul_format = {
+static sox_format_t sox_nul_format = {
   nulnames,
   NULL,
-  ST_FILE_DEVICE | ST_FILE_PHONY | ST_FILE_NOSTDIO,
-  st_nulstartread,
-  st_nulread,
-  st_format_nothing,
-  st_format_nothing,
-  st_nulwrite,
-  st_format_nothing,
-  st_format_nothing_seek
+  SOX_FILE_DEVICE | SOX_FILE_PHONY | SOX_FILE_NOSTDIO,
+  sox_nulstartread,
+  sox_nulread,
+  sox_format_nothing,
+  sox_format_nothing,
+  sox_nulwrite,
+  sox_format_nothing,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_nul_format_fn(void)
+const sox_format_t *sox_nul_format_fn(void)
 {
-    return &st_nul_format;
+    return &sox_nul_format;
 }
--- a/src/oss.c
+++ b/src/oss.c
@@ -25,7 +25,7 @@
  *
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #ifdef HAVE_OSS
 
@@ -46,39 +46,39 @@
 {
     int sampletype, samplesize, dsp_stereo;
     int tmp, rc;
-    st_fileinfo_t *file = (st_fileinfo_t *)ft->priv;
+    sox_fileinfo_t *file = (sox_fileinfo_t *)ft->priv;
 
     if (ft->signal.rate == 0.0) ft->signal.rate = 8000;
-    if (ft->signal.size == -1) ft->signal.size = ST_SIZE_BYTE;
-    if (ft->signal.size == ST_SIZE_BYTE) {
+    if (ft->signal.size == -1) ft->signal.size = SOX_SIZE_BYTE;
+    if (ft->signal.size == SOX_SIZE_BYTE) {
         sampletype = AFMT_U8;
         samplesize = 8;
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
-            ft->signal.encoding = ST_ENCODING_UNSIGNED;
-        if (ft->signal.encoding != ST_ENCODING_UNSIGNED) {
-            st_report("OSS driver only supports unsigned with bytes");
-            st_report("Forcing to unsigned");
-            ft->signal.encoding = ST_ENCODING_UNSIGNED;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN)
+            ft->signal.encoding = SOX_ENCODING_UNSIGNED;
+        if (ft->signal.encoding != SOX_ENCODING_UNSIGNED) {
+            sox_report("OSS driver only supports unsigned with bytes");
+            sox_report("Forcing to unsigned");
+            ft->signal.encoding = SOX_ENCODING_UNSIGNED;
         }
     }
-    else if (ft->signal.size == ST_SIZE_16BIT) {
-        sampletype = (ST_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
+    else if (ft->signal.size == SOX_SIZE_16BIT) {
+        sampletype = (SOX_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
         samplesize = 16;
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
-            ft->signal.encoding = ST_ENCODING_SIGN2;
-        if (ft->signal.encoding != ST_ENCODING_SIGN2) {
-            st_report("OSS driver only supports signed with words");
-            st_report("Forcing to signed linear");
-            ft->signal.encoding = ST_ENCODING_SIGN2;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN)
+            ft->signal.encoding = SOX_ENCODING_SIGN2;
+        if (ft->signal.encoding != SOX_ENCODING_SIGN2) {
+            sox_report("OSS driver only supports signed with words");
+            sox_report("Forcing to signed linear");
+            ft->signal.encoding = SOX_ENCODING_SIGN2;
         }
     }
     else {
-        sampletype = (ST_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
+        sampletype = (SOX_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
         samplesize = 16;
-        ft->signal.size = ST_SIZE_16BIT;
-        ft->signal.encoding = ST_ENCODING_SIGN2;
-        st_report("OSS driver only supports bytes and words");
-        st_report("Forcing to signed linear word");
+        ft->signal.size = SOX_SIZE_16BIT;
+        ft->signal.encoding = SOX_ENCODING_SIGN2;
+        sox_report("OSS driver only supports bytes and words");
+        sox_report("Forcing to signed linear word");
     }
 
     if (ft->signal.channels == 0) ft->signal.channels = 1;
@@ -86,8 +86,8 @@
 
     if (ioctl(fileno(ft->fp), SNDCTL_DSP_RESET, 0) < 0)
     {
-        st_fail_errno(ft,ST_EOF,"Unable to reset OSS driver.  Possibly accessing an invalid file/device");
-        return(ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"Unable to reset OSS driver.  Possibly accessing an invalid file/device");
+        return(SOX_EOF);
     }
 
     /* Query the supported formats and find the best match
@@ -100,10 +100,10 @@
             if (samplesize == 16 && (tmp & (AFMT_S16_LE|AFMT_S16_BE)) == 0)
             {
                 /* Must not like 16-bits, try 8-bits */
-                ft->signal.size = ST_SIZE_BYTE;
-                ft->signal.encoding = ST_ENCODING_UNSIGNED;
-                st_report("OSS driver doesn't like signed words");
-                st_report("Forcing to unsigned bytes");
+                ft->signal.size = SOX_SIZE_BYTE;
+                ft->signal.encoding = SOX_ENCODING_UNSIGNED;
+                sox_report("OSS driver doesn't like signed words");
+                sox_report("Forcing to unsigned bytes");
                 tmp = sampletype = AFMT_U8;
                 samplesize = 8;
             }
@@ -110,16 +110,16 @@
             /* is 8-bit supported */
             else if (samplesize == 8 && (tmp & AFMT_U8) == 0)
             {
-                ft->signal.size = ST_SIZE_16BIT;
-                ft->signal.encoding = ST_ENCODING_SIGN2;
-                st_report("OSS driver doesn't like unsigned bytes");
-                st_report("Forcing to signed words");
-                sampletype = (ST_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
+                ft->signal.size = SOX_SIZE_16BIT;
+                ft->signal.encoding = SOX_ENCODING_SIGN2;
+                sox_report("OSS driver doesn't like unsigned bytes");
+                sox_report("Forcing to signed words");
+                sampletype = (SOX_IS_BIGENDIAN) ? AFMT_S16_BE : AFMT_S16_LE;
                 samplesize = 16;
             }
             /* determine which 16-bit format to use */
             if (samplesize == 16 && (tmp & sampletype) == 0)
-              sampletype = (ST_IS_BIGENDIAN) ? AFMT_S16_LE : AFMT_S16_BE;
+              sampletype = (SOX_IS_BIGENDIAN) ? AFMT_S16_LE : AFMT_S16_BE;
         }
         tmp = sampletype;
         rc = ioctl(fileno(ft->fp), SNDCTL_DSP_SETFMT, &tmp);
@@ -127,12 +127,12 @@
     /* Give up and exit */
     if (rc < 0 || tmp != sampletype)
     {
-        st_fail_errno(ft,ST_EOF,"Unable to set the sample size to %d", samplesize);
-        return (ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"Unable to set the sample size to %d", samplesize);
+        return (SOX_EOF);
     }
 
     if (samplesize == 16)
-      ft->signal.reverse_bytes = ST_IS_BIGENDIAN != (sampletype == AFMT_S16_BE);
+      ft->signal.reverse_bytes = SOX_IS_BIGENDIAN != (sampletype == AFMT_S16_BE);
 
     if (ft->signal.channels == 2) dsp_stereo = 1;
     else dsp_stereo = 0;
@@ -140,13 +140,13 @@
     tmp = dsp_stereo;
     if (ioctl(fileno(ft->fp), SNDCTL_DSP_STEREO, &tmp) < 0)
     {
-        st_warn("Couldn't set to %s", dsp_stereo?  "stereo":"mono");
+        sox_warn("Couldn't set to %s", dsp_stereo?  "stereo":"mono");
         dsp_stereo = 0;
     }
 
     if (tmp != dsp_stereo)
     {
-        st_warn("Sound card appears to only support %d channels.  Overriding format", tmp+1);
+        sox_warn("Sound card appears to only support %d channels.  Overriding format", tmp+1);
         ft->signal.channels = tmp + 1;
     }
 
@@ -163,7 +163,7 @@
          */
         if ((int)ft->signal.rate - tmp > (tmp * .01) || 
             tmp - (int)ft->signal.rate > (tmp * .01)) {
-            st_warn("Unable to set audio speed to %d (set to %d)",
+            sox_warn("Unable to set audio speed to %d (set to %d)",
                      ft->signal.rate, tmp);
             ft->signal.rate = tmp;
         }
@@ -175,8 +175,8 @@
     file->size = 0;
     ioctl (fileno(ft->fp), SNDCTL_DSP_GETBLKSIZE, &file->size);
     if (file->size < 4 || file->size > 65536) {
-            st_fail_errno(ft,ST_EOF,"Invalid audio buffer size %d", file->size);
-            return (ST_EOF);
+            sox_fail_errno(ft,SOX_EOF,"Invalid audio buffer size %d", file->size);
+            return (SOX_EOF);
     }
     file->count = 0;
     file->pos = 0;
@@ -184,13 +184,13 @@
     file->buf = (char *)xmalloc(file->size);
 
     if (ioctl(fileno(ft->fp), SNDCTL_DSP_SYNC, NULL) < 0) {
-        st_fail_errno(ft,ST_EOF,"Unable to sync dsp");
-        return (ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"Unable to sync dsp");
+        return (SOX_EOF);
     }
 
     /* Change to non-buffered I/O */
     setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * file->size);
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
 }
 
 /*
@@ -200,7 +200,7 @@
  *      size and encoding of samples,
  *      mono/stereo/quad.
  */
-static int st_ossdspstartread(ft_t ft)
+static int sox_ossdspstartread(ft_t ft)
 {
     int rc;
     rc = ossdspinit(ft);
@@ -207,7 +207,7 @@
     return rc;
 }
 
-static int st_ossdspstartwrite(ft_t ft)
+static int sox_ossdspstartwrite(ft_t ft)
 {
     return ossdspinit(ft);
 }
@@ -218,21 +218,21 @@
   NULL
 };
 
-static st_format_t st_ossdsp_format = {
+static sox_format_t sox_ossdsp_format = {
   ossdspnames,
   NULL,
-  ST_FILE_DEVICE,
-  st_ossdspstartread,
-  st_rawread,
-  st_rawstopread,
-  st_ossdspstartwrite,
-  st_rawwrite,
-  st_rawstopwrite,
-  st_format_nothing_seek
+  SOX_FILE_DEVICE,
+  sox_ossdspstartread,
+  sox_rawread,
+  sox_rawstopread,
+  sox_ossdspstartwrite,
+  sox_rawwrite,
+  sox_rawstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_ossdsp_format_fn(void)
+const sox_format_t *sox_ossdsp_format_fn(void)
 {
-    return &st_ossdsp_format;
+    return &sox_ossdsp_format;
 }
 #endif
--- a/src/pad.c
+++ b/src/pad.c
@@ -16,7 +16,7 @@
 
 /* Effect: Pad With Silence   (c) 2006 robs@users.sourceforge.net */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 typedef struct pad
 {
@@ -23,19 +23,19 @@
   int npads;         /* Number of pads requested */
   struct {
     char *str;       /* Command-line argument to parse for this pad */
-    st_size_t start; /* Start padding when in_pos equals this */
-    st_size_t pad;   /* Number of samples to pad */
+    sox_size_t start; /* Start padding when in_pos equals this */
+    sox_size_t pad;   /* Number of samples to pad */
   } * pads;
 
-  st_size_t in_pos;  /* Number of samples read from the input stream */
+  sox_size_t in_pos;  /* Number of samples read from the input stream */
   int pads_pos;      /* Number of pads completed so far */
-  st_size_t pad_pos; /* Number of samples through the current pad */
+  sox_size_t pad_pos; /* Number of samples through the current pad */
 } * pad_t;
 
-assert_static(sizeof(struct pad) <= ST_MAX_EFFECT_PRIVSIZE,
+assert_static(sizeof(struct pad) <= SOX_MAX_EFFECT_PRIVSIZE,
               /* else */ pad_PRIVSIZE_too_big);
 
-static int parse(eff_t effp, char * * argv, st_rate_t rate)
+static int parse(eff_t effp, char * * argv, sox_rate_t rate)
 {
   pad_t p = (pad_t) effp->priv;
   char const * next;
@@ -44,22 +44,22 @@
   for (i = 0; i < p->npads; ++i) {
     if (argv) /* 1st parse only */
       p->pads[i].str = xstrdup(argv[i]);
-    next = st_parsesamples(rate, p->pads[i].str, &p->pads[i].pad, 't');
+    next = sox_parsesamples(rate, p->pads[i].str, &p->pads[i].pad, 't');
     if (next == NULL) break;
     if (*next == '\0')
-      p->pads[i].start = i? ST_SIZE_MAX : 0;
+      p->pads[i].start = i? SOX_SIZE_MAX : 0;
     else {
       if (*next != '@') break;
-      next = st_parsesamples(rate, next+1, &p->pads[i].start, 't');
+      next = sox_parsesamples(rate, next+1, &p->pads[i].start, 't');
       if (next == NULL || *next != '\0') break;
     }
     if (i > 0 && p->pads[i].start <= p->pads[i-1].start) break;
   }
   if (i < p->npads) {
-    st_fail(effp->h->usage);
-    return ST_EOF;
+    sox_fail(effp->h->usage);
+    return SOX_EOF;
   }
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static int create(eff_t effp, int n, char * * argv)
@@ -66,7 +66,7 @@
 {
   pad_t p = (pad_t) effp->priv;
   p->pads = xcalloc(p->npads = n, sizeof(*p->pads));
-  return parse(effp, argv, ST_MAXRATE); /* No rate yet; parse with dummy */
+  return parse(effp, argv, SOX_MAXRATE); /* No rate yet; parse with dummy */
 }
 
 static int start(eff_t effp)
@@ -78,15 +78,15 @@
   p->in_pos = p->pad_pos = p->pads_pos = 0;
   for (i = 0; i < p->npads; ++i)
     if (p->pads[i].pad)
-      return ST_SUCCESS;
-  return ST_EFF_NULL;
+      return SOX_SUCCESS;
+  return SOX_EFF_NULL;
 }
 
-static int flow(eff_t effp, const st_sample_t * ibuf, st_sample_t * obuf,
-                st_size_t * isamp, st_size_t * osamp)
+static int flow(eff_t effp, const sox_sample_t * ibuf, sox_sample_t * obuf,
+                sox_size_t * isamp, sox_size_t * osamp)
 {
   pad_t p = (pad_t) effp->priv;
-  st_size_t c, idone = 0, odone = 0;
+  sox_size_t c, idone = 0, odone = 0;
   *isamp /= effp->ininfo.channels;
   *osamp /= effp->ininfo.channels;
 
@@ -108,15 +108,15 @@
 
   *isamp = idone * effp->ininfo.channels;
   *osamp = odone * effp->ininfo.channels;
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static int drain(eff_t effp, st_sample_t * obuf, st_size_t * osamp)
+static int drain(eff_t effp, sox_sample_t * obuf, sox_size_t * osamp)
 {
-  static st_size_t isamp = 0;
+  static sox_size_t isamp = 0;
   pad_t p = (pad_t) effp->priv;
   if (p->pads_pos != p->npads && p->in_pos != p->pads[p->pads_pos].start)
-    p->in_pos = ST_SIZE_MAX;  /* Invoke the final pad (with no given start) */
+    p->in_pos = SOX_SIZE_MAX;  /* Invoke the final pad (with no given start) */
   return flow(effp, 0, obuf, &isamp, osamp);
 }
 
@@ -124,8 +124,8 @@
 {
   pad_t p = (pad_t) effp->priv;
   if (p->pads_pos != p->npads)
-    st_warn("Input audio too short; pads not applied: %i",p->npads-p->pads_pos);
-  return ST_SUCCESS;
+    sox_warn("Input audio too short; pads not applied: %i",p->npads-p->pads_pos);
+  return SOX_SUCCESS;
 }
 
 static int delete(eff_t effp)
@@ -135,13 +135,13 @@
   for (i = 0; i < p->npads; ++i)
     free(p->pads[i].str);
   free(p->pads);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-st_effect_t const * st_pad_effect_fn(void)
+sox_effect_t const * sox_pad_effect_fn(void)
 {
-  static st_effect_t driver = {
-    "pad", "Usage: pad {length[@position]}", ST_EFF_MCHAN,
+  static sox_effect_t driver = {
+    "pad", "Usage: pad {length[@position]}", SOX_EFF_MCHAN,
     create, start, flow, drain, stop, delete
   };
   return &driver;
--- a/src/pan.c
+++ b/src/pan.c
@@ -16,10 +16,10 @@
  * pan 0.0 basically behaves as avg.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <string.h>
 
-static st_effect_t st_pan_effect;
+static sox_effect_t sox_pan_effect;
 
 /* structure to hold pan parameter */
 
@@ -30,7 +30,7 @@
 /*
  * Process options
  */
-static int st_pan_getopts(eff_t effp, int n, char **argv) 
+static int sox_pan_getopts(eff_t effp, int n, char **argv) 
 {
     pan_t pan = (pan_t) effp->priv; 
     
@@ -39,51 +39,51 @@
     if (n && (!sscanf(argv[0], "%lf", &pan->dir) || 
               pan->dir < -1.0 || pan->dir > 1.0))
     {
-        st_fail(st_pan_effect.usage);
-        return ST_EOF;
+        sox_fail(sox_pan_effect.usage);
+        return SOX_EOF;
     }
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
  * Start processing
  */
-static int st_pan_start(eff_t effp)
+static int sox_pan_start(eff_t effp)
 {
     if (effp->outinfo.channels==1)
-        st_warn("PAN onto a mono channel...");
+        sox_warn("PAN onto a mono channel...");
 
     if (effp->outinfo.rate != effp->ininfo.rate)
     {
-        st_fail("PAN cannot handle different rates (in=%ld, out=%ld)"
+        sox_fail("PAN cannot handle different rates (in=%ld, out=%ld)"
              " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
-        return ST_EOF;
+        return SOX_EOF;
     }
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 
 #define UNEXPECTED_CHANNELS \
-    st_fail("unexpected number of channels (in=%d, out=%d)", ich, och); \
+    sox_fail("unexpected number of channels (in=%d, out=%d)", ich, och); \
     free(ibuf_copy); \
-    return ST_EOF
+    return SOX_EOF
 
 /*
  * Process either isamp or osamp samples, whichever is smaller.
  */
-static int st_pan_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                st_size_t *isamp, st_size_t *osamp)
+static int sox_pan_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                sox_size_t *isamp, sox_size_t *osamp)
 {
     pan_t pan = (pan_t) effp->priv;
-    st_size_t len, done;
-    st_sample_t *ibuf_copy;
+    sox_size_t len, done;
+    sox_sample_t *ibuf_copy;
     char ich, och;
     double left, right, dir, hdir;
     
-    ibuf_copy = (st_sample_t *)xmalloc(*isamp * sizeof(st_sample_t));
-    memcpy(ibuf_copy, ibuf, *isamp * sizeof(st_sample_t));
+    ibuf_copy = (sox_sample_t *)xmalloc(*isamp * sizeof(sox_sample_t));
+    memcpy(ibuf_copy, ibuf, *isamp * sizeof(sox_sample_t));
 
     dir   = pan->dir;    /* -1   <=  dir  <= 1   */
     hdir  = 0.5 * dir;  /* -0.5 <=  hdir <= 0.5 */
@@ -112,7 +112,7 @@
             {
                 double f;
                 f = 0.5*ibuf_copy[0] + 0.5*ibuf_copy[1];
-                ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                 *obuf++ = f;
                 ibuf_copy += 2;
             }
@@ -123,7 +123,7 @@
                 double f;
                 f = 0.25*ibuf_copy[0] + 0.25*ibuf_copy[1] + 
                         0.25*ibuf_copy[2] + 0.25*ibuf_copy[3];
-                ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                 *obuf++ = f;
                 ibuf_copy += 4;
             }
@@ -141,10 +141,10 @@
                 double f;
 
                 f = left * ibuf_copy[0];
-                ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                 obuf[0] = f;
                 f = right * ibuf_copy[0];
-                ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                 obuf[1] = f;
                 obuf += 2;
                 ibuf_copy++;
@@ -167,10 +167,10 @@
                     double f;
 
                     f = cll * ibuf_copy[0] + clr * ibuf_copy[1];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[0] = f;
                     f = cr * ibuf_copy[1];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[1] = f;
                     obuf += 2;
                     ibuf_copy += 2;
@@ -190,10 +190,10 @@
                     double f;
 
                     f = cl * ibuf_copy[0];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[0] = f;
                     f = crl * ibuf_copy[0] + crr * ibuf_copy[1];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[1] = f;
                     obuf += 2;
                     ibuf_copy += 2;
@@ -220,10 +220,10 @@
 
                     /* pan it */
                     f = cll * ibuf0 + clr * ibuf1;
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[0] = f;
                     f = cr * ibuf1;
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[1] = f;
                     obuf += 2;
                     ibuf_copy += 4;
@@ -246,10 +246,10 @@
                     ibuf1 = 0.5*ibuf_copy[1] + 0.5*ibuf_copy[3];
 
                     f = cl * ibuf0;
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[0] = f;
                     f = crl * ibuf0 + crr * ibuf1;
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[1] = f;
                     obuf += 2;
                     ibuf_copy += 4;
@@ -275,10 +275,10 @@
                     double f;
 
                     f = cl * ibuf_copy[0];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[2] = obuf[0] = f;
                     f = cr * ibuf_copy[0];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     ibuf_copy[3] = obuf[1] = f;
                     obuf += 4;
                     ibuf_copy++;
@@ -300,10 +300,10 @@
                     double f;
 
                     f = cll * ibuf_copy[0] + clr * ibuf_copy[1];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[2] = obuf[0] = f;
                     f = cr * ibuf_copy[1];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     ibuf_copy[3] = obuf[1] = f;
                     obuf += 4;
                     ibuf_copy += 2;
@@ -323,10 +323,10 @@
                     double f;
 
                     f = cl * ibuf_copy[0];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[2] = obuf[0] =f ;
                     f = crl * ibuf_copy[0] + crr * ibuf_copy[1];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     ibuf_copy[3] = obuf[1] = f;
                     obuf += 4;
                     ibuf_copy += 2;
@@ -349,16 +349,16 @@
                     double f;
 
                     f = cown*ibuf_copy[0] + cright*ibuf_copy[1];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[0] = f;
                     f = cown*ibuf_copy[1] + cright*ibuf_copy[3];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[1] = f;
                     f = cown*ibuf_copy[2] + cright*ibuf_copy[0];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[2] = f;
                     f = cown*ibuf_copy[3] + cright*ibuf_copy[2];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[3] = f;
                     obuf += 4;
                     ibuf_copy += 4;              
@@ -376,16 +376,16 @@
                     double f;
 
                     f = cleft*ibuf_copy[2] + cown*ibuf_copy[0];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[0] = f;
                     f = cleft*ibuf_copy[0] + cown*ibuf_copy[1];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[1] = f;
                     f = cleft*ibuf_copy[3] + cown*ibuf_copy[2];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[2] = f;
                     f = cleft*ibuf_copy[1] + cown*ibuf_copy[3];
-                    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                     obuf[3] = f;
                     obuf += 4;
                     ibuf_copy += 4;
@@ -404,7 +404,7 @@
 
     free(ibuf_copy);
     
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
@@ -411,19 +411,19 @@
  * FIXME: Add a stop function with statistics on right, left, and output amplitudes.
  */
 
-static st_effect_t st_pan_effect = {
+static sox_effect_t sox_pan_effect = {
   "pan",
   "Usage: pan direction (in [-1.0 .. 1.0])",
-  ST_EFF_MCHAN | ST_EFF_CHAN,
-  st_pan_getopts,
-  st_pan_start,
-  st_pan_flow,
-  st_effect_nothing_drain,
-  st_effect_nothing,
-  st_effect_nothing
+  SOX_EFF_MCHAN | SOX_EFF_CHAN,
+  sox_pan_getopts,
+  sox_pan_start,
+  sox_pan_flow,
+  sox_effect_nothing_drain,
+  sox_effect_nothing,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_pan_effect_fn(void)
+const sox_effect_t *sox_pan_effect_fn(void)
 {
-    return &st_pan_effect;
+    return &sox_pan_effect;
 }
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -57,9 +57,9 @@
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
 #include <math.h>
 #include <string.h>
-#include "st_i.h"
+#include "sox_i.h"
 
-static st_effect_t st_phaser_effect;
+static sox_effect_t sox_phaser_effect;
 
 #define MOD_SINE        0
 #define MOD_TRIANGLE    1
@@ -73,22 +73,22 @@
         float   in_gain, out_gain;
         float   delay, decay;
         float   speed;
-        st_size_t length;
+        sox_size_t length;
         int     *lookup_tab;
-        st_size_t maxsamples, fade_out;
+        sox_size_t maxsamples, fade_out;
 } *phaser_t;
 
 /*
  * Process options
  */
-static int st_phaser_getopts(eff_t effp, int n, char **argv) 
+static int sox_phaser_getopts(eff_t effp, int n, char **argv) 
 {
         phaser_t phaser = (phaser_t) effp->priv;
 
         if (!((n == 5) || (n == 6)))
         {
-            st_fail(st_phaser_effect.usage);
-            return (ST_EOF);
+            sox_fail(sox_phaser_effect.usage);
+            return (SOX_EOF);
         }
 
         sscanf(argv[0], "%f", &phaser->in_gain);
@@ -104,17 +104,17 @@
                         phaser->modulation = MOD_TRIANGLE;
                 else
                 {
-                        st_fail(st_phaser_effect.usage);
-                        return (ST_EOF);
+                        sox_fail(sox_phaser_effect.usage);
+                        return (SOX_EOF);
                 }
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Prepare for processing.
  */
-static int st_phaser_start(eff_t effp)
+static int sox_phaser_start(eff_t effp)
 {
         phaser_t phaser = (phaser_t) effp->priv;
         unsigned int i;
@@ -123,39 +123,39 @@
 
         if ( phaser->delay < 0.0 )
         {
-            st_fail("phaser: delay must be positive!");
-            return (ST_EOF);
+            sox_fail("phaser: delay must be positive!");
+            return (SOX_EOF);
         }
         if ( phaser->delay > 5.0 )
         {
-            st_fail("phaser: delay must be less than 5.0 msec!");
-            return (ST_EOF);
+            sox_fail("phaser: delay must be less than 5.0 msec!");
+            return (SOX_EOF);
         }
         if ( phaser->speed < 0.1 )
         {
-            st_fail("phaser: speed must be more than 0.1 Hz!");
-            return (ST_EOF);
+            sox_fail("phaser: speed must be more than 0.1 Hz!");
+            return (SOX_EOF);
         }
         if ( phaser->speed > 2.0 )
         {
-            st_fail("phaser: speed must be less than 2.0 Hz!");
-            return (ST_EOF);
+            sox_fail("phaser: speed must be less than 2.0 Hz!");
+            return (SOX_EOF);
         }
         if ( phaser->decay < 0.0 )
         {
-            st_fail("phaser: decay must be positive!" );
-            return (ST_EOF);
+            sox_fail("phaser: decay must be positive!" );
+            return (SOX_EOF);
         }
         if ( phaser->decay >= 1.0 )
         {
-            st_fail("phaser: decay must be less that 1.0!" );
-            return (ST_EOF);
+            sox_fail("phaser: decay must be less that 1.0!" );
+            return (SOX_EOF);
         }
         /* Be nice and check the hint with warning, if... */
         if ( phaser->in_gain > ( 1.0 - phaser->decay * phaser->decay ) )
-                st_warn("phaser: warning >>> gain-in can cause saturation or clipping of output <<<");
+                sox_warn("phaser: warning >>> gain-in can cause saturation or clipping of output <<<");
         if ( phaser->in_gain / ( 1.0 - phaser->decay ) > 1.0 / phaser->out_gain )
-                st_warn("phaser: warning >>> gain-out can cause saturation or clipping of output <<<");
+                sox_warn("phaser: warning >>> gain-out can cause saturation or clipping of output <<<");
 
         phaser->length = effp->ininfo.rate / phaser->speed;
         phaser->phaserbuf = (double *) xmalloc(sizeof (double) * phaser->maxsamples);
@@ -164,15 +164,15 @@
         phaser->lookup_tab = (int *) xmalloc(sizeof (int) * phaser->length);
 
         if (phaser->modulation == MOD_SINE)
-          st_generate_wave_table(ST_WAVE_SINE, ST_INT, phaser->lookup_tab,
+          sox_generate_wave_table(SOX_WAVE_SINE, SOX_INT, phaser->lookup_tab,
               phaser->length, 0, phaser->maxsamples - 1, 0);
         else
-          st_generate_wave_table(ST_WAVE_TRIANGLE, ST_INT, phaser->lookup_tab,
+          sox_generate_wave_table(SOX_WAVE_TRIANGLE, SOX_INT, phaser->lookup_tab,
               phaser->length, 0, 2 * (phaser->maxsamples - 1), 3 * M_PI_2);
         phaser->counter = 0;
         phaser->phase = 0;
         phaser->fade_out = phaser->maxsamples;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
@@ -179,14 +179,14 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_phaser_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                   st_size_t *isamp, st_size_t *osamp)
+static int sox_phaser_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                   sox_size_t *isamp, sox_size_t *osamp)
 {
         phaser_t phaser = (phaser_t) effp->priv;
         int len, done;
         
         double d_in, d_out;
-        st_sample_t out;
+        sox_sample_t out;
 
         len = ((*isamp > *osamp) ? *osamp : *isamp);
         for(done = 0; done < len; done++) {
@@ -199,7 +199,7 @@
         phaser->maxsamples] * phaser->decay * -1.0;
                 /* Adjust the output volume and size to 24 bit */
                 d_out = d_in * phaser->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 *obuf++ = out * 256;
                 /* Mix decay of delay and input */
                 phaser->phaserbuf[phaser->counter] = d_in;
@@ -208,19 +208,19 @@
                 phaser->phase  = ( phaser->phase + 1 ) % phaser->length;
         }
         /* processed all samples */
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Drain out reverb lines. 
  */
-static int st_phaser_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_phaser_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
         phaser_t phaser = (phaser_t) effp->priv;
-        st_size_t done;
+        sox_size_t done;
         
         double d_in, d_out;
-        st_sample_t out;
+        sox_sample_t out;
 
         done = 0;
         while ( ( done < *osamp ) && ( done < phaser->fade_out ) ) {
@@ -232,7 +232,7 @@
         phaser->maxsamples] * phaser->decay * -1.0;
                 /* Adjust the output volume and size to 24 bit */
                 d_out = d_in * phaser->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 *obuf++ = out * 256;
                 /* Mix decay of delay and input */
                 phaser->phaserbuf[phaser->counter] = d_in;
@@ -245,36 +245,36 @@
         /* samples played, it remains */
         *osamp = done;
         if (phaser->fade_out == 0)
-            return ST_EOF;
+            return SOX_EOF;
         else
-            return ST_SUCCESS;
+            return SOX_SUCCESS;
 }
 
 /*
  * Clean up phaser effect.
  */
-static int st_phaser_stop(eff_t effp)
+static int sox_phaser_stop(eff_t effp)
 {
         phaser_t phaser = (phaser_t) effp->priv;
 
         free(phaser->phaserbuf);
         free(phaser->lookup_tab);
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_effect_t st_phaser_effect = {
+static sox_effect_t sox_phaser_effect = {
   "phaser",
   "Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]",
   0,
-  st_phaser_getopts,
-  st_phaser_start,
-  st_phaser_flow,
-  st_phaser_drain,
-  st_phaser_stop,
-  st_effect_nothing
+  sox_phaser_getopts,
+  sox_phaser_start,
+  sox_phaser_flow,
+  sox_phaser_drain,
+  sox_phaser_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_phaser_effect_fn(void)
+const sox_effect_t *sox_phaser_effect_fn(void)
 {
-    return &st_phaser_effect;
+    return &sox_phaser_effect;
 }
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -35,7 +35,7 @@
  * Some speed-optimization could be added at code size expanse/expense?
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -42,7 +42,7 @@
 
 #include <math.h>   /* cos(), pow() */
 
-static st_effect_t st_pitch_effect;
+static sox_effect_t sox_pitch_effect;
 
 /* cross fading options for transitions
  */
@@ -102,9 +102,9 @@
 
     unsigned int iacc;   /* part of acc already output */
 
-    st_size_t size;      /* size of buffer for processing chunks. */
+    sox_size_t size;      /* size of buffer for processing chunks. */
     unsigned int index;  /* index of next empty input item. */
-    st_sample_t *buf;    /* bufferize input */
+    sox_sample_t *buf;    /* bufferize input */
 
     pitch_state_t state; /* buffer management status. */
 
@@ -126,7 +126,7 @@
 
 static void debug(pitch_t pitch, char * where)
 {
-  st_debug("%s: ind=%d sz=%ld step=%d o=%d rate=%f ia=%d st=%d fo=%s", 
+  sox_debug("%s: ind=%d sz=%ld step=%d o=%d rate=%f ia=%d st=%d fo=%s", 
   where, pitch->index, pitch->size, pitch->step, pitch->overlap, 
   pitch->rate, pitch->iacc, pitch->state, fadeoptname(pitch->fadeopt));
 }
@@ -169,7 +169,7 @@
  */
 static void interpolation(
   pitch_t pitch,
-  const st_sample_t *ibuf, int ilen, 
+  const sox_sample_t *ibuf, int ilen, 
   double * out, int olen,
   double rate) /* signed */
 {
@@ -246,7 +246,7 @@
 /*
  * Process options
  */
-static int st_pitch_getopts(eff_t effp, int n, char **argv) 
+static int sox_pitch_getopts(eff_t effp, int n, char **argv) 
 {
     pitch_t pitch = (pitch_t) effp->priv; 
     
@@ -255,8 +255,8 @@
 
     if (n && !sscanf(argv[0], "%lf", &pitch->shift))
     {
-        st_fail(st_pitch_effect.usage);
-        return ST_EOF;
+        sox_fail(sox_pitch_effect.usage);
+        return SOX_EOF;
     }
 
     /* sweep size in ms */
@@ -263,8 +263,8 @@
     pitch->width = PITCH_DEFAULT_WIDTH;
     if (n>1 && !sscanf(argv[1], "%lf", &pitch->width))
     {
-        st_fail(st_pitch_effect.usage);
-        return ST_EOF;
+        sox_fail(sox_pitch_effect.usage);
+        return SOX_EOF;
     }
 
     /* interpole option */
@@ -282,8 +282,8 @@
             pitch->interopt = PITCH_INTERPOLE_CUB;
             break;
         default:
-            st_fail(st_pitch_effect.usage);
-            return ST_EOF;
+            sox_fail(sox_pitch_effect.usage);
+            return SOX_EOF;
         }
     }
 
@@ -310,8 +310,8 @@
             pitch->fadeopt = PITCH_FADE_COS;
             break;
         default:
-            st_fail(st_pitch_effect.usage);
-            return ST_EOF;
+            sox_fail(sox_pitch_effect.usage);
+            return SOX_EOF;
         }
     }
     
@@ -319,17 +319,17 @@
     if (n>4 && (!sscanf(argv[4], "%lf", &pitch->coef) ||
                 pitch->coef<0.0 || pitch->coef>0.5))
     {
-        st_fail(st_pitch_effect.usage);
-        return ST_EOF;
+        sox_fail(sox_pitch_effect.usage);
+        return SOX_EOF;
     }
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
  * Start processing
  */
-static int st_pitch_start(eff_t effp)
+static int sox_pitch_start(eff_t effp)
 {
     pitch_t pitch = (pitch_t) effp->priv;
     register int sample_rate = effp->outinfo.rate;
@@ -339,16 +339,16 @@
      */
     if (effp->outinfo.rate != effp->ininfo.rate)
     {
-        st_fail("PITCH cannot handle different rates (in=%ld, out=%ld)"
+        sox_fail("PITCH cannot handle different rates (in=%ld, out=%ld)"
              " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
-        return ST_EOF;
+        return SOX_EOF;
     }
  
     if (effp->outinfo.channels != effp->ininfo.channels)
     {
-        st_fail("PITCH cannot handle different channels (in=%ld, out=%ld)"
+        sox_fail("PITCH cannot handle different channels (in=%ld, out=%ld)"
              " use avg or pan", effp->ininfo.channels, effp->outinfo.channels);
-        return ST_EOF;
+        return SOX_EOF;
     }
 
     /* computer inner stuff... */
@@ -379,7 +379,7 @@
     pitch->fade = (double *) xmalloc(pitch->step*sizeof(double));
     pitch->tmp  = (double *) xmalloc(pitch->step*sizeof(double));
     pitch->acc  = (double *) xmalloc(pitch->step*sizeof(double));
-    pitch->buf  = (st_sample_t *) xmalloc(pitch->size*sizeof(st_sample_t));
+    pitch->buf  = (sox_sample_t *) xmalloc(pitch->size*sizeof(sox_sample_t));
     pitch->index = pitch->overlap;
 
     /* default initial signal */
@@ -429,24 +429,24 @@
     }
     else
     {
-        st_fail("unexpected PITCH_FADE parameter %d", pitch->fadeopt);
-        return ST_EOF;
+        sox_fail("unexpected PITCH_FADE parameter %d", pitch->fadeopt);
+        return SOX_EOF;
     }
 
     if (pitch->shift == 0)
-      return ST_EFF_NULL;
+      return SOX_EFF_NULL;
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /* Processes input.
  */
-static int st_pitch_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                st_size_t *isamp, st_size_t *osamp)
+static int sox_pitch_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                sox_size_t *isamp, sox_size_t *osamp)
 {
     pitch_t pitch = (pitch_t) effp->priv;
     int i, size;
-    st_size_t len, iindex, oindex;
+    sox_size_t len, iindex, oindex;
 
     size = pitch->size;
     /* size to process */
@@ -466,7 +466,7 @@
         {
             register int tocopy = min(pitch->size-pitch->index, len);
 
-            memcpy(pitch->buf+pitch->index, ibuf+iindex, tocopy*sizeof(st_sample_t));
+            memcpy(pitch->buf+pitch->index, ibuf+iindex, tocopy*sizeof(sox_sample_t));
 
             len -= tocopy;
             pitch->index += tocopy;
@@ -492,7 +492,7 @@
                 float f;
 
                 f = pitch->acc[pitch->iacc++];
-                ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+                SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
                 obuf[oindex++] = f;
             }
 
@@ -513,15 +513,15 @@
     *isamp = iindex;
     *osamp = oindex;
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /* at the end...
  */
-static int st_pitch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_pitch_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
     pitch_t pitch = (pitch_t) effp->priv;
-    st_size_t i;
+    sox_size_t i;
 
     if (pitch->state == pi_input)
     {
@@ -545,7 +545,7 @@
         float f;
 
         f = pitch->acc[pitch->iacc++];
-        ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+        SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
         obuf[i++] = f;
     }
 
@@ -553,9 +553,9 @@
     *osamp = i;
 
     if ((pitch->index - pitch->overlap) == 0)
-        return ST_EOF;
+        return SOX_EOF;
     else
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
 }
     
 /*
@@ -562,7 +562,7 @@
  * Do anything required when you stop reading samples.  
  * Don't close input file! 
  */
-static int st_pitch_stop(eff_t effp)
+static int sox_pitch_stop(eff_t effp)
 {
     pitch_t pitch = (pitch_t) effp->priv;
 
@@ -571,24 +571,24 @@
     free(pitch->acc);
     free(pitch->buf);
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
-static st_effect_t st_pitch_effect = {
+static sox_effect_t sox_pitch_effect = {
   "pitch",
   "Usage: pitch shift width interpole fade\n"
   "       (in cents, in ms, cub/lin, cos/ham/lin/trap)"
   "       (defaults: 0 20 c c)",
   0,
-  st_pitch_getopts,
-  st_pitch_start,
-  st_pitch_flow,
-  st_pitch_drain,
-  st_pitch_stop,
-  st_effect_nothing
+  sox_pitch_getopts,
+  sox_pitch_start,
+  sox_pitch_flow,
+  sox_pitch_drain,
+  sox_pitch_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_pitch_effect_fn(void)
+const sox_effect_t *sox_pitch_effect_fn(void)
 {
-    return &st_pitch_effect;
+    return &sox_pitch_effect;
 }
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -27,7 +27,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "st_i.h"
+#include "sox_i.h"
 
 #define Float float/*double*/
 #define ISCALE 0x10000
@@ -44,11 +44,11 @@
 } polystage;
 
 typedef struct polyphase {
-  st_rate_t lcmrate;             /* least common multiple of rates */
-  st_rate_t inskip, outskip;     /* LCM increments for I & O rates */
+  sox_rate_t lcmrate;             /* least common multiple of rates */
+  sox_rate_t inskip, outskip;     /* LCM increments for I & O rates */
   double Factor;                 /* out_rate/in_rate               */
   unsigned long total;           /* number of filter stages        */
-  st_size_t oskip;               /* output samples to skip at start*/
+  sox_size_t oskip;               /* output samples to skip at start*/
   double inpipe;                 /* output samples 'in the pipe'   */
   polystage *stage[MF];          /* array of pointers to polystage structs */
   int win_type;
@@ -57,13 +57,13 @@
   int m1[MF], m2[MF], b1[MF], b2[MF]; /* arrays used in optimize_factors */
 } *poly_t;
 
-assert_static(sizeof(struct polyphase) <= ST_MAX_EFFECT_PRIVSIZE, 
+assert_static(sizeof(struct polyphase) <= SOX_MAX_EFFECT_PRIVSIZE, 
               /* else */ skeleff_PRIVSIZE_too_big);
 
 /*
  * Process options
  */
-static int st_poly_getopts(eff_t effp, int n, char **argv)
+static int sox_poly_getopts(eff_t effp, int n, char **argv)
 {
   poly_t rate = (poly_t) effp->priv;
 
@@ -99,11 +99,11 @@
       continue;
     }
 
-    st_fail("Polyphase: unknown argument (%s %s)!", argv[0], argv[1]);
-    return ST_EOF;
+    sox_fail("Polyphase: unknown argument (%s %s)!", argv[0], argv[1]);
+    return SOX_EOF;
   }
   
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
@@ -134,11 +134,11 @@
 
   p = primes;
   q = q0;
-  st_debug("factors(%d) =",n);
+  sox_debug("factors(%d) =",n);
   while (n > 1) {
     while ((pr = *p) && (n % pr)) p++;
     if (!pr) {
-      st_fail("Number %d too large of a prime.",n);
+      sox_fail("Number %d too large of a prime.",n);
       pr = n;
     }
     *q++ = pr;
@@ -145,8 +145,8 @@
     n /= pr;
   }
   *q = 0;
-  for (pr=0; pr<q-q0; pr++) st_debug(" %d",q0[pr]);
-  st_debug("");
+  for (pr=0; pr<q-q0; pr++) sox_debug(" %d",q0[pr]);
+  sox_debug("");
   return (q-q0);
 }
 
@@ -184,8 +184,8 @@
   }
   if (n) *p++=n;
   *p = 0;
-  /*for (k=0; k<p-m; k++) st_debug(" %d",m[k]);*/
-  /*st_debug("");*/
+  /*for (k=0; k<p-m; k++) sox_debug(" %d",m[k]);*/
+  /*sox_debug("");*/
   return (p-m);
 }
 
@@ -214,9 +214,9 @@
       cost = 0;
       f = denom;
       u = min(ct1,ct2) + 1;
-      /*st_debug("pfacts(%d): ", numer);*/
+      /*sox_debug("pfacts(%d): ", numer);*/
       u1 = permute(rate->m1,l1,ct1,u,amalg);
-      /*st_debug("pfacts(%d): ", denom);*/
+      /*sox_debug("pfacts(%d): ", denom);*/
       u2 = permute(rate->m2,l2,ct2,u,amalg);
       u = max(u1,u2);
       for (j=0; j<u; j++) {
@@ -229,11 +229,11 @@
       if (c_min>cost) {
         c_min = cost;
         u_min = u;
-        if (st_output_verbosity_level >= 4) {
-          st_debug("c_min %d, [%d-%d]:",c_min,numer,denom);
+        if (sox_output_verbosity_level >= 4) {
+          sox_debug("c_min %d, [%d-%d]:",c_min,numer,denom);
           for (j=0; j<u; j++)
-            st_debug(" (%d,%d)",rate->m1[j],rate->m2[j]);
-          st_debug("");
+            sox_debug(" (%d,%d)",rate->m1[j],rate->m2[j]);
+          sox_debug("");
         }
         memcpy(rate->b1,rate->m1,u*sizeof(int));
         memcpy(rate->b2,rate->m2,u*sizeof(int));
@@ -263,7 +263,7 @@
   int N1;
 
   if(buffer == NULL || length <= 0)
-    st_fail("Illegal buffer %p or length %d to nuttall.", buffer, length);
+    sox_fail("Illegal buffer %p or length %d to nuttall.", buffer, length);
 
   /* Initial variable setups. */
   N = length;
@@ -286,7 +286,7 @@
     int N1;
 
     if(buffer == NULL || length <= 0)
-      st_fail("Illegal buffer %p or length %d to hamming.",buffer,length);
+      sox_fail("Illegal buffer %p or length %d to hamming.",buffer,length);
 
     N1 = length/2;
     for(j=0;j<length;j++)
@@ -312,7 +312,7 @@
     double sum;
 
     if(buffer == NULL || length < 0 || cutoff < 0 || cutoff > M_PI)
-      st_fail("Illegal buffer %p, length %d, or cutoff %f.",buffer,length,cutoff);
+      sox_fail("Illegal buffer %p, length %d, or cutoff %f.",buffer,length,cutoff);
 
     /* Use the user-option of window type */
     if (rate->win_type == 0)
@@ -320,12 +320,12 @@
     else
       hamming(buffer,length);  /* Design Hamming window:  43 dB cutoff */
 
-    /* st_debug("# fir_design length=%d, cutoff=%8.4f",length,cutoff); */
+    /* sox_debug("# fir_design length=%d, cutoff=%8.4f",length,cutoff); */
     /* Design filter:  windowed sinc function */
     sum = 0.0;
     for(j=0;j<length;j++) {
       buffer[j] *= sinc(M_PI*cutoff*(j-length/2)); /* center at length/2 */
-      /* st_debug("%.1f %.6f",(float)j,buffer[j]); */
+      /* sox_debug("%.1f %.6f",(float)j,buffer[j]); */
       sum += buffer[j];
     }
     sum = (double)1.0/sum;
@@ -333,12 +333,12 @@
     for(j=0;j<length;j++) {
       buffer[j] *= sum;
     }
-    /* st_debug("# end"); */
+    /* sox_debug("# end"); */
 }
 
 #define RIBLEN 2048
 
-static int st_poly_start(eff_t effp)
+static int sox_poly_start(eff_t effp)
 {
     poly_t rate = (poly_t) effp->priv;
     static int l1[MF], l2[MF];
@@ -347,10 +347,10 @@
     int k;
 
     if (effp->ininfo.rate == effp->outinfo.rate)
-      return ST_EFF_NULL;
+      return SOX_EFF_NULL;
 
-    rate->lcmrate = st_lcm((st_sample_t)effp->ininfo.rate,
-                           (st_sample_t)effp->outinfo.rate);
+    rate->lcmrate = sox_lcm((sox_sample_t)effp->ininfo.rate,
+                           (sox_sample_t)effp->outinfo.rate);
 
     /* Cursory check for LCM overflow.
      * If both rates are below 65k, there should be no problem.
@@ -372,9 +372,9 @@
     rate->total = total;
     /* l1 and l2 are now lists of the up/down factors for conversion */
 
-    st_debug("Poly:  input rate %d, output rate %d.  %d stages.",
+    sox_debug("Poly:  input rate %d, output rate %d.  %d stages.",
             effp->ininfo.rate, effp->outinfo.rate,total);
-    st_debug("Poly:  window: %s  size: %d  cutoff: %f.",
+    sox_debug("Poly:  window: %s  size: %d  cutoff: %f.",
             (rate->win_type == 0) ? ("nut") : ("ham"), rate->win_width, rate->cutoff);
 
     /* Create an array of filters and past history */
@@ -394,7 +394,7 @@
       s->size = size;
       s->hsize = f_len/s->up; /* this much of window is past-history */
       s->held = 0;
-      st_debug("Poly:  stage %d:  Up by %d, down by %d,  i_samps %d, hsize %d",
+      sox_debug("Poly:  stage %d:  Up by %d, down by %d,  i_samps %d, hsize %d",
               k+1,s->up,s->down,size, s->hsize);
       s->filt_len = f_len;
       s->filt_array = (Float *) xmalloc(sizeof(Float) * f_len);
@@ -404,7 +404,7 @@
         s->window[j] = 0.0;
 
       uprate *= s->up;
-      st_debug("Poly:         :  filt_len %d, cutoff freq %.1f",
+      sox_debug("Poly:         :  filt_len %d, cutoff freq %.1f",
               f_len, uprate * rate->cutoff / f_cutoff);
       uprate /= s->down;
       fir_design(rate, s->filt_array, f_len, rate->cutoff / f_cutoff);
@@ -427,8 +427,8 @@
       s->filt_array = NULL;
       s->window = (Float *) xmalloc(sizeof(Float) * size);
     }
-    st_debug("Poly:  output samples %d, oskip %d",size, rate->oskip);
-    return (ST_SUCCESS);
+    sox_debug("Poly:  output samples %d, oskip %d",size, rate->oskip);
+    return (SOX_SUCCESS);
 }
 
 /*
@@ -437,7 +437,7 @@
  */
 
 /* REMARK: putting this in a separate subroutine improves gcc's optimization */
-static double st_prod(const Float *q, int qstep, const Float *p, int n)
+static double sox_prod(const Float *q, int qstep, const Float *p, int n)
 {
   double sum = 0;
   const Float *p0;
@@ -461,16 +461,16 @@
   Float *o_top;
 
   in = s->window + s->hsize;
-  /*for (mm=0; mm<s->filt_len; mm++) st_debug("cf_%d %f",mm,s->filt_array[mm]);*/
+  /*for (mm=0; mm<s->filt_len; mm++) sox_debug("cf_%d %f",mm,s->filt_array[mm]);*/
   /* assumes s->size divisible by down (now true) */
   o_top = output + (s->size * up) / down;
-  /*st_debug(" isize %d, osize %d, up %d, down %d, N %d", s->size, o_top-output, up, down, f_len);*/
+  /*sox_debug(" isize %d, osize %d, up %d, down %d, N %d", s->size, o_top-output, up, down, f_len);*/
   for (mm=0, o=output; o < o_top; mm+=down, o++) {
     double sum;
     const Float *p, *q;
     q = s->filt_array + (mm%up);   /* decimated coef pointer */
     p  = in + (mm/up);
-    sum = st_prod(q, up, p, f_len/up);
+    sum = sox_prod(q, up, p, f_len/up);
     *o = sum * up;
   }
 }
@@ -486,18 +486,18 @@
 
 }
 
-static int st_poly_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
-                 st_size_t *isamp, st_size_t *osamp)
+static int sox_poly_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf,
+                 sox_size_t *isamp, sox_size_t *osamp)
 {
   poly_t rate = (poly_t) effp->priv;
   polystage *s0,*s1;
 
   /* Sanity check:  how much can we tolerate? */
-  /* st_debug("*isamp=%d *osamp=%d",*isamp,*osamp); */
+  /* sox_debug("*isamp=%d *osamp=%d",*isamp,*osamp); */
   s0 = rate->stage[0];            /* the first stage */
   s1 = rate->stage[rate->total];  /* the 'last' stage is output buffer */
   {
-    st_size_t in_size, gap, k;
+    sox_size_t in_size, gap, k;
 
     in_size = *isamp;
     gap = s0->size - s0->held; /* space available in this 'input' buffer */
@@ -521,7 +521,7 @@
   }
 
   if (s0->held == s0->size && s1->held == 0) {
-    st_size_t k;
+    sox_size_t k;
     /* input buffer full, output buffer empty, so do process */
 
     for(k=0; k<rate->total; k++) {
@@ -532,7 +532,7 @@
 
       out = rate->stage[k+1]->window + rate->stage[k+1]->hsize;
 
-      /* st_debug("k=%d  insize=%d",k,in_size); */
+      /* sox_debug("k=%d  insize=%d",k,in_size); */
       polyphase(out, s);
 
       /* copy input history into lower portion of rate->window[k] */
@@ -546,11 +546,11 @@
   }
 
   {
-    st_sample_t *q;
-    st_size_t out_size;
-    st_size_t oskip;
+    sox_sample_t *q;
+    sox_size_t out_size;
+    sox_size_t oskip;
     Float *out_buf;
-    st_size_t k;
+    sox_size_t k;
 
     oskip = rate->oskip;
                 out_size = s1->held;
@@ -566,7 +566,7 @@
     {
         float f;
         f = out_buf[k] * ISCALE; /* should clip-limit */
-        ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+        SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
         *q++ = f;
     }
 
@@ -582,7 +582,7 @@
     }
 
   }
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 
 }
 
@@ -589,12 +589,12 @@
 /*
  * Process tail of input samples.
  */
-static int st_poly_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_poly_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
-  st_size_t in_size;
+  sox_size_t in_size;
   /* Call "flow" with NULL input. */
-  st_poly_flow(effp, NULL, obuf, &in_size, osamp);
-  return (ST_SUCCESS);
+  sox_poly_flow(effp, NULL, obuf, &in_size, osamp);
+  return (SOX_SUCCESS);
 }
 
 /*
@@ -601,10 +601,10 @@
  * Do anything required when you stop reading samples.
  * Don't close input file!
  */
-static int st_poly_stop(eff_t effp)
+static int sox_poly_stop(eff_t effp)
 {
     poly_t rate = (poly_t)effp->priv;
-    st_size_t k;
+    sox_size_t k;
 
     for (k = 0; k <= rate->total; k++) {
       free(rate->stage[k]->window);
@@ -612,25 +612,25 @@
       free(rate->stage[k]);
     }
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
-static st_effect_t st_polyphase_effect = {
+static sox_effect_t sox_polyphase_effect = {
   "polyphase",
   "Usage: -w {nut|ham}   window type\n"
   "       -width n       window width in samples [default 1024]\n"
   "\n"
   "       -cutoff float  frequency cutoff for base bandwidth [default 0.95]",
-  ST_EFF_RATE,
-  st_poly_getopts,
-  st_poly_start,
-  st_poly_flow,
-  st_poly_drain,
-  st_poly_stop,
-  st_effect_nothing
+  SOX_EFF_RATE,
+  sox_poly_getopts,
+  sox_poly_start,
+  sox_poly_flow,
+  sox_poly_drain,
+  sox_poly_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_polyphase_effect_fn(void)
+const sox_effect_t *sox_polyphase_effect_fn(void)
 {
-    return &st_polyphase_effect;
+    return &sox_polyphase_effect;
 }
--- a/src/prc.c
+++ b/src/prc.c
@@ -50,7 +50,7 @@
  ******************************************************************/
 
  
-#include "st_i.h"
+#include "sox_i.h"
 
 #include "adpcms.h"
 
@@ -63,7 +63,7 @@
   uint32_t nsamp, nbytes;
   short padding;
   short repeats;
-  st_size_t data_start;         /* for seeking */
+  sox_size_t data_start;         /* for seeking */
   struct adpcm_io adpcm;
   unsigned frame_samp;     /* samples left to read in current frame */
 } *prc_t;
@@ -107,16 +107,16 @@
 
 int prc_checkheader(ft_t ft, char *head)
 {
-  st_readbuf(ft, head, 1, sizeof(prc_header));
+  sox_readbuf(ft, head, 1, sizeof(prc_header));
   return memcmp(head, prc_header, sizeof(prc_header)) == 0;
 }
 
 static void prcwriteheader(ft_t ft);
 
-static int seek(ft_t ft, st_size_t offset)
+static int seek(ft_t ft, sox_size_t offset)
 {
   prc_t prc = (prc_t)ft->priv;
-  st_size_t new_offset, channel_block, alignment;
+  sox_size_t new_offset, channel_block, alignment;
 
   new_offset = offset * ft->signal.size;
   /* Make sure request aligns to a channel block (i.e. left+right) */
@@ -130,7 +130,7 @@
     new_offset += (channel_block - alignment);
   new_offset += prc->data_start;
 
-  return st_seeki(ft, new_offset, SEEK_SET);
+  return sox_seeki(ft, new_offset, SEEK_SET);
 }
 
 static int startread(ft_t ft)
@@ -145,83 +145,83 @@
 
   /* Check the header */
   if (prc_checkheader(ft, head))
-    st_debug("Found Psion Record header");
+    sox_debug("Found Psion Record header");
   else {
-      st_fail_errno(ft,ST_EHDR,"Not a Psion Record file");
-      return (ST_EOF);
+      sox_fail_errno(ft,SOX_EHDR,"Not a Psion Record file");
+      return (SOX_EOF);
   }
 
-  st_readb(ft, &byte);
+  sox_readb(ft, &byte);
   if ((byte & 0x3) != 0x2) {
-    st_fail_errno(ft, ST_EHDR, "Invalid length byte for application name string %d", (int)(byte));
-    return ST_EOF;
+    sox_fail_errno(ft, SOX_EHDR, "Invalid length byte for application name string %d", (int)(byte));
+    return SOX_EOF;
   }
 
   byte >>= 2;
   assert(byte < 64);
-  st_reads(ft, appname, byte);
+  sox_reads(ft, appname, byte);
   if (strncasecmp(appname, "record.app", byte) != 0) {
-    st_fail_errno(ft, ST_EHDR, "Invalid application name string %.63s", appname);
-    return ST_EOF;
+    sox_fail_errno(ft, SOX_EHDR, "Invalid application name string %.63s", appname);
+    return SOX_EOF;
   }
         
-  st_readdw(ft, &len);
+  sox_readdw(ft, &len);
   p->nsamp = len;
-  st_debug("Number of samples: %d", len);
+  sox_debug("Number of samples: %d", len);
 
-  st_readdw(ft, &encoding);
-  st_debug("Encoding of samples: %x", encoding);
+  sox_readdw(ft, &encoding);
+  sox_debug("Encoding of samples: %x", encoding);
   if (encoding == 0)
-    ft->signal.encoding = ST_ENCODING_ALAW;
+    ft->signal.encoding = SOX_ENCODING_ALAW;
   else if (encoding == 0x100001a1)
-    ft->signal.encoding = ST_ENCODING_IMA_ADPCM;
+    ft->signal.encoding = SOX_ENCODING_IMA_ADPCM;
   else {
-    st_fail_errno(ft, ST_EHDR, "Unrecognised encoding");
-    return ST_EOF;
+    sox_fail_errno(ft, SOX_EHDR, "Unrecognised encoding");
+    return SOX_EOF;
   }
 
-  st_readw(ft, &reps);    /* Number of repeats */
-  st_debug("Repeats: %d", reps);
+  sox_readw(ft, &reps);    /* Number of repeats */
+  sox_debug("Repeats: %d", reps);
         
-  st_readb(ft, &volume);
-  st_debug("Volume: %d", (unsigned)volume);
+  sox_readb(ft, &volume);
+  sox_debug("Volume: %d", (unsigned)volume);
   if (volume < 1 || volume > 5)
-    st_warn("Volume %d outside range 1..5", volume);
+    sox_warn("Volume %d outside range 1..5", volume);
 
-  st_readb(ft, &byte);   /* Unused and seems always zero */
+  sox_readb(ft, &byte);   /* Unused and seems always zero */
 
-  st_readdw(ft, &repgap); /* Time between repeats in usec */
-  st_debug("Time between repeats (usec): %ld", repgap);
+  sox_readdw(ft, &repgap); /* Time between repeats in usec */
+  sox_debug("Time between repeats (usec): %ld", repgap);
 
-  st_readdw(ft, &listlen); /* Length of samples list */
-  st_debug("Number of bytes in samples list: %ld", listlen);
+  sox_readdw(ft, &listlen); /* Length of samples list */
+  sox_debug("Number of bytes in samples list: %ld", listlen);
 
   if (ft->signal.rate != 0 && ft->signal.rate != 8000)
-    st_report("PRC only supports 8 kHz; overriding.");
+    sox_report("PRC only supports 8 kHz; overriding.");
   ft->signal.rate = 8000;
 
   if (ft->signal.channels != 1 && ft->signal.channels != 0)
-    st_report("PRC only supports 1 channel; overriding.");
+    sox_report("PRC only supports 1 channel; overriding.");
   ft->signal.channels = 1;
 
-  p->data_start = st_tell(ft);
+  p->data_start = sox_tell(ft);
   ft->length = p->nsamp / ft->signal.channels;
 
-  if (ft->signal.encoding == ST_ENCODING_ALAW) {
-    ft->signal.size = ST_SIZE_BYTE;
-    if (st_rawstartread(ft))
-      return ST_EOF;
-  } else if (ft->signal.encoding == ST_ENCODING_IMA_ADPCM) {
+  if (ft->signal.encoding == SOX_ENCODING_ALAW) {
+    ft->signal.size = SOX_SIZE_BYTE;
+    if (sox_rawstartread(ft))
+      return SOX_EOF;
+  } else if (ft->signal.encoding == SOX_ENCODING_IMA_ADPCM) {
     p->frame_samp = 0;
-    if (st_adpcm_ima_start(ft, &p->adpcm))
-      return ST_EOF;
+    if (sox_adpcm_ima_start(ft, &p->adpcm))
+      return SOX_EOF;
   }
 
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 /* Read a variable-length encoded count */
-/* Ignore return code of st_readb, as it doesn't really matter if EOF
+/* Ignore return code of sox_readb, as it doesn't really matter if EOF
    is delayed until the caller. */
 static unsigned read_cardinal(ft_t ft)
 {
@@ -228,27 +228,27 @@
   unsigned a;
   uint8_t byte;
 
-  if (st_readb(ft, &byte) == ST_EOF)
-    return (unsigned)ST_EOF;
-  st_debug_more("Cardinal byte 1: %x", byte);
+  if (sox_readb(ft, &byte) == SOX_EOF)
+    return (unsigned)SOX_EOF;
+  sox_debug_more("Cardinal byte 1: %x", byte);
   a = byte;
   if (!(a & 1))
     a >>= 1;
   else {
-    if (st_readb(ft, &byte) == ST_EOF)
-      return (unsigned)ST_EOF;
-    st_debug_more("Cardinal byte 2: %x", byte);
+    if (sox_readb(ft, &byte) == SOX_EOF)
+      return (unsigned)SOX_EOF;
+    sox_debug_more("Cardinal byte 2: %x", byte);
     a |= byte << 8;
     if (!(a & 2))
       a >>= 2;
     else if (!(a & 4)) {
-      if (st_readb(ft, &byte) == ST_EOF)
-        return (unsigned)ST_EOF;
-      st_debug_more("Cardinal byte 3: %x", byte);
+      if (sox_readb(ft, &byte) == SOX_EOF)
+        return (unsigned)SOX_EOF;
+      sox_debug_more("Cardinal byte 3: %x", byte);
       a |= byte << 16;
-      if (st_readb(ft, &byte) == ST_EOF)
-        return (unsigned)ST_EOF;
-      st_debug_more("Cardinal byte 4: %x", byte);
+      if (sox_readb(ft, &byte) == SOX_EOF)
+        return (unsigned)SOX_EOF;
+      sox_debug_more("Cardinal byte 4: %x", byte);
       a |= byte << 24;
       a >>= 3;
     }
@@ -257,43 +257,43 @@
   return a;
 }
 
-static st_size_t read(ft_t ft, st_sample_t *buf, st_size_t samp)
+static sox_size_t read(ft_t ft, sox_sample_t *buf, sox_size_t samp)
 {
   prc_t p = (prc_t)ft->priv;
 
-  st_debug_more("length now = %d", p->nsamp);
+  sox_debug_more("length now = %d", p->nsamp);
 
-  if (ft->signal.encoding == ST_ENCODING_IMA_ADPCM) {
-    st_size_t nsamp, read;
+  if (ft->signal.encoding == SOX_ENCODING_IMA_ADPCM) {
+    sox_size_t nsamp, read;
 
     if (p->frame_samp == 0) {
       unsigned framelen = read_cardinal(ft);
       uint32_t trash;
 
-      if (framelen == (unsigned)ST_EOF)
+      if (framelen == (unsigned)SOX_EOF)
         return 0;
 
-      st_debug_more("frame length %d", framelen);
+      sox_debug_more("frame length %d", framelen);
       p->frame_samp = framelen;
 
       /* Discard length of compressed data */
-      st_debug_more("compressed length %d", read_cardinal(ft));
+      sox_debug_more("compressed length %d", read_cardinal(ft));
       /* Discard length of BListL */
-      st_readdw(ft, &trash);
-      st_debug_more("list length %d", trash);
+      sox_readdw(ft, &trash);
+      sox_debug_more("list length %d", trash);
 
       /* Reset CODEC for start of frame */
-      st_adpcm_reset(&p->adpcm, ft->signal.encoding);
+      sox_adpcm_reset(&p->adpcm, ft->signal.encoding);
     }
     nsamp = min(p->frame_samp, samp);
     p->nsamp += nsamp;
-    read = st_adpcm_read(ft, &p->adpcm, buf, nsamp);
+    read = sox_adpcm_read(ft, &p->adpcm, buf, nsamp);
     p->frame_samp -= read;
-    st_debug_more("samples left in this frame: %d", p->frame_samp);
+    sox_debug_more("samples left in this frame: %d", p->frame_samp);
     return read;
   } else {
     p->nsamp += samp;
-    return st_rawread(ft, buf, samp);
+    return sox_rawread(ft, buf, samp);
   }
 }
 
@@ -301,10 +301,10 @@
 {
   prc_t p = (prc_t)ft->priv;
 
-  if (ft->signal.encoding == ST_ENCODING_IMA_ADPCM)
-    return st_adpcm_stopread(ft, &p->adpcm);
+  if (ft->signal.encoding == SOX_ENCODING_IMA_ADPCM)
+    return sox_adpcm_stopread(ft, &p->adpcm);
   else
-    return st_rawstopread(ft);
+    return sox_rawstopread(ft);
 }
 
 /* When writing, the header is supposed to contain the number of
@@ -320,18 +320,18 @@
 {
   prc_t p = (prc_t)ft->priv;
 
-  if (ft->signal.encoding != ST_ENCODING_ALAW &&
-      ft->signal.encoding != ST_ENCODING_IMA_ADPCM) {
-    st_report("PRC only supports A-law and ADPCM encoding; choosing A-law");
-    ft->signal.encoding = ST_ENCODING_ALAW;
+  if (ft->signal.encoding != SOX_ENCODING_ALAW &&
+      ft->signal.encoding != SOX_ENCODING_IMA_ADPCM) {
+    sox_report("PRC only supports A-law and ADPCM encoding; choosing A-law");
+    ft->signal.encoding = SOX_ENCODING_ALAW;
   }
         
-  if (ft->signal.encoding == ST_ENCODING_ALAW) {
-    if (st_rawstartwrite(ft))
-      return ST_EOF;
-  } else if (ft->signal.encoding == ST_ENCODING_IMA_ADPCM) {
-    if (st_adpcm_ima_start(ft, &p->adpcm))
-      return ST_EOF;
+  if (ft->signal.encoding == SOX_ENCODING_ALAW) {
+    if (sox_rawstartwrite(ft))
+      return SOX_EOF;
+  } else if (ft->signal.encoding == SOX_ENCODING_IMA_ADPCM) {
+    if (sox_adpcm_ima_start(ft, &p->adpcm))
+      return SOX_EOF;
   }
         
   p->nsamp = 0;
@@ -340,20 +340,20 @@
     p->repeats = 1;
 
   if (ft->signal.rate != 0 && ft->signal.rate != 8000)
-    st_report("PRC only supports 8 kHz sample rate; overriding.");
+    sox_report("PRC only supports 8 kHz sample rate; overriding.");
   ft->signal.rate = 8000;
 
   if (ft->signal.channels != 1 && ft->signal.channels != 0)
-    st_report("PRC only supports 1 channel; overriding.");
+    sox_report("PRC only supports 1 channel; overriding.");
   ft->signal.channels = 1;
 
-  ft->signal.size = ST_SIZE_BYTE;
+  ft->signal.size = SOX_SIZE_BYTE;
 
   prcwriteheader(ft);
 
-  p->data_start = st_tell(ft);
+  p->data_start = sox_tell(ft);
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static void write_cardinal(ft_t ft, unsigned a)
@@ -362,53 +362,53 @@
 
   if (a < 0x80) {
     byte = a << 1;
-    st_debug_more("Cardinal byte 1: %x", byte);
-    st_writeb(ft, byte);
+    sox_debug_more("Cardinal byte 1: %x", byte);
+    sox_writeb(ft, byte);
   } else if (a < 0x8000) {
     byte = (a << 2) | 1;
-    st_debug_more("Cardinal byte 1: %x", byte);
-    st_writeb(ft, byte);
+    sox_debug_more("Cardinal byte 1: %x", byte);
+    sox_writeb(ft, byte);
     byte = a >> 6;
-    st_debug_more("Cardinal byte 2: %x", byte);
-    st_writeb(ft, byte);
+    sox_debug_more("Cardinal byte 2: %x", byte);
+    sox_writeb(ft, byte);
   } else {
     byte = (a << 3) | 3;
-    st_debug_more("Cardinal byte 1: %x", byte);
-    st_writeb(ft, byte);
+    sox_debug_more("Cardinal byte 1: %x", byte);
+    sox_writeb(ft, byte);
     byte = a >> 5;
-    st_debug_more("Cardinal byte 2: %x", byte);
-    st_writeb(ft, byte);
+    sox_debug_more("Cardinal byte 2: %x", byte);
+    sox_writeb(ft, byte);
     byte = a >> 13;
-    st_debug_more("Cardinal byte 3: %x", byte);
-    st_writeb(ft, byte);
+    sox_debug_more("Cardinal byte 3: %x", byte);
+    sox_writeb(ft, byte);
     byte = a >> 21;
-    st_debug_more("Cardinal byte 4: %x", byte);
-    st_writeb(ft, byte);
+    sox_debug_more("Cardinal byte 4: %x", byte);
+    sox_writeb(ft, byte);
   }
 }
 
-static st_size_t write(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static sox_size_t write(ft_t ft, const sox_sample_t *buf, sox_size_t samp)
 {
   prc_t p = (prc_t)ft->priv;
   /* Psion Record seems not to be able to handle frames > 800 samples */
   samp = min(samp, 800);
   p->nsamp += samp;
-  st_debug_more("length now = %d", p->nsamp);
-  if (ft->signal.encoding == ST_ENCODING_IMA_ADPCM) {
-    st_size_t written;
+  sox_debug_more("length now = %d", p->nsamp);
+  if (ft->signal.encoding == SOX_ENCODING_IMA_ADPCM) {
+    sox_size_t written;
 
     write_cardinal(ft, samp);
     /* Write compressed length */
     write_cardinal(ft, (samp / 2) + (samp % 2) + 4);
     /* Write length again (seems to be a BListL) */
-    st_debug_more("list length %d", samp);
-    st_writedw(ft, samp);
-    st_adpcm_reset(&p->adpcm, ft->signal.encoding);
-    written = st_adpcm_write(ft, &p->adpcm, buf, samp);
-    st_adpcm_flush(ft, &p->adpcm);
+    sox_debug_more("list length %d", samp);
+    sox_writedw(ft, samp);
+    sox_adpcm_reset(&p->adpcm, ft->signal.encoding);
+    written = sox_adpcm_write(ft, &p->adpcm, buf, samp);
+    sox_adpcm_flush(ft, &p->adpcm);
     return written;
   } else
-    return st_rawwrite(ft, buf, samp);
+    return sox_rawwrite(ft, buf, samp);
 }
 
 static int stopwrite(ft_t ft)
@@ -416,22 +416,22 @@
   prc_t p = (prc_t)ft->priv;
 
   /* Call before seeking to flush buffer (ADPCM has already been flushed) */
-  if (ft->signal.encoding != ST_ENCODING_IMA_ADPCM)
-    st_rawstopwrite(ft);
+  if (ft->signal.encoding != SOX_ENCODING_IMA_ADPCM)
+    sox_rawstopwrite(ft);
 
-  p->nbytes = st_tell(ft) - p->data_start;
+  p->nbytes = sox_tell(ft) - p->data_start;
 
   if (!ft->seekable) {
-      st_warn("Header will have invalid file length since file is not seekable");
-      return ST_SUCCESS;
+      sox_warn("Header will have invalid file length since file is not seekable");
+      return SOX_SUCCESS;
   }
 
-  if (st_seeki(ft, 0, 0) != 0) {
-      st_fail_errno(ft,errno,"Can't rewind output file to rewrite Psion header.");
-      return(ST_EOF);
+  if (sox_seeki(ft, 0, 0) != 0) {
+      sox_fail_errno(ft,errno,"Can't rewind output file to rewrite Psion header.");
+      return(SOX_EOF);
   }
   prcwriteheader(ft);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static void prcwriteheader(ft_t ft)
@@ -438,24 +438,24 @@
 {
   prc_t p = (prc_t)ft->priv;
 
-  st_writebuf(ft, prc_header, 1, sizeof(prc_header));
-  st_writes(ft, "\x2arecord.app");
+  sox_writebuf(ft, prc_header, 1, sizeof(prc_header));
+  sox_writes(ft, "\x2arecord.app");
 
-  st_debug("Number of samples: %d",p->nsamp);
-  st_writedw(ft, p->nsamp);
+  sox_debug("Number of samples: %d",p->nsamp);
+  sox_writedw(ft, p->nsamp);
 
-  if (ft->signal.encoding == ST_ENCODING_ALAW)
-    st_writedw(ft, 0);
+  if (ft->signal.encoding == SOX_ENCODING_ALAW)
+    sox_writedw(ft, 0);
   else
-    st_writedw(ft, 0x100001a1); /* ADPCM */
+    sox_writedw(ft, 0x100001a1); /* ADPCM */
   
-  st_writew(ft, 0);             /* Number of repeats */
-  st_writeb(ft, 3);             /* Volume: use default value of Record.app */
-  st_writeb(ft, 0);             /* Unused and seems always zero */
-  st_writedw(ft, 0);            /* Time between repeats in usec */
+  sox_writew(ft, 0);             /* Number of repeats */
+  sox_writeb(ft, 3);             /* Volume: use default value of Record.app */
+  sox_writeb(ft, 0);             /* Unused and seems always zero */
+  sox_writedw(ft, 0);            /* Time between repeats in usec */
 
-  st_debug("Number of bytes: %d", p->nbytes);
-  st_writedw(ft, p->nbytes);    /* Number of bytes of data */
+  sox_debug("Number of bytes: %d", p->nbytes);
+  sox_writedw(ft, p->nbytes);    /* Number of bytes of data */
 }
 
 /* Psion .prc */
@@ -464,10 +464,10 @@
   NULL
 };
 
-static st_format_t st_prc_format = {
+static sox_format_t sox_prc_format = {
   prcnames,
   NULL,
-  ST_FILE_SEEK | ST_FILE_LIT_END,
+  SOX_FILE_SEEK | SOX_FILE_LIT_END,
   startread,
   read,
   stopread,
@@ -477,7 +477,7 @@
   seek
 };
 
-const st_format_t *st_prc_format_fn(void)
+const sox_format_t *sox_prc_format_fn(void)
 {
-  return &st_prc_format;
+  return &sox_prc_format;
 }
--- a/src/rabbit.c
+++ b/src/rabbit.c
@@ -22,7 +22,7 @@
    had global clipping detection, rabbit used to do its own based on
    sndfile-resample. */
  
-#include "st_i.h"
+#include "sox_i.h"
 
 #ifdef HAVE_SAMPLERATE_H
 
@@ -32,7 +32,7 @@
 #include <math.h>
 #include <samplerate.h>
 
-static st_effect_t st_rabbit_effect;
+static sox_effect_t sox_rabbit_effect;
 
 /* Private data for resampling */
 typedef struct {
@@ -39,14 +39,14 @@
   int converter_type;           /* SRC converter type */
   SRC_STATE *state;             /* SRC state struct */
   SRC_DATA *data;               /* SRC_DATA control struct */
-  st_size_t samples;            /* Number of samples read so far */
-  st_size_t outsamp;            /* Next output sample */
+  sox_size_t samples;            /* Number of samples read so far */
+  sox_size_t outsamp;            /* Next output sample */
 } *rabbit_t;
 
 /*
  * Process options
  */
-static int st_rabbit_getopts(eff_t effp, int n, char **argv)
+static int sox_rabbit_getopts(eff_t effp, int n, char **argv)
 {
   rabbit_t r = (rabbit_t) effp->priv;
 
@@ -72,32 +72,32 @@
   }
 
   if (n >= 1) {
-    st_fail(st_rabbit_effect.usage);
-    return ST_EOF;
+    sox_fail(sox_rabbit_effect.usage);
+    return SOX_EOF;
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
  * Prepare processing.
  */
-static int st_rabbit_start(eff_t effp)
+static int sox_rabbit_start(eff_t effp)
 {
   rabbit_t r = (rabbit_t) effp->priv;
 
   /* The next line makes the "speed" effect accurate; it's needed because
-   * ininfo.rate (st_rate_t) isn't floating point (but it's probably not worth
-   * changing st_rate_t just because of this): */
+   * ininfo.rate (sox_rate_t) isn't floating point (but it's probably not worth
+   * changing sox_rate_t just because of this): */
   double in_rate = floor(effp->ininfo.rate / effp->globalinfo->speed + .5)
     * effp->globalinfo->speed;
 
   if (in_rate == effp->outinfo.rate)
-    return ST_EFF_NULL;
+    return SOX_EFF_NULL;
           
   if (effp->ininfo.channels != effp->outinfo.channels) {
-    st_fail("number of Input and Output channels must be equal to use rabbit effect");
-    return ST_EOF;
+    sox_fail("number of Input and Output channels must be equal to use rabbit effect");
+    return SOX_EOF;
   }
 
   r->data = (SRC_DATA *)xcalloc(1, sizeof(SRC_DATA));
@@ -105,29 +105,29 @@
   r->data->input_frames_used = 0;
   r->data->output_frames_gen = 0;
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
  * Read all the data.
  */
-static int st_rabbit_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf UNUSED,
-                   st_size_t *isamp, st_size_t *osamp)
+static int sox_rabbit_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf UNUSED,
+                   sox_size_t *isamp, sox_size_t *osamp)
 {
   rabbit_t r = (rabbit_t) effp->priv;
   int channels = effp->ininfo.channels;
-  st_size_t i, newsamples;
+  sox_size_t i, newsamples;
 
   newsamples = r->samples + *isamp;
   if (newsamples / channels > INT_MAX) {
-      st_fail("input data size %d too large for libsamplerate", newsamples);
-      return ST_EOF;
+      sox_fail("input data size %d too large for libsamplerate", newsamples);
+      return SOX_EOF;
   }
 
   r->data->data_in = (float *)xrealloc(r->data->data_in, newsamples * sizeof(float));
 
   for (i = 0 ; i < *isamp; i++)
-    r->data->data_in[r->samples + i] = ST_SAMPLE_TO_FLOAT_DWORD(ibuf[i], effp->clips);
+    r->data->data_in[r->samples + i] = SOX_SAMPLE_TO_FLOAT_DWORD(ibuf[i], effp->clips);
 
   r->samples = newsamples;
   r->data->input_frames = r->samples / channels;
@@ -135,27 +135,27 @@
 
   *osamp = 0;           /* Signal that we didn't produce any output */
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
  * Process samples and write output.
  */
-static int st_rabbit_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_rabbit_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
   rabbit_t r = (rabbit_t) effp->priv;
   int channels = effp->ininfo.channels;
-  st_size_t i, outsamps;
+  sox_size_t i, outsamps;
 
   /* On first call, process the data */
   if (r->data->data_out == NULL) {
     /* Guess maximum number of possible output frames */
-    st_size_t outframes = r->data->input_frames * (r->data->src_ratio + 0.01) + 8;
+    sox_size_t outframes = r->data->input_frames * (r->data->src_ratio + 0.01) + 8;
     int error;
 
     if (outframes > INT_MAX) {
-      st_fail("too many output frames (%d) for libsamplerate", outframes);
-      return ST_EOF;
+      sox_fail("too many output frames (%d) for libsamplerate", outframes);
+      return SOX_EOF;
     }
     r->data->output_frames = outframes;
     r->data->data_out = (float *)xmalloc(r->data->output_frames * channels * sizeof(float));
@@ -162,24 +162,24 @@
 
     /* Process the data */
     if ((error = src_simple(r->data, r->converter_type, channels))) {
-      st_fail("libsamplerate processing failed: %s", src_strerror(error));
-      return ST_EOF;
+      sox_fail("libsamplerate processing failed: %s", src_strerror(error));
+      return SOX_EOF;
     }
   }
 
   /* Return the data one bufferful at a time */
   if (*osamp > INT_MAX) {
-    st_fail("output buffer size %d too large for libsamplerate", *osamp);
-    return ST_EOF;
+    sox_fail("output buffer size %d too large for libsamplerate", *osamp);
+    return SOX_EOF;
   }
 
   outsamps = min(r->data->output_frames_gen * channels - r->outsamp, *osamp);
   for (i = 0; i < outsamps; i++)
-    obuf[i] = ST_FLOAT_DWORD_TO_SAMPLE(r->data->data_out[r->outsamp + i], effp->clips);
-  *osamp = (st_size_t)outsamps;
+    obuf[i] = SOX_FLOAT_DWORD_TO_SAMPLE(r->data->data_out[r->outsamp + i], effp->clips);
+  *osamp = (sox_size_t)outsamps;
   r->outsamp += outsamps;
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
@@ -186,30 +186,30 @@
  * Do anything required when you stop reading samples.
  * Don't close input file!
  */
-static int st_rabbit_stop(eff_t effp)
+static int sox_rabbit_stop(eff_t effp)
 {
   rabbit_t r = (rabbit_t) effp->priv;
 
   free(r->data);
   src_delete(r->state);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static st_effect_t st_rabbit_effect = {
+static sox_effect_t sox_rabbit_effect = {
   "rabbit",
   "Usage: rabbit [ -c0 | -c1 | -c2 | -c3 | -c4 ]",
-  ST_EFF_RATE | ST_EFF_MCHAN,
-  st_rabbit_getopts,
-  st_rabbit_start,
-  st_rabbit_flow,
-  st_rabbit_drain,
-  st_rabbit_stop,
-  st_effect_nothing
+  SOX_EFF_RATE | SOX_EFF_MCHAN,
+  sox_rabbit_getopts,
+  sox_rabbit_start,
+  sox_rabbit_flow,
+  sox_rabbit_drain,
+  sox_rabbit_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_rabbit_effect_fn(void)
+const sox_effect_t *sox_rabbit_effect_fn(void)
 {
-  return &st_rabbit_effect;
+  return &sox_rabbit_effect;
 }
 
 #endif /* HAVE_SAMPLERATE */
--- a/src/rate.c
+++ b/src/rate.c
@@ -5,28 +5,28 @@
  * backwards compatibility.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
  
-int st_resample_getopts(eff_t effp, int n, char **argv);
-int st_resample_start(eff_t effp);
-int st_resample_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                     st_size_t *isamp, st_size_t *osamp);
-int st_resample_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
-int st_resample_stop(eff_t effp);
+int sox_resample_getopts(eff_t effp, int n, char **argv);
+int sox_resample_start(eff_t effp);
+int sox_resample_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                     sox_size_t *isamp, sox_size_t *osamp);
+int sox_resample_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp);
+int sox_resample_stop(eff_t effp);
 
-static st_effect_t st_rate_effect = {
+static sox_effect_t sox_rate_effect = {
   "rate",
   "Usage: Rate effect takes no options",
-  ST_EFF_RATE | ST_EFF_DEPRECATED,
-  st_resample_getopts,
-  st_resample_start,
-  st_resample_flow,
-  st_resample_drain,
-  st_resample_stop,
-  st_effect_nothing
+  SOX_EFF_RATE | SOX_EFF_DEPRECATED,
+  sox_resample_getopts,
+  sox_resample_start,
+  sox_resample_flow,
+  sox_resample_drain,
+  sox_resample_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_rate_effect_fn(void)
+const sox_effect_t *sox_rate_effect_fn(void)
 {
-    return &st_rate_effect;
+    return &sox_rate_effect;
 }
--- a/src/raw.c
+++ b/src/raw.c
@@ -9,7 +9,7 @@
  * the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "g711.h"
 
 #include <string.h>
@@ -16,25 +16,25 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#define ST_ULAW_BYTE_TO_SAMPLE(d,clips)   ST_SIGNED_WORD_TO_SAMPLE(st_ulaw2linear16(d),clips)
-#define ST_ALAW_BYTE_TO_SAMPLE(d,clips)   ST_SIGNED_WORD_TO_SAMPLE(st_alaw2linear16(d),clips)
-#define ST_SAMPLE_TO_ULAW_BYTE(d,c) st_14linear2ulaw(ST_SAMPLE_TO_SIGNED_WORD(d,c) >> 2)
-#define ST_SAMPLE_TO_ALAW_BYTE(d,c) st_13linear2alaw(ST_SAMPLE_TO_SIGNED_WORD(d,c) >> 3)
+#define SOX_ULAW_BYTE_TO_SAMPLE(d,clips)   SOX_SIGNED_WORD_TO_SAMPLE(sox_ulaw2linear16(d),clips)
+#define SOX_ALAW_BYTE_TO_SAMPLE(d,clips)   SOX_SIGNED_WORD_TO_SAMPLE(sox_alaw2linear16(d),clips)
+#define SOX_SAMPLE_TO_ULAW_BYTE(d,c) sox_14linear2ulaw(SOX_SAMPLE_TO_SIGNED_WORD(d,c) >> 2)
+#define SOX_SAMPLE_TO_ALAW_BYTE(d,c) sox_13linear2alaw(SOX_SAMPLE_TO_SIGNED_WORD(d,c) >> 3)
 
-int st_rawseek(ft_t ft, st_size_t offset)
+int sox_rawseek(ft_t ft, sox_size_t offset)
 {
-    st_size_t new_offset, channel_block, alignment;
+    sox_size_t new_offset, channel_block, alignment;
 
     switch(ft->signal.size) {
-        case ST_SIZE_BYTE:
-        case ST_SIZE_16BIT:
-        case ST_SIZE_24BIT:
-        case ST_SIZE_32BIT:
-        case ST_SIZE_64BIT:
+        case SOX_SIZE_BYTE:
+        case SOX_SIZE_16BIT:
+        case SOX_SIZE_24BIT:
+        case SOX_SIZE_32BIT:
+        case SOX_SIZE_64BIT:
             break;
         default:
-            st_fail_errno(ft,ST_ENOTSUP,"Can't seek this data size");
-            return ft->st_errno;
+            sox_fail_errno(ft,SOX_ENOTSUP,"Can't seek this data size");
+            return ft->sox_errno;
     }
 
     new_offset = offset * ft->signal.size;
@@ -48,30 +48,30 @@
     if (alignment != 0)
         new_offset += (channel_block - alignment);
 
-    ft->st_errno = st_seeki(ft, new_offset, SEEK_SET);
+    ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
 
-    return ft->st_errno;
+    return ft->sox_errno;
 }
 
-/* Works nicely for starting read and write; st_rawstart{read,write}
-   are #defined in st_i.h */
-int st_rawstart(ft_t ft, st_bool default_rate, st_bool default_channels, st_encoding_t encoding, signed char size, st_option_t rev_bits)
+/* Works nicely for starting read and write; sox_rawstart{read,write}
+   are #defined in sox_i.h */
+int sox_rawstart(ft_t ft, sox_bool default_rate, sox_bool default_channels, sox_encoding_t encoding, signed char size, sox_option_t rev_bits)
 {
   if (default_rate && ft->signal.rate == 0) {
-    st_warn("'%s': sample rate not specified; trying 8kHz", ft->filename);
+    sox_warn("'%s': sample rate not specified; trying 8kHz", ft->filename);
     ft->signal.rate = 8000;
   }
 
   if (default_channels && ft->signal.channels == 0) {
-    st_warn("'%s': # channels not specified; trying mono", ft->filename);
+    sox_warn("'%s': # channels not specified; trying mono", ft->filename);
     ft->signal.channels = 1;
   }
 
-  if (encoding != ST_ENCODING_UNKNOWN) {
+  if (encoding != SOX_ENCODING_UNKNOWN) {
     if (ft->mode == 'r' &&
-        ft->signal.encoding != ST_ENCODING_UNKNOWN &&
+        ft->signal.encoding != SOX_ENCODING_UNKNOWN &&
         ft->signal.encoding != encoding)
-      st_report("'%s': Format options overriding file-type encoding", ft->filename);
+      sox_report("'%s': Format options overriding file-type encoding", ft->filename);
     else ft->signal.encoding = encoding;
   }
 
@@ -78,33 +78,33 @@
   if (size != -1) {
     if (ft->mode == 'r' &&
         ft->signal.size != -1 && ft->signal.size != size)
-      st_report("'%s': Format options overriding file-type sample-size", ft->filename);
+      sox_report("'%s': Format options overriding file-type sample-size", ft->filename);
     else ft->signal.size = size;
   }
 
-  if (rev_bits != ST_OPTION_DEFAULT) {
+  if (rev_bits != SOX_OPTION_DEFAULT) {
     if (ft->mode == 'r' &&
-        ft->signal.reverse_bits != ST_OPTION_DEFAULT &&
+        ft->signal.reverse_bits != SOX_OPTION_DEFAULT &&
         ft->signal.reverse_bits != rev_bits)
-      st_report("'%s': Format options overriding file-type bit-order", ft->filename);
+      sox_report("'%s': Format options overriding file-type bit-order", ft->filename);
     else ft->signal.reverse_bits = rev_bits;
   }
 
   ft->eof = 0;
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 #define READ_FUNC(size, sign, ctype, uctype, cast) \
-  static st_size_t st_ ## sign ## size ## _read_buf( \
-      ft_t ft, st_sample_t *buf, st_size_t len) \
+  static sox_size_t sox_ ## sign ## size ## _read_buf( \
+      ft_t ft, sox_sample_t *buf, sox_size_t len) \
   { \
-    st_size_t n; \
+    sox_size_t n; \
     for (n = 0; n < len; n++) { \
       ctype datum; \
-      int ret = st_read ## size(ft, (uctype *)&datum); \
-      if (ret != ST_SUCCESS) \
+      int ret = sox_read ## size(ft, (uctype *)&datum); \
+      if (ret != SOX_SUCCESS) \
         break; \
-      *buf++ = ST_ ## cast ## _TO_SAMPLE(datum, ft->clips); \
+      *buf++ = SOX_ ## cast ## _TO_SAMPLE(datum, ft->clips); \
     } \
     return n; \
   }
@@ -123,13 +123,13 @@
 READ_FUNC(df, su, double, double, FLOAT_DDWORD)
 
 #define WRITE_FUNC(size, sign, cast) \
-  static st_size_t st_ ## sign ## size ## _write_buf( \
-      ft_t ft, st_sample_t *buf, st_size_t len) \
+  static sox_size_t sox_ ## sign ## size ## _write_buf( \
+      ft_t ft, sox_sample_t *buf, sox_size_t len) \
   { \
-    st_size_t n; \
+    sox_size_t n; \
     for (n = 0; n < len; n++) { \
-      int ret = st_write ## size(ft, ST_SAMPLE_TO_ ## cast(*buf++, ft->clips)); \
-      if (ret != ST_SUCCESS) \
+      int ret = sox_write ## size(ft, SOX_SAMPLE_TO_ ## cast(*buf++, ft->clips)); \
+      if (ret != SOX_SUCCESS) \
         break; \
     } \
     return n; \
@@ -148,65 +148,65 @@
 WRITE_FUNC(f, su, FLOAT_DWORD)
 WRITE_FUNC(df, su, FLOAT_DDWORD)
 
-typedef st_size_t (ft_io_fun)(ft_t ft, st_sample_t *buf, st_size_t len);
+typedef sox_size_t (ft_io_fun)(ft_t ft, sox_sample_t *buf, sox_size_t len);
 
-static ft_io_fun *check_format(ft_t ft, st_bool write)
+static ft_io_fun *check_format(ft_t ft, sox_bool write)
 {
     switch (ft->signal.size) {
-    case ST_SIZE_BYTE:
+    case SOX_SIZE_BYTE:
       switch (ft->signal.encoding) {
-      case ST_ENCODING_SIGN2:
-        return write ? st_sb_write_buf : st_sb_read_buf;
-      case ST_ENCODING_UNSIGNED:
-        return write ? st_ub_write_buf : st_ub_read_buf;
-      case ST_ENCODING_ULAW:
-        return write ? st_ulawb_write_buf : st_ulawb_read_buf;
-      case ST_ENCODING_ALAW:
-        return write ? st_alawb_write_buf : st_alawb_read_buf;
+      case SOX_ENCODING_SIGN2:
+        return write ? sox_sb_write_buf : sox_sb_read_buf;
+      case SOX_ENCODING_UNSIGNED:
+        return write ? sox_ub_write_buf : sox_ub_read_buf;
+      case SOX_ENCODING_ULAW:
+        return write ? sox_ulawb_write_buf : sox_ulawb_read_buf;
+      case SOX_ENCODING_ALAW:
+        return write ? sox_alawb_write_buf : sox_alawb_read_buf;
       default:
         break;
       }
       break;
       
-    case ST_SIZE_16BIT: 
+    case SOX_SIZE_16BIT: 
       switch (ft->signal.encoding) {
-      case ST_ENCODING_SIGN2:
-        return write ? st_sw_write_buf : st_sw_read_buf;
-      case ST_ENCODING_UNSIGNED:
-        return write ? st_uw_write_buf : st_uw_read_buf;
+      case SOX_ENCODING_SIGN2:
+        return write ? sox_sw_write_buf : sox_sw_read_buf;
+      case SOX_ENCODING_UNSIGNED:
+        return write ? sox_uw_write_buf : sox_uw_read_buf;
       default:
         break;
       }
       break;
 
-    case ST_SIZE_24BIT:
+    case SOX_SIZE_24BIT:
       switch (ft->signal.encoding) {
-      case ST_ENCODING_SIGN2:
-        return write ? st_s3_write_buf : st_s3_read_buf;
-      case ST_ENCODING_UNSIGNED:
-        return write ? st_u3_write_buf: st_u3_read_buf;
+      case SOX_ENCODING_SIGN2:
+        return write ? sox_s3_write_buf : sox_s3_read_buf;
+      case SOX_ENCODING_UNSIGNED:
+        return write ? sox_u3_write_buf: sox_u3_read_buf;
       default:
         break;
       }
       break;
       
-    case ST_SIZE_32BIT:
+    case SOX_SIZE_32BIT:
       switch (ft->signal.encoding) {
-      case ST_ENCODING_SIGN2:
-        return write ? st_sdw_write_buf : st_sdw_read_buf;
-      case ST_ENCODING_UNSIGNED:
-        return write ? st_udw_write_buf : st_udw_read_buf;
-      case ST_ENCODING_FLOAT:
-        return write ? st_suf_write_buf : st_suf_read_buf;
+      case SOX_ENCODING_SIGN2:
+        return write ? sox_sdw_write_buf : sox_sdw_read_buf;
+      case SOX_ENCODING_UNSIGNED:
+        return write ? sox_udw_write_buf : sox_udw_read_buf;
+      case SOX_ENCODING_FLOAT:
+        return write ? sox_suf_write_buf : sox_suf_read_buf;
       default:
         break;
       }
       break;
       
-    case ST_SIZE_64BIT:
+    case SOX_SIZE_64BIT:
       switch (ft->signal.encoding) {
-      case ST_ENCODING_FLOAT:
-        return write ? st_sudf_write_buf : st_sudf_read_buf;
+      case SOX_ENCODING_FLOAT:
+        return write ? sox_sudf_write_buf : sox_sudf_read_buf;
       default:
         break;
       }
@@ -213,18 +213,18 @@
       break;
 
     default:
-      st_fail_errno(ft,ST_EFMT,"this handler does not support this data size");
+      sox_fail_errno(ft,SOX_EFMT,"this handler does not support this data size");
       return NULL;
     }
 
-    st_fail_errno(ft,ST_EFMT,"this encoding is not supported for this data size");
+    sox_fail_errno(ft,SOX_EFMT,"this encoding is not supported for this data size");
     return NULL;
 }
 
 /* Read a stream of some type into SoX's internal buffer format. */
-st_size_t st_rawread(ft_t ft, st_sample_t *buf, st_size_t nsamp)
+sox_size_t sox_rawread(ft_t ft, sox_sample_t *buf, sox_size_t nsamp)
 {
-    ft_io_fun * read_buf = check_format(ft, st_false);
+    ft_io_fun * read_buf = check_format(ft, sox_false);
 
     if (read_buf && nsamp)
       return read_buf(ft, buf, nsamp);
@@ -234,37 +234,37 @@
 
 static void writeflush(ft_t ft)
 {
-  ft->eof = ST_EOF;
+  ft->eof = SOX_EOF;
 }
 
 
 /* Writes SoX's internal buffer format to buffer of various data types. */
-st_size_t st_rawwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp)
+sox_size_t sox_rawwrite(ft_t ft, const sox_sample_t *buf, sox_size_t nsamp)
 {
-    ft_io_fun *write_buf = check_format(ft, st_true);
+    ft_io_fun *write_buf = check_format(ft, sox_true);
 
     if (write_buf && nsamp)
-      return write_buf(ft, (st_sample_t *)buf, nsamp);
+      return write_buf(ft, (sox_sample_t *)buf, nsamp);
 
     return 0;
 }
 
-int st_rawstopwrite(ft_t ft)
+int sox_rawstopwrite(ft_t ft)
 {
         writeflush(ft);
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
 }
 
 static int raw_start(ft_t ft) {
-  return st_rawstart(ft,st_false,st_false,ST_ENCODING_UNKNOWN,-1,ST_OPTION_DEFAULT);
+  return sox_rawstart(ft,sox_false,sox_false,SOX_ENCODING_UNKNOWN,-1,SOX_OPTION_DEFAULT);
 }
-st_format_t const * st_raw_format_fn(void) {
+sox_format_t const * sox_raw_format_fn(void) {
   static char const * names[] = {"raw", NULL};
-  static st_format_t driver = {
-    names, NULL, ST_FILE_SEEK,
-    raw_start, st_rawread , st_rawstopread,
-    raw_start, st_rawwrite, st_rawstopwrite,
-    st_rawseek
+  static sox_format_t driver = {
+    names, NULL, SOX_FILE_SEEK,
+    raw_start, sox_rawread , sox_rawstopread,
+    raw_start, sox_rawwrite, sox_rawstopwrite,
+    sox_rawseek
   };
   return &driver;
 }
@@ -271,15 +271,15 @@
 
 #define RAW_FORMAT(id,alt1,alt2,size,rev_bits,encoding) \
 static int id##_start(ft_t ft) { \
-  return st_rawstart(ft,st_true,st_true,ST_ENCODING_##encoding,ST_SIZE_##size,ST_OPTION_##rev_bits); \
+  return sox_rawstart(ft,sox_true,sox_true,SOX_ENCODING_##encoding,SOX_SIZE_##size,SOX_OPTION_##rev_bits); \
 } \
-st_format_t const * st_##id##_format_fn(void) { \
+sox_format_t const * sox_##id##_format_fn(void) { \
   static char const * names[] = {#id, alt1, alt2, NULL}; \
-  static st_format_t driver = { \
+  static sox_format_t driver = { \
     names, NULL, 0, \
-    id##_start, st_rawread , st_rawstopread, \
-    id##_start, st_rawwrite, st_rawstopwrite, \
-    st_format_nothing_seek \
+    id##_start, sox_rawread , sox_rawstopread, \
+    id##_start, sox_rawwrite, sox_rawstopwrite, \
+    sox_format_nothing_seek \
   }; \
   return &driver; \
 }
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -17,83 +17,83 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
 
-static st_effect_t st_repeat_effect;
+static sox_effect_t sox_repeat_effect;
 
 typedef struct repeatstuff {
         FILE *fp;
         int first_drain;
-        st_size_t total;
-        st_size_t remaining;
+        sox_size_t total;
+        sox_size_t remaining;
         int repeats;
 } *repeat_t;
 
-static int st_repeat_getopts(eff_t effp, int n, char **argv)
+static int sox_repeat_getopts(eff_t effp, int n, char **argv)
 {
         repeat_t repeat = (repeat_t)effp->priv;
 
         if (n != 1) {
-                st_fail(st_repeat_effect.usage);
-                return (ST_EOF);
+                sox_fail(sox_repeat_effect.usage);
+                return (SOX_EOF);
         }
 
         if (!(sscanf(argv[0], "%i", &repeat->repeats))) {
-                st_fail("repeat: could not parse repeat parameter");
-                return (ST_EOF);
+                sox_fail("repeat: could not parse repeat parameter");
+                return (SOX_EOF);
         }
 
         if (repeat->repeats < 0) {
-                st_fail("repeat: repeat parameter must be positive");
-                return (ST_EOF);
+                sox_fail("repeat: repeat parameter must be positive");
+                return (SOX_EOF);
         }
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static int st_repeat_start(eff_t effp)
+static int sox_repeat_start(eff_t effp)
 {
         repeat_t repeat = (repeat_t)effp->priv;
 
         if (repeat->repeats == 0)
-          return ST_EFF_NULL;
+          return SOX_EFF_NULL;
 
         if ((repeat->fp = tmpfile()) == NULL) {
-                st_fail("repeat: could not create temporary file");
-                return (ST_EOF);
+                sox_fail("repeat: could not create temporary file");
+                return (SOX_EOF);
         }
 
         repeat->first_drain = 1;
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static int st_repeat_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf UNUSED,
-                st_size_t *isamp, st_size_t *osamp)
+static int sox_repeat_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf UNUSED,
+                sox_size_t *isamp, sox_size_t *osamp)
 {
         repeat_t repeat = (repeat_t)effp->priv;
 
-        if (fwrite((char *)ibuf, sizeof(st_sample_t), *isamp, repeat->fp) !=
+        if (fwrite((char *)ibuf, sizeof(sox_sample_t), *isamp, repeat->fp) !=
                         *isamp) {
-                st_fail("repeat: write error on temporary file");
-                return (ST_EOF);
+                sox_fail("repeat: write error on temporary file");
+                return (SOX_EOF);
         }
 
         *osamp = 0;
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static int st_repeat_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_repeat_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
         size_t read = 0;
-        st_sample_t *buf;
-        st_size_t samp;
-        st_size_t done;
+        sox_sample_t *buf;
+        sox_size_t samp;
+        sox_size_t done;
 
         repeat_t repeat = (repeat_t)effp->priv;
 
@@ -103,12 +103,12 @@
                 fseeko(repeat->fp, 0, SEEK_END);
                 repeat->total = ftello(repeat->fp);
 
-                if ((repeat->total % sizeof(st_sample_t)) != 0) {
-                        st_fail("repeat: corrupted temporary file");
-                        return (ST_EOF);
+                if ((repeat->total % sizeof(sox_sample_t)) != 0) {
+                        sox_fail("repeat: corrupted temporary file");
+                        return (SOX_EOF);
                 }
 
-                repeat->total /= sizeof(st_sample_t);
+                repeat->total /= sizeof(sox_sample_t);
                 repeat->remaining = repeat->total;
 
                 fseeko(repeat->fp, 0, SEEK_SET);
@@ -117,7 +117,7 @@
         if (repeat->remaining == 0) {
                 if (repeat->repeats == 0) {
                         *osamp = 0;
-                        return (ST_EOF);
+                        return (SOX_EOF);
                 } else {
                         repeat->repeats--;
                         fseeko(repeat->fp, 0, SEEK_SET);
@@ -128,12 +128,12 @@
                 buf = obuf;
                 samp = repeat->remaining;
 
-                read = fread((char *)buf, sizeof(st_sample_t), samp,
+                read = fread((char *)buf, sizeof(sox_sample_t), samp,
                                 repeat->fp);
                 if (read != samp) {
                         perror(strerror(errno));
-                        st_fail("repeat: read error on temporary file");
-                        return(ST_EOF);
+                        sox_fail("repeat: read error on temporary file");
+                        return(SOX_EOF);
                 }
 
                 done = samp;
@@ -154,13 +154,13 @@
 
                         repeat->remaining = repeat->total - samp;
 
-                        read = fread((char *)buf, sizeof(st_sample_t), samp,
+                        read = fread((char *)buf, sizeof(sox_sample_t), samp,
                                         repeat->fp);
                         if (read != samp) {
                                 perror(strerror(errno));
-                                st_fail("repeat2: read error on temporary "
+                                sox_fail("repeat2: read error on temporary "
                                                 "file\n");
-                                return(ST_EOF);
+                                return(SOX_EOF);
                         }
 
                         done += samp;
@@ -170,44 +170,44 @@
                 *osamp = done;
         }
         else {
-                read = fread((char *)obuf, sizeof(st_sample_t), *osamp,
+                read = fread((char *)obuf, sizeof(sox_sample_t), *osamp,
                                 repeat->fp);
                 if (read != *osamp) {
                         perror(strerror(errno));
-                        st_fail("repeat3: read error on temporary file");
-                        return(ST_EOF);
+                        sox_fail("repeat3: read error on temporary file");
+                        return(SOX_EOF);
                 }
                 repeat->remaining -= *osamp;
         }
 
         if (repeat->remaining == 0)
-            return ST_EOF;
+            return SOX_EOF;
         else
-            return ST_SUCCESS;
+            return SOX_SUCCESS;
 }
 
-static int st_repeat_stop(eff_t effp)
+static int sox_repeat_stop(eff_t effp)
 {
         repeat_t repeat = (repeat_t)effp->priv;
 
         fclose(repeat->fp);
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_effect_t st_repeat_effect = {
+static sox_effect_t sox_repeat_effect = {
   "repeat",
   "Usage: repeat count",
   0,
-  st_repeat_getopts,
-  st_repeat_start,
-  st_repeat_flow,
-  st_repeat_drain,
-  st_repeat_stop,
-  st_effect_nothing
+  sox_repeat_getopts,
+  sox_repeat_start,
+  sox_repeat_flow,
+  sox_repeat_drain,
+  sox_repeat_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_repeat_effect_fn(void)
+const sox_effect_t *sox_repeat_effect_fn(void)
 {
-    return &st_repeat_effect;
+    return &sox_repeat_effect;
 }
--- a/src/resample.c
+++ b/src/resample.c
@@ -40,7 +40,7 @@
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
-#include "st_i.h"
+#include "sox_i.h"
 
 
 /* Conversion constants */
@@ -86,7 +86,7 @@
  *
  */
 
-static st_effect_t st_resample_effect;
+static sox_effect_t sox_resample_effect;
 
 #define ISCALE 0x10000
 
@@ -141,7 +141,7 @@
 /*
  * Process options
  */
-int st_resample_getopts(eff_t effp, int n, char **argv)
+int sox_resample_getopts(eff_t effp, int n, char **argv)
 {
         resample_t r = (resample_t) effp->priv;
 
@@ -171,28 +171,28 @@
         }
 
         if ((n >= 1) && (sscanf(argv[0], "%lf", &r->rolloff) != 1)) {
-          st_fail(st_resample_effect.usage);
-          return (ST_EOF);
+          sox_fail(sox_resample_effect.usage);
+          return (SOX_EOF);
         } else if ((r->rolloff <= 0.01) || (r->rolloff >= 1.0)) {
-          st_fail("resample: rolloff factor (%f) no good, should be 0.01<x<1.0", r->rolloff);
-          return(ST_EOF);
+          sox_fail("resample: rolloff factor (%f) no good, should be 0.01<x<1.0", r->rolloff);
+          return(SOX_EOF);
         }
 
         if ((n >= 2) && !sscanf(argv[1], "%lf", &r->beta)) {
-        	st_fail(st_resample_effect.usage);
-          	return (ST_EOF);
+        	sox_fail(sox_resample_effect.usage);
+          	return (SOX_EOF);
         } else if (r->beta <= 2.0) {
         	r->beta = 0;
-                st_debug("resample opts: Nuttall window, cutoff %f", r->rolloff);
+                sox_debug("resample opts: Nuttall window, cutoff %f", r->rolloff);
         } else
-                st_debug("resample opts: Kaiser window, cutoff %f, beta %f", r->rolloff, r->beta);
-        return (ST_SUCCESS);
+                sox_debug("resample opts: Kaiser window, cutoff %f, beta %f", r->rolloff, r->beta);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Prepare processing.
  */
-int st_resample_start(eff_t effp)
+int sox_resample_start(eff_t effp)
 {
   resample_t r = (resample_t) effp->priv;
   long Xoff, gcdrate;
@@ -199,17 +199,17 @@
   int i;
 
   /* The next line makes the "speed" effect accurate; it's needed because
-   * ininfo.rate (st_rate_t) isn't floating point (but it's probably not worth
-   * changing st_rate_t just because of this): */
+   * ininfo.rate (sox_rate_t) isn't floating point (but it's probably not worth
+   * changing sox_rate_t just because of this): */
   double in_rate = floor(effp->ininfo.rate / effp->globalinfo->speed + .5)
     * effp->globalinfo->speed;
 
   if (in_rate == effp->outinfo.rate)
-    return ST_EFF_NULL;
+    return SOX_EFF_NULL;
           
   r->Factor = (double) effp->outinfo.rate / in_rate;
 
-  gcdrate = st_gcd((long) effp->ininfo.rate, (long) effp->outinfo.rate);
+  gcdrate = sox_gcd((long) effp->ininfo.rate, (long) effp->outinfo.rate);
   r->a = effp->ininfo.rate / gcdrate;
   r->b = effp->outinfo.rate / gcdrate;
 
@@ -227,15 +227,15 @@
   /* returns error # <=0, or adjusted wing-len > 0 */
   i = makeFilter(r->Imp, r->Nwing, r->rolloff, r->beta, r->Nq, 1);
   if (i <= 0) {
-    st_fail("resample: Unable to make filter");
-    return (ST_EOF);
+    sox_fail("resample: Unable to make filter");
+    return (SOX_EOF);
   }
 
-  st_debug("Nmult: %ld, Nwing: %ld, Nq: %ld", r->Nmult, r->Nwing, r->Nq);
+  sox_debug("Nmult: %ld, Nwing: %ld, Nq: %ld", r->Nmult, r->Nwing, r->Nq);
 
   if (r->quadr < 0) {     /* exact coeff's method */
     r->Xh = r->Nwing / r->b;
-    st_debug("resample: rate ratio %ld:%ld, coeff interpolation not needed", r->a, r->b);
+    sox_debug("resample: rate ratio %ld:%ld, coeff interpolation not needed", r->a, r->b);
   } else {
     r->dhb = Np;        /* Fixed-point Filter sampling-time-increment */
     if (r->Factor < 1.0)
@@ -259,13 +259,13 @@
   }
   i = BUFFSIZE - 2 * Xoff;
   if (i < r->Factor + 1.0 / r->Factor) {  /* Check input buffer size */
-    st_fail("Factor is too small or large for BUFFSIZE");
-    return (ST_EOF);
+    sox_fail("Factor is too small or large for BUFFSIZE");
+    return (SOX_EOF);
   }
 
   r->Xsize = 2 * Xoff + i / (1.0 + r->Factor);
   r->Ysize = BUFFSIZE - r->Xsize;
-  st_debug("Xsize %d, Ysize %d, Xoff %d", r->Xsize, r->Ysize, r->Xoff);
+  sox_debug("Xsize %d, Ysize %d, Xoff %d", r->Xsize, r->Ysize, r->Xoff);
 
   r->X = (double *) xmalloc(sizeof(double) * (BUFFSIZE));
   r->Y = r->X + r->Xsize;
@@ -273,7 +273,7 @@
   /* Need Xoff zeros at beginning of sample */
   for (i = 0; i < Xoff; i++)
     r->X[i] = 0;
-  return (ST_SUCCESS);
+  return (SOX_SUCCESS);
 }
 
 /*
@@ -280,13 +280,13 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-int st_resample_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                     st_size_t *isamp, st_size_t *osamp)
+int sox_resample_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                     sox_size_t *isamp, sox_size_t *osamp)
 {
         resample_t r = (resample_t) effp->priv;
         long i, last, Nout, Nx, Nproc;
 
-        st_debug("Xp %d, Xread %d, isamp %d, ",r->Xp, r->Xread,*isamp);
+        sox_debug("Xp %d, Xread %d, isamp %d, ",r->Xp, r->Xread,*isamp);
 
         /* constrain amount we actually process */
         Nproc = r->Xsize - r->Xp;
@@ -298,12 +298,12 @@
         Nx = Nproc - r->Xread; /* space for right-wing future-data */
         if (Nx <= 0)
         {
-                st_fail("resample: Can not handle this sample rate change. Nx not positive: %d", Nx);
-                return (ST_EOF);
+                sox_fail("resample: Can not handle this sample rate change. Nx not positive: %d", Nx);
+                return (SOX_EOF);
         }
         if ((unsigned long)Nx > *isamp)
                 Nx = *isamp;
-        st_debug("Nx %d",Nx);
+        sox_debug("Nx %d",Nx);
 
         if (ibuf == NULL) {
                 for(i = r->Xread; i < Nx + r->Xread  ; i++) 
@@ -320,12 +320,12 @@
                 r->Xread = last;
                 /* leave *isamp alone, we consumed it */
                 *osamp = 0;
-                return (ST_SUCCESS);
+                return (SOX_SUCCESS);
         }
         if (r->quadr < 0) { /* exact coeff's method */
                 long creep; 
                 Nout = SrcEX(r, Nproc);
-                st_debug("Nproc %d --> %d",Nproc,Nout);
+                sox_debug("Nproc %d --> %d",Nproc,Nout);
                 /* Move converter Nproc samples back in time */
                 r->t -= Nproc * r->b;
                 /* Advance by number of samples processed */
@@ -336,12 +336,12 @@
                 {
                   r->t -= creep * r->b;  /* Remove time accumulation   */
                   r->Xp += creep;        /* and add it to read pointer */
-                  st_debug("Nproc %ld, creep %ld",Nproc,creep);
+                  sox_debug("Nproc %ld, creep %ld",Nproc,creep);
                 }
         } else { /* approx coeff's method */
                 long creep; 
                 Nout = SrcUD(r, Nproc);
-                st_debug("Nproc %d --> %d",Nproc,Nout);
+                sox_debug("Nproc %d --> %d",Nproc,Nout);
                 /* Move converter Nproc samples back in time */
                 r->Time -= Nproc;
                 /* Advance by number of samples processed */
@@ -352,7 +352,7 @@
                 {
                   r->Time -= creep;   /* Remove time accumulation   */
                   r->Xp += creep;     /* and add it to read pointer */
-                  st_debug("Nproc %ld, creep %ld",Nproc,creep);
+                  sox_debug("Nproc %ld, creep %ld",Nproc,creep);
                 }
         }
 
@@ -360,7 +360,7 @@
         long i,k;
         /* Copy back portion of input signal that must be re-used */
         k = r->Xp - r->Xoff;
-        st_debug("k %d, last %d",k,last);
+        sox_debug("k %d, last %d",k,last);
         for (i=0; i<last - k; i++) 
             r->X[i] = r->X[i+k];
 
@@ -371,7 +371,7 @@
         for(i=0; i < Nout; i++) { 
                 double ftemp = r->Y[i] * ISCALE;
 
-                ST_SAMPLE_CLIP_COUNT(ftemp, effp->clips);
+                SOX_SAMPLE_CLIP_COUNT(ftemp, effp->clips);
                 *obuf++ = ftemp;
         }
 
@@ -379,20 +379,20 @@
         *osamp = Nout;
 
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Process tail of input samples.
  */
-int st_resample_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+int sox_resample_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
         resample_t r = (resample_t) effp->priv;
         long isamp_res, osamp_res;
-        st_sample_t *Obuf;
+        sox_sample_t *Obuf;
         int rc;
 
-        st_debug("Xoff %d  <--- DRAIN",r->Xoff);
+        sox_debug("Xoff %d  <--- DRAIN",r->Xoff);
 
         /* stuff end with Xoff zeros */
         isamp_res = r->Xoff;
@@ -399,13 +399,13 @@
         osamp_res = *osamp;
         Obuf = obuf;
         while (isamp_res>0 && osamp_res>0) {
-                st_sample_t Isamp, Osamp;
+                sox_sample_t Isamp, Osamp;
                 Isamp = isamp_res;
                 Osamp = osamp_res;
-                rc = st_resample_flow(effp, NULL, Obuf, (st_size_t *)&Isamp, (st_size_t *)&Osamp);
+                rc = sox_resample_flow(effp, NULL, Obuf, (sox_size_t *)&Isamp, (sox_size_t *)&Osamp);
                 if (rc)
                     return rc;
-                st_debug("DRAIN isamp,osamp  (%d,%d) -> (%d,%d)",
+                sox_debug("DRAIN isamp,osamp  (%d,%d) -> (%d,%d)",
                          isamp_res,osamp_res,Isamp,Osamp);
                 Obuf += Osamp;
                 osamp_res -= Osamp;
@@ -412,13 +412,13 @@
                 isamp_res -= Isamp;
         }
         *osamp -= osamp_res;
-        st_debug("DRAIN osamp %d", *osamp);
+        sox_debug("DRAIN osamp %d", *osamp);
         if (isamp_res)
-                st_warn("drain overran obuf by %d", isamp_res);
+                sox_warn("drain overran obuf by %d", isamp_res);
         /* FIXME: This is very picky.  IF obuf is not big enough to
          * drain remaining samples, they will be lost.
          */
-        return (ST_EOF);
+        return (SOX_EOF);
 }
 
 /*
@@ -425,7 +425,7 @@
  * Do anything required when you stop reading samples.  
  * Don't close input file! 
  */
-int st_resample_stop(eff_t effp)
+int sox_resample_stop(eff_t effp)
 {
         resample_t r = (resample_t) effp->priv;
         
@@ -432,7 +432,7 @@
         free(r->Imp - 1);
         free(r->X);
         /* free(r->Y); Y is in same block starting at X */ 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /* over 90% of CPU time spent in this iprodUD() function */
@@ -510,11 +510,11 @@
    Factor = r->Factor;
    time = r->Time;
    dt = 1.0/Factor;        /* Output sampling period */
-   st_debug("Factor %f, dt %f, ",Factor,dt);
-   st_debug("Time %f, ",r->Time);
+   sox_debug("Factor %f, dt %f, ",Factor,dt);
+   sox_debug("Time %f, ",r->Time);
    /* (Xh * dhb)>>La is max index into Imp[] */
-   st_debug("ct=%.2f %d",(double)r->Nwing*Na/r->dhb, r->Xh);
-   st_debug("ct=%ld, T=%.6f, dhb=%6f, dt=%.6f",
+   sox_debug("ct=%.2f %d",(double)r->Nwing*Na/r->dhb, r->Xh);
+   sox_debug("ct=%ld, T=%.6f, dhb=%6f, dt=%.6f",
                          r->Xh, time-floor(time),(double)r->dhb/Na,dt);
    Ystart = Y = r->Y;
    n = (int)ceil((double)Nx/dt);
@@ -536,7 +536,7 @@
       time += dt;            /* Move to next sample by time increment */
       }
    r->Time = time;
-   st_debug("Time %f",r->Time);
+   sox_debug("Time %f",r->Time);
    return (Y - Ystart);        /* Return the number of output samples */
 }
 
@@ -623,7 +623,7 @@
       for (i=Dh; i<Mwing; i+=Dh)
          DCgain += ImpR[i];
       DCgain = 2*DCgain + ImpR[0];    /* DC gain of real coefficients */
-      st_debug("DCgain err=%.12f",DCgain-1.0);
+      sox_debug("DCgain err=%.12f",DCgain-1.0);
   
       DCgain = 1.0/DCgain;
       for (i=0; i<Mwing; i++)
@@ -723,19 +723,19 @@
    }
 }
 
-static st_effect_t st_resample_effect = {
+static sox_effect_t sox_resample_effect = {
    "resample",
    "Usage: resample [ -qs | -q | -ql ] [ rolloff [ beta ] ]",
-   ST_EFF_RATE,
-   st_resample_getopts,
-   st_resample_start,
-   st_resample_flow,
-   st_resample_drain,
-   st_resample_stop,
-  st_effect_nothing
+   SOX_EFF_RATE,
+   sox_resample_getopts,
+   sox_resample_start,
+   sox_resample_flow,
+   sox_resample_drain,
+   sox_resample_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_resample_effect_fn(void)
+const sox_effect_t *sox_resample_effect_fn(void)
 {
-    return &st_resample_effect;
+    return &sox_resample_effect;
 }
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -93,12 +93,12 @@
 
 #include <stdlib.h> /* Harmless, and prototypes atof() etc. --dgc */
 #include <math.h>
-#include "st_i.h"
+#include "sox_i.h"
 
-static st_effect_t st_reverb_effect;
+static sox_effect_t sox_reverb_effect;
 
 #define REVERB_FADE_THRESH 10
-#define DELAY_BUFSIZ ( 50 * ST_MAXRATE )
+#define DELAY_BUFSIZ ( 50 * SOX_MAXRATE )
 #define MAXREVERBS 8
 
 /* Private data for SKEL file */
@@ -109,13 +109,13 @@
         float   in_gain, out_gain, time;
         float   delay[MAXREVERBS], decay[MAXREVERBS];
         size_t  samples[MAXREVERBS], maxsamples;
-        st_sample_t pl, ppl, pppl;
+        sox_sample_t pl, ppl, pppl;
 } *reverb_t;
 
 /*
  * Process options
  */
-static int st_reverb_getopts(eff_t effp, int n, char **argv) 
+static int sox_reverb_getopts(eff_t effp, int n, char **argv) 
 {
         reverb_t reverb = (reverb_t) effp->priv;
         int i;
@@ -125,15 +125,15 @@
 
         if ( n < 3 )
         {
-            st_fail(st_reverb_effect.usage);
-            return (ST_EOF);
+            sox_fail(sox_reverb_effect.usage);
+            return (SOX_EOF);
         }
 
         if ( n - 2 > MAXREVERBS )
         {
-            st_fail("reverb: to many dalays, use less than %i delays",
+            sox_fail("reverb: to many dalays, use less than %i delays",
                         MAXREVERBS);
-            return (ST_EOF);
+            return (SOX_EOF);
         }
 
         i = 0;
@@ -144,13 +144,13 @@
                 sscanf(argv[i++], "%f", &reverb->delay[reverb->numdelays]);
                 reverb->numdelays++;
         }
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Prepare for processing.
  */
-static int st_reverb_start(eff_t effp)
+static int sox_reverb_start(eff_t effp)
 {
         reverb_t reverb = (reverb_t) effp->priv;
         size_t i;
@@ -159,28 +159,28 @@
 
         if ( reverb->out_gain < 0.0 )
         {
-                st_fail("reverb: gain-out must be positive");
-                return (ST_EOF);
+                sox_fail("reverb: gain-out must be positive");
+                return (SOX_EOF);
         }
         if ( reverb->out_gain > 1.0 )
-                st_warn("reverb: warnig >>> gain-out can cause saturation of output <<<");
+                sox_warn("reverb: warnig >>> gain-out can cause saturation of output <<<");
         if ( reverb->time < 0.0 )
         {
-                st_fail("reverb: reverb-time must be positive");
-                return (ST_EOF);
+                sox_fail("reverb: reverb-time must be positive");
+                return (SOX_EOF);
         }
         for(i = 0; i < reverb->numdelays; i++) {
                 reverb->samples[i] = reverb->delay[i] * effp->ininfo.rate / 1000.0;
                 if ( reverb->samples[i] < 1 )
                 {
-                    st_fail("reverb: delay must be positive!");
-                    return (ST_EOF);
+                    sox_fail("reverb: delay must be positive!");
+                    return (SOX_EOF);
                 }
                 if ( reverb->samples[i] > DELAY_BUFSIZ )
                 {
-                        st_fail("reverb: delay must be less than %g seconds!",
+                        sox_fail("reverb: delay must be less than %g seconds!",
                                 DELAY_BUFSIZ / (float) effp->ininfo.rate );
-                        return(ST_EOF);
+                        return(SOX_EOF);
                 }
                 /* Compute a realistic decay */
                 reverb->decay[i] = (float) pow(10.0,(-3.0 * reverb->delay[i] / reverb->time));
@@ -196,7 +196,7 @@
         for ( i = 0; i < reverb->numdelays; i++ )
                 reverb->in_gain *= 
                         ( 1.0 - ( reverb->decay[i] * reverb->decay[i] ));
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
@@ -203,8 +203,8 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_reverb_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                   st_size_t *isamp, st_size_t *osamp)
+static int sox_reverb_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                   sox_size_t *isamp, sox_size_t *osamp)
 {
         reverb_t reverb = (reverb_t) effp->priv;
         size_t len, done;
@@ -211,7 +211,7 @@
         size_t i, j;
         
         float d_in, d_out;
-        st_sample_t out;
+        sox_sample_t out;
 
         i = reverb->counter;
         len = ((*isamp > *osamp) ? *osamp : *isamp);
@@ -224,7 +224,7 @@
                         d_in +=
 reverb->reverbbuf[(i + reverb->maxsamples - reverb->samples[j]) % reverb->maxsamples] * reverb->decay[j];
                 d_out = d_in * reverb->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 *obuf++ = out * 256;
                 reverb->reverbbuf[i] = d_in;
                 i++;            /* XXX need a % maxsamples here ? */
@@ -232,19 +232,19 @@
         }
         reverb->counter = i;
         /* processed all samples */
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Drain out reverb lines. 
  */
-static int st_reverb_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_reverb_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
         reverb_t reverb = (reverb_t) effp->priv;
         float d_in, d_out;
-        st_sample_t out, l;
+        sox_sample_t out, l;
         size_t i, j;
-        st_size_t done;
+        sox_size_t done;
 
         i = reverb->counter;
         done = 0;
@@ -256,10 +256,10 @@
                         d_in += 
 reverb->reverbbuf[(i + reverb->maxsamples - reverb->samples[j]) % reverb->maxsamples] * reverb->decay[j];
                 d_out = d_in * reverb->out_gain;
-                out = ST_24BIT_CLIP_COUNT((st_sample_t) d_out, effp->clips);
+                out = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_out, effp->clips);
                 obuf[done++] = out * 256;
                 reverb->reverbbuf[i] = d_in;
-                l = ST_24BIT_CLIP_COUNT((st_sample_t) d_in, effp->clips);
+                l = SOX_24BIT_CLIP_COUNT((sox_sample_t) d_in, effp->clips);
                 reverb->pppl = reverb->ppl;
                 reverb->ppl = reverb->pl;
                 reverb->pl = l;
@@ -269,34 +269,34 @@
                 ((abs(reverb->pl) + abs(reverb->ppl) + abs(reverb->pppl)) > REVERB_FADE_THRESH));
         reverb->counter = i;
         *osamp = done;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
  * Clean up reverb effect.
  */
-static int st_reverb_stop(eff_t effp)
+static int sox_reverb_stop(eff_t effp)
 {
         reverb_t reverb = (reverb_t) effp->priv;
 
         free((char *) reverb->reverbbuf);
         reverb->reverbbuf = (float *) -1;   /* guaranteed core dump */
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_effect_t st_reverb_effect = {
+static sox_effect_t sox_reverb_effect = {
   "reverb",
   "Usage: reverb gain-out reverb-time delay [ delay ... ]",
   0,
-  st_reverb_getopts,
-  st_reverb_start,
-  st_reverb_flow,
-  st_reverb_drain,
-  st_reverb_stop,
-  st_effect_nothing
+  sox_reverb_getopts,
+  sox_reverb_start,
+  sox_reverb_flow,
+  sox_reverb_drain,
+  sox_reverb_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_reverb_effect_fn(void)
+const sox_effect_t *sox_reverb_effect_fn(void)
 {
-    return &st_reverb_effect;
+    return &sox_reverb_effect;
 }
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -11,7 +11,7 @@
  * "reverse" effect, uses a temporary file created by tmpfile().
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <math.h>
 #include <stdio.h>
@@ -20,12 +20,12 @@
 #include <unistd.h>     /* For SEEK_* defines if not found in stdio */
 #endif
 
-static st_effect_t st_reverse_effect;
+static sox_effect_t sox_reverse_effect;
 
 /* Private data */
 typedef struct reversestuff {
         FILE *fp;
-        st_size_t pos;
+        sox_size_t pos;
         int phase;
 } *reverse_t;
 
@@ -36,17 +36,17 @@
  * Prepare processing: open temporary file.
  */
 
-static int st_reverse_start(eff_t effp)
+static int sox_reverse_start(eff_t effp)
 {
         reverse_t reverse = (reverse_t) effp->priv;
         reverse->fp = tmpfile();
         if (reverse->fp == NULL)
         {
-                st_fail("Reverse effect can't create temporary file");
-                return (ST_EOF);
+                sox_fail("Reverse effect can't create temporary file");
+                return (SOX_EOF);
         }
         reverse->phase = WRITING;
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
@@ -53,24 +53,24 @@
  * Effect flow: a degenerate case: write input samples on temporary file,
  * don't generate any output samples.
  */
-static int st_reverse_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf UNUSED, 
-                    st_size_t *isamp, st_size_t *osamp)
+static int sox_reverse_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf UNUSED, 
+                    sox_size_t *isamp, sox_size_t *osamp)
 {
         reverse_t reverse = (reverse_t) effp->priv;
 
         if (reverse->phase != WRITING)
         {
-                st_fail("Internal error: reverse_flow called in wrong phase");
-                return(ST_EOF);
+                sox_fail("Internal error: reverse_flow called in wrong phase");
+                return(SOX_EOF);
         }
-        if (fwrite((char *)ibuf, sizeof(st_sample_t), *isamp, reverse->fp)
+        if (fwrite((char *)ibuf, sizeof(sox_sample_t), *isamp, reverse->fp)
             != *isamp)
         {
-                st_fail("Reverse effect write error on temporary file");
-                return(ST_EOF);
+                sox_fail("Reverse effect write error on temporary file");
+                return(SOX_EOF);
         }
         *osamp = 0;
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*
@@ -77,36 +77,36 @@
  * Effect drain: generate the actual samples in reverse order.
  */
 
-static int st_reverse_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_reverse_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
         reverse_t reverse = (reverse_t) effp->priv;
-        st_size_t len, nbytes;
+        sox_size_t len, nbytes;
         register int i, j;
-        st_sample_t temp;
+        sox_sample_t temp;
 
         if (reverse->phase == WRITING) {
                 fflush(reverse->fp);
                 fseeko(reverse->fp, 0, SEEK_END);
                 reverse->pos = ftello(reverse->fp);
-                if (reverse->pos % sizeof(st_sample_t) != 0)
+                if (reverse->pos % sizeof(sox_sample_t) != 0)
                 {
-                        st_fail("Reverse effect finds odd temporary file");
-                        return(ST_EOF);
+                        sox_fail("Reverse effect finds odd temporary file");
+                        return(SOX_EOF);
                 }
                 reverse->phase = READING;
         }
         len = *osamp;
-        nbytes = len * sizeof(st_sample_t);
+        nbytes = len * sizeof(sox_sample_t);
         if (reverse->pos < nbytes) {
                 nbytes = reverse->pos;
-                len = nbytes / sizeof(st_sample_t);
+                len = nbytes / sizeof(sox_sample_t);
         }
         reverse->pos -= nbytes;
         fseeko(reverse->fp, reverse->pos, SEEK_SET);
-        if (fread((char *)obuf, sizeof(st_sample_t), len, reverse->fp) != len)
+        if (fread((char *)obuf, sizeof(sox_sample_t), len, reverse->fp) != len)
         {
-                st_fail("Reverse effect read error from temporary file");
-                return(ST_EOF);
+                sox_fail("Reverse effect read error from temporary file");
+                return(SOX_EOF);
         }
         for (i = 0, j = len-1; i < j; i++, j--) {
                 temp = obuf[i];
@@ -115,35 +115,35 @@
         }
         *osamp = len;
         if (reverse->pos == 0)
-            return ST_EOF;
+            return SOX_EOF;
         else
-            return ST_SUCCESS;
+            return SOX_SUCCESS;
 }
 
 /*
  * Close and unlink the temporary file.
  */
-static int st_reverse_stop(eff_t effp)
+static int sox_reverse_stop(eff_t effp)
 {
         reverse_t reverse = (reverse_t) effp->priv;
 
         fclose(reverse->fp);
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static st_effect_t st_reverse_effect = {
+static sox_effect_t sox_reverse_effect = {
   "reverse",
   "Usage: Reverse effect takes no options",
   0,
-  st_effect_nothing_getopts,
-  st_reverse_start,
-  st_reverse_flow,
-  st_reverse_drain,
-  st_reverse_stop,
-  st_effect_nothing
+  sox_effect_nothing_getopts,
+  sox_reverse_start,
+  sox_reverse_flow,
+  sox_reverse_drain,
+  sox_reverse_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_reverse_effect_fn(void)
+const sox_effect_t *sox_reverse_effect_fn(void)
 {
-    return &st_reverse_effect;
+    return &sox_reverse_effect;
 }
--- a/src/sf.c
+++ b/src/sf.c
@@ -13,7 +13,7 @@
  * Derived from: Sound Tools skeleton handler file.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "sfircam.h"
 
 #include <string.h>
@@ -23,7 +23,7 @@
 typedef struct sfstuff {
         struct sfinfo info;
         /* needed for seek */
-        st_size_t dataStart;
+        sox_size_t dataStart;
 } *sf_t;
 
 /*
@@ -40,8 +40,8 @@
         do {
                 sfcharp = (char *) sfcodep + sizeof(SFCODE);
                 if (ft->signal.reverse_bytes) {
-                        sfcodep->bsize = st_swapdw(sfcodep->bsize);
-                        sfcodep->code = st_swapdw(sfcodep->code);
+                        sfcodep->bsize = sox_swapdw(sfcodep->bsize);
+                        sfcodep->code = sox_swapdw(sfcodep->code);
                 }
                 bsize = sfcodep->bsize - sizeof(SFCODE);
                 switch(sfcodep->code) {
@@ -51,7 +51,7 @@
                 case SF_COMMENT:
                         commentbuf = (char *) xmalloc(bsize + 1);
                         memcpy(commentbuf, sfcharp, bsize);
-                        st_report("IRCAM comment: %s", sfcharp);
+                        sox_report("IRCAM comment: %s", sfcharp);
                         commentbuf[bsize] = '\0';
                         if((newline = strchr(commentbuf, '\n')) != NULL)
                                 *newline = '\0';
@@ -63,9 +63,9 @@
                 ft->comment = commentbuf;
 }
 
-static int st_sfseek(ft_t ft, st_size_t offset)
+static int sox_sfseek(ft_t ft, sox_size_t offset)
 {
-    st_size_t new_offset, channel_block, alignment;
+    sox_size_t new_offset, channel_block, alignment;
 
     sf_t sf = (sf_t ) ft->priv;
     new_offset = offset * ft->signal.size;
@@ -80,7 +80,7 @@
         new_offset += (channel_block - alignment);
     new_offset += sf->dataStart;
 
-    return st_seeki(ft, new_offset, SEEK_SET);
+    return sox_seeki(ft, new_offset, SEEK_SET);
 }
 
 /*
@@ -90,7 +90,7 @@
  *      size and encoding of samples,
  *      mono/stereo/quad.
  */
-static int st_sfstartread(ft_t ft)
+static int sox_sfstartread(ft_t ft)
 {
         sf_t sf = (sf_t) ft->priv;
         SFHEADER sfhead;
@@ -97,20 +97,20 @@
         int rc;
         int samplesize = 0;
 
-        if (st_readbuf(ft, &sfhead, 1, sizeof(sfhead)) != sizeof(sfhead))
+        if (sox_readbuf(ft, &sfhead, 1, sizeof(sfhead)) != sizeof(sfhead))
         {
-                st_fail("unexpected EOF in SF header");
-                return(ST_EOF);
+                sox_fail("unexpected EOF in SF header");
+                return(SOX_EOF);
         }
         memcpy(&sf->info, &sfhead.sfinfo, sizeof(struct sfinfo));
         if (ft->signal.reverse_bytes) {
-                sf->info.sf_srate = st_swapf(sf->info.sf_srate);
-                sf->info.sf_packmode = st_swapdw(sf->info.sf_packmode);
-                sf->info.sf_chans = st_swapdw(sf->info.sf_chans);
+                sf->info.sf_srate = sox_swapf(sf->info.sf_srate);
+                sf->info.sf_packmode = sox_swapdw(sf->info.sf_packmode);
+                sf->info.sf_chans = sox_swapdw(sf->info.sf_chans);
         }
         if ((sfmagic1(&sfhead) != SF_MAGIC1) ||
             (sfmagic2(&sfhead) != SF_MAGIC2))
-                st_fail(
+                sox_fail(
 "SF %s file: can't read, it is byte-swapped or it is not an IRCAM SoundFile",
                         ft->filename);
 
@@ -122,19 +122,19 @@
         ft->signal.rate = sf->info.sf_srate;
         switch(sf->info.sf_packmode) {
                 case SF_SHORT:
-                        ft->signal.size = ST_SIZE_16BIT;
-                        ft->signal.encoding = ST_ENCODING_SIGN2;
+                        ft->signal.size = SOX_SIZE_16BIT;
+                        ft->signal.encoding = SOX_ENCODING_SIGN2;
                         samplesize = ft->signal.size;
                         break;
                 case SF_FLOAT:
-                        ft->signal.size = ST_SIZE_32BIT;
-                        ft->signal.encoding = ST_ENCODING_FLOAT;
+                        ft->signal.size = SOX_SIZE_32BIT;
+                        ft->signal.encoding = SOX_ENCODING_FLOAT;
                         samplesize = sizeof(float);
                         break;
                 default:
-                        st_fail("Soundfile input: unknown format 0x%x",
+                        sox_fail("Soundfile input: unknown format 0x%x",
                                 sf->info.sf_packmode);
-                        return(ST_EOF);
+                        return(SOX_EOF);
         }
         ft->signal.channels = (int) sf->info.sf_chans;
 
@@ -145,12 +145,12 @@
         readcodes(ft, &sfhead);
 
         /* Needed for rawread() */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
 
 /* Need length for seeking */
         if(ft->seekable){
-                ft->length = st_filelength(ft)/samplesize;
-                sf->dataStart = st_tell(ft);
+                ft->length = sox_filelength(ft)/samplesize;
+                sf->dataStart = sox_tell(ft);
         } else {
                 ft->length = 0;
         }
@@ -158,7 +158,7 @@
         return(rc);
 }
 
-static int st_sfstartwrite(ft_t ft)
+static int sox_sfstartwrite(ft_t ft)
 {
         sf_t sf = (sf_t) ft->priv;
         SFHEADER sfhead;
@@ -167,7 +167,7 @@
         int rc;
 
         /* Needed for rawwrite() */
-        rc = st_rawstartwrite(ft);
+        rc = sox_rawstartwrite(ft);
         if (rc)
             return rc;
 
@@ -176,20 +176,20 @@
         sf->info.magic_union._magic_bytes.sf_param = 0;
 
         /* This file handler can handle both big and little endian data */
-        if (ST_IS_LITTLEENDIAN)
+        if (SOX_IS_LITTLEENDIAN)
             sf->info.magic_union._magic_bytes.sf_machine = SF_VAX;
         else
             sf->info.magic_union._magic_bytes.sf_machine = SF_SUN;
 
         sf->info.sf_srate = ft->signal.rate;
-        if (ft->signal.size == ST_SIZE_32BIT &&
-            ft->signal.encoding == ST_ENCODING_FLOAT) {
+        if (ft->signal.size == SOX_SIZE_32BIT &&
+            ft->signal.encoding == SOX_ENCODING_FLOAT) {
                 sf->info.sf_packmode = SF_FLOAT;
         } else {
                 sf->info.sf_packmode = SF_SHORT;
                 /* Default to signed words */
-                ft->signal.size = ST_SIZE_16BIT;
-                ft->signal.encoding = ST_ENCODING_SIGN2;
+                ft->signal.size = SOX_SIZE_16BIT;
+                ft->signal.encoding = SOX_ENCODING_SIGN2;
         }
 
         sf->info.sf_chans = ft->signal.channels;
@@ -211,9 +211,9 @@
         sfcharp = (char *) sfcodep + sizeof(SFCODE);
         while(sfcharp < (char *) &sfhead + SIZEOF_HEADER)
                 *sfcharp++ = '\0';
-        st_writebuf(ft, &sfhead, 1, sizeof(SFHEADER));
+        sox_writebuf(ft, &sfhead, 1, sizeof(SFHEADER));
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* Read and write are supplied by raw.c */
@@ -224,20 +224,20 @@
   NULL
 };
 
-static st_format_t st_sf_format = {
+static sox_format_t sox_sf_format = {
   sfnames,
   NULL,
-  ST_FILE_SEEK,
-  st_sfstartread,
-  st_rawread,
-  st_rawstopread,
-  st_sfstartwrite,
-  st_rawwrite,
-  st_rawstopwrite,
-  st_sfseek
+  SOX_FILE_SEEK,
+  sox_sfstartread,
+  sox_rawread,
+  sox_rawstopread,
+  sox_sfstartwrite,
+  sox_rawwrite,
+  sox_rawstopwrite,
+  sox_sfseek
 };
 
-const st_format_t *st_sf_format_fn(void)
+const sox_format_t *sox_sf_format_fn(void)
 {
-    return &st_sf_format;
+    return &sox_sf_format;
 }
--- a/src/sfircam.h
+++ b/src/sfircam.h
@@ -159,7 +159,7 @@
 #define sfchans(x) ((x)->sfinfo.sf_chans)
 #define sfclass(x) ((x)->sfinfo.sf_packmode)
 #define sfsamplesize(x) ((size_t) ((x)->sfinfo.sf_packmode & 0xFFFF))
-#define sfbsize(x) ((x)->st_size - sizeof(SFHEADER))
+#define sfbsize(x) ((x)->sox_size - sizeof(SFHEADER))
 #define sfcodes(x) ((x)->sfinfo.sf_codes)
 
 /*
@@ -215,6 +215,6 @@
 #define sfmaxamp(mptr,chan) (mptr)->value[chan]
 #define sfmaxamploc(mptr,chan) (mptr)->samploc[chan]
 #define sfmaxamptime(x) (x)->timetag
-#define ismaxampgood(x,s) (sfmaxamptime(x) >= (s)->st_mtime)
+#define ismaxampgood(x,s) (sfmaxamptime(x) >= (s)->sox_mtime)
 #define sfcomm(x,n) (x)->comment[n]
 
--- a/src/silence.c
+++ b/src/silence.c
@@ -16,9 +16,9 @@
 
 #include <string.h>
 #include <math.h>
-#include "st_i.h"
+#include "sox_i.h"
 
-static st_effect_t st_silence_effect;
+static sox_effect_t sox_silence_effect;
 
 /* Private data for silence effect. */
 
@@ -33,32 +33,32 @@
     char        start;
     int         start_periods;
     char        *start_duration_str;
-    st_size_t   start_duration;
+    sox_size_t   start_duration;
     double      start_threshold;
     char        start_unit; /* "d" for decibels or "%" for percent. */
     int         restart;
 
-    st_sample_t *start_holdoff;
-    st_size_t   start_holdoff_offset;
-    st_size_t   start_holdoff_end;
+    sox_sample_t *start_holdoff;
+    sox_size_t   start_holdoff_offset;
+    sox_size_t   start_holdoff_end;
     int         start_found_periods;
 
     char        stop;
     int         stop_periods;
     char        *stop_duration_str;
-    st_size_t   stop_duration;
+    sox_size_t   stop_duration;
     double      stop_threshold;
     char        stop_unit;
 
-    st_sample_t *stop_holdoff;
-    st_size_t   stop_holdoff_offset;
-    st_size_t   stop_holdoff_end;
+    sox_sample_t *stop_holdoff;
+    sox_size_t   stop_holdoff_offset;
+    sox_size_t   stop_holdoff_end;
     int         stop_found_periods;
 
     double      *window;
     double      *window_current;
     double      *window_end;
-    st_size_t   window_size;
+    sox_size_t   window_size;
     double      rms_sum;
 
     /* State Machine */
@@ -78,7 +78,7 @@
     silence->rms_sum = 0;
 }
 
-static int st_silence_getopts(eff_t effp, int n, char **argv)
+static int sox_silence_getopts(eff_t effp, int n, char **argv)
 {
     silence_t   silence = (silence_t) effp->priv;
     int parse_count;
@@ -85,21 +85,21 @@
 
     if (n < 1)
     {
-        st_fail(st_silence_effect.usage);
-        return (ST_EOF);
+        sox_fail(sox_silence_effect.usage);
+        return (SOX_EOF);
     }
 
     /* Parse data related to trimming front side */
-    silence->start = st_false;
+    silence->start = sox_false;
     if (sscanf(argv[0], "%d", &silence->start_periods) != 1)
     {
-        st_fail(st_silence_effect.usage);
-        return(ST_EOF);
+        sox_fail(sox_silence_effect.usage);
+        return(SOX_EOF);
     }
     if (silence->start_periods < 0)
     {
-        st_fail("Periods must not be negative");
-        return(ST_EOF);
+        sox_fail("Periods must not be negative");
+        return(SOX_EOF);
     }
     argv++;
     n--;
@@ -106,11 +106,11 @@
 
     if (silence->start_periods > 0)
     {
-        silence->start = st_true;
+        silence->start = sox_true;
         if (n < 2)
         {
-            st_fail(st_silence_effect.usage);
-            return ST_EOF;
+            sox_fail(sox_silence_effect.usage);
+            return SOX_EOF;
         }
 
         /* We do not know the sample rate so we can not fully
@@ -120,11 +120,11 @@
         silence->start_duration_str = (char *)xmalloc(strlen(argv[0])+1);
         strcpy(silence->start_duration_str,argv[0]);
         /* Perform a fake parse to do error checking */
-        if (st_parsesamples(0,silence->start_duration_str,
+        if (sox_parsesamples(0,silence->start_duration_str,
                     &silence->start_duration,'s') == NULL)
         {
-            st_fail(st_silence_effect.usage);
-            return(ST_EOF);
+            sox_fail(sox_silence_effect.usage);
+            return(SOX_EOF);
         }
 
         parse_count = sscanf(argv[1], "%lf%c", &silence->start_threshold, 
@@ -131,8 +131,8 @@
                 &silence->start_unit);
         if (parse_count < 1)
         {
-            st_fail(st_silence_effect.usage);
-            return ST_EOF;
+            sox_fail(sox_silence_effect.usage);
+            return SOX_EOF;
         }
         else if (parse_count < 2)
             silence->start_unit = '%';
@@ -141,19 +141,19 @@
         n--; n--;
     }
 
-    silence->stop = st_false;
+    silence->stop = sox_false;
     /* Parse data needed for trimming of backside */
     if (n > 0)
     {
         if (n < 3)
         {
-            st_fail(st_silence_effect.usage);
-            return ST_EOF;
+            sox_fail(sox_silence_effect.usage);
+            return SOX_EOF;
         }
         if (sscanf(argv[0], "%d", &silence->stop_periods) != 1)
         {
-            st_fail(st_silence_effect.usage);
-            return ST_EOF;
+            sox_fail(sox_silence_effect.usage);
+            return SOX_EOF;
         }
         if (silence->stop_periods < 0)
         {
@@ -162,7 +162,7 @@
         }
         else
             silence->restart = 0;
-        silence->stop = st_true;
+        silence->stop = sox_true;
         argv++;
         n--;
 
@@ -173,11 +173,11 @@
         silence->stop_duration_str = (char *)xmalloc(strlen(argv[0])+1);
         strcpy(silence->stop_duration_str,argv[0]);
         /* Perform a fake parse to do error checking */
-        if (st_parsesamples(0,silence->stop_duration_str,
+        if (sox_parsesamples(0,silence->stop_duration_str,
                     &silence->stop_duration,'s') == NULL)
         {
-            st_fail(st_silence_effect.usage);
-            return(ST_EOF);
+            sox_fail(sox_silence_effect.usage);
+            return(SOX_EOF);
         }
 
         parse_count = sscanf(argv[1], "%lf%c", &silence->stop_threshold, 
@@ -184,8 +184,8 @@
                              &silence->stop_unit);
         if (parse_count < 1)
         {
-            st_fail(st_silence_effect.usage);
-            return ST_EOF;
+            sox_fail(sox_silence_effect.usage);
+            return SOX_EOF;
         }
         else if (parse_count < 2)
             silence->stop_unit = '%';
@@ -199,20 +199,20 @@
     {
         if ((silence->start_unit != '%') && (silence->start_unit != 'd'))
         {
-            st_fail("Invalid unit specified");
-            st_fail(st_silence_effect.usage);
-            return(ST_EOF);
+            sox_fail("Invalid unit specified");
+            sox_fail(sox_silence_effect.usage);
+            return(SOX_EOF);
         }
         if ((silence->start_unit == '%') && ((silence->start_threshold < 0.0)
             || (silence->start_threshold > 100.0)))
         {
-            st_fail("silence threshold should be between 0.0 and 100.0 %%");
-            return (ST_EOF);
+            sox_fail("silence threshold should be between 0.0 and 100.0 %%");
+            return (SOX_EOF);
         }
         if ((silence->start_unit == 'd') && (silence->start_threshold >= 0.0))
         {
-            st_fail("silence threshold should be less than 0.0 dB");
-            return(ST_EOF);
+            sox_fail("silence threshold should be less than 0.0 dB");
+            return(SOX_EOF);
         }
     }
 
@@ -220,25 +220,25 @@
     {
         if ((silence->stop_unit != '%') && (silence->stop_unit != 'd'))
         {
-            st_fail("Invalid unit specified");
-            return(ST_EOF);
+            sox_fail("Invalid unit specified");
+            return(SOX_EOF);
         }
         if ((silence->stop_unit == '%') && ((silence->stop_threshold < 0.0) || 
                     (silence->stop_threshold > 100.0)))
         {
-            st_fail("silence threshold should be between 0.0 and 100.0 %%");
-            return (ST_EOF);
+            sox_fail("silence threshold should be between 0.0 and 100.0 %%");
+            return (SOX_EOF);
         }
         if ((silence->stop_unit == 'd') && (silence->stop_threshold >= 0.0))
         {
-            st_fail("silence threshold should be less than 0.0 dB");
-            return(ST_EOF);
+            sox_fail("silence threshold should be less than 0.0 dB");
+            return(SOX_EOF);
         }
     }
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
 }
 
-static int st_silence_start(eff_t effp)
+static int sox_silence_start(eff_t effp)
 {
         silence_t       silence = (silence_t) effp->priv;
 
@@ -256,20 +256,20 @@
         /* Now that we now sample rate, reparse duration. */
         if (silence->start)
         {
-            if (st_parsesamples(effp->ininfo.rate, silence->start_duration_str,
+            if (sox_parsesamples(effp->ininfo.rate, silence->start_duration_str,
                                 &silence->start_duration, 's') == NULL)
             {
-                st_fail(st_silence_effect.usage);
-                return(ST_EOF);
+                sox_fail(sox_silence_effect.usage);
+                return(SOX_EOF);
             }
         }
         if (silence->stop)
         {
-            if (st_parsesamples(effp->ininfo.rate,silence->stop_duration_str,
+            if (sox_parsesamples(effp->ininfo.rate,silence->stop_duration_str,
                                 &silence->stop_duration,'s') == NULL)
             {
-                st_fail(st_silence_effect.usage);
-                return(ST_EOF);
+                sox_fail(sox_silence_effect.usage);
+                return(SOX_EOF);
             }
         }
 
@@ -278,44 +278,44 @@
         else
             silence->mode = SILENCE_COPY;
 
-        silence->start_holdoff = (st_sample_t *)xmalloc(sizeof(st_sample_t)*silence->start_duration);
+        silence->start_holdoff = (sox_sample_t *)xmalloc(sizeof(sox_sample_t)*silence->start_duration);
         silence->start_holdoff_offset = 0;
         silence->start_holdoff_end = 0;
         silence->start_found_periods = 0;
 
-        silence->stop_holdoff = (st_sample_t *)xmalloc(sizeof(st_sample_t)*silence->stop_duration);
+        silence->stop_holdoff = (sox_sample_t *)xmalloc(sizeof(sox_sample_t)*silence->stop_duration);
         silence->stop_holdoff_offset = 0;
         silence->stop_holdoff_end = 0;
         silence->stop_found_periods = 0;
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
-static int aboveThreshold(eff_t effp, st_sample_t value, double threshold, char unit)
+static int aboveThreshold(eff_t effp, sox_sample_t value, double threshold, char unit)
 {
     double ratio;
     int rc;
-    st_sample_t dummy_clipped_count = 0;
+    sox_sample_t dummy_clipped_count = 0;
 
     /* When scaling low bit data, noise values got scaled way up */
     /* Only consider the original bits when looking for silence */
     switch(effp->ininfo.size)
     {
-        case ST_SIZE_BYTE:
-            value = ST_SAMPLE_TO_SIGNED_BYTE(value, dummy_clipped_count);
-            ratio = (double)abs(value) / (double)ST_INT8_MAX;
+        case SOX_SIZE_BYTE:
+            value = SOX_SAMPLE_TO_SIGNED_BYTE(value, dummy_clipped_count);
+            ratio = (double)abs(value) / (double)SOX_INT8_MAX;
             break;
-        case ST_SIZE_16BIT:
-            value = ST_SAMPLE_TO_SIGNED_WORD(value, dummy_clipped_count);
-            ratio = (double)abs(value) / (double)ST_INT16_MAX;
+        case SOX_SIZE_16BIT:
+            value = SOX_SAMPLE_TO_SIGNED_WORD(value, dummy_clipped_count);
+            ratio = (double)abs(value) / (double)SOX_INT16_MAX;
             break;
-        case ST_SIZE_24BIT:
-            value = ST_SAMPLE_TO_SIGNED_24BIT(value, dummy_clipped_count);
-            ratio = (double)abs(value) / (double)ST_INT24_MAX;
+        case SOX_SIZE_24BIT:
+            value = SOX_SAMPLE_TO_SIGNED_24BIT(value, dummy_clipped_count);
+            ratio = (double)abs(value) / (double)SOX_INT24_MAX;
             break;
-        case ST_SIZE_32BIT:
-            value = ST_SAMPLE_TO_SIGNED_DWORD(value,);
-            ratio = (double)labs(value) / (double)ST_INT32_MAX;
+        case SOX_SIZE_32BIT:
+            value = SOX_SAMPLE_TO_SIGNED_DWORD(value,);
+            ratio = (double)labs(value) / (double)SOX_INT32_MAX;
             break;
         default:
             ratio = 0;
@@ -330,11 +330,11 @@
     return rc;
 }
 
-static st_sample_t compute_rms(eff_t effp, st_sample_t sample)
+static sox_sample_t compute_rms(eff_t effp, sox_sample_t sample)
 {
     silence_t silence = (silence_t) effp->priv;
     double new_sum;
-    st_sample_t rms;
+    sox_sample_t rms;
 
     new_sum = silence->rms_sum;
     new_sum -= *silence->window_current;
@@ -345,7 +345,7 @@
     return (rms);
 }
 
-static void update_rms(eff_t effp, st_sample_t sample)
+static void update_rms(eff_t effp, sox_sample_t sample)
 {
     silence_t silence = (silence_t) effp->priv;
 
@@ -360,13 +360,13 @@
 
 /* Process signed long samples from ibuf to obuf. */
 /* Return number of samples processed in isamp and osamp. */
-static int st_silence_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                    st_size_t *isamp, st_size_t *osamp)
+static int sox_silence_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                    sox_size_t *isamp, sox_size_t *osamp)
 {
     silence_t silence = (silence_t) effp->priv;
     int threshold;
-    st_size_t i, j;
-    st_size_t nrOfTicks, nrOfInSamplesRead, nrOfOutSamplesWritten;
+    sox_size_t i, j;
+    sox_size_t nrOfTicks, nrOfInSamplesRead, nrOfOutSamplesWritten;
 
     nrOfInSamplesRead = 0;
     nrOfOutSamplesWritten = 0;
@@ -540,8 +540,8 @@
                                     *isamp = nrOfInSamplesRead;
                                     *osamp = nrOfOutSamplesWritten;
                                     silence->mode = SILENCE_STOP;
-                                    /* Return ST_EOF since no more processing */
-                                    return (ST_EOF);
+                                    /* Return SOX_EOF since no more processing */
+                                    return (SOX_EOF);
                                 }
                                 else
                                 {
@@ -570,7 +570,7 @@
             } /* Trimming off backend */
             else /* !(silence->stop) */
             {
-                memcpy(obuf, ibuf, sizeof(st_sample_t)*nrOfTicks*
+                memcpy(obuf, ibuf, sizeof(sox_sample_t)*nrOfTicks*
                                    effp->ininfo.channels);
                 nrOfInSamplesRead += (nrOfTicks*effp->ininfo.channels);
                 nrOfOutSamplesWritten += (nrOfTicks*effp->ininfo.channels);
@@ -607,14 +607,14 @@
         *isamp = nrOfInSamplesRead;
         *osamp = nrOfOutSamplesWritten;
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static int st_silence_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_silence_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
     silence_t silence = (silence_t) effp->priv;
-    st_size_t i;
-    st_size_t nrOfTicks, nrOfOutSamplesWritten = 0;
+    sox_size_t i;
+    sox_size_t nrOfTicks, nrOfOutSamplesWritten = 0;
 
     /* Only if in flush mode will there be possible samples to write
      * out during drain() call.
@@ -641,12 +641,12 @@
 
     *osamp = nrOfOutSamplesWritten;
     if (silence->mode == SILENCE_STOP || *osamp == 0)
-        return ST_EOF;
+        return SOX_EOF;
     else
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
 }
 
-static int st_silence_stop(eff_t effp)
+static int sox_silence_stop(eff_t effp)
 {
     silence_t silence = (silence_t) effp->priv;
 
@@ -653,7 +653,7 @@
     free(silence->window);
     free(silence->start_holdoff);
     free(silence->stop_holdoff);
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
 }
 
 static int delete(eff_t effp)
@@ -662,22 +662,22 @@
 
   free(silence->start_duration_str);
   free(silence->stop_duration_str);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static st_effect_t st_silence_effect = {
+static sox_effect_t sox_silence_effect = {
   "silence",
   "Usage: silence above_periods [ duration thershold[d | %% ] ] [ below_periods duration threshold[ d | %% ]]",
-  ST_EFF_MCHAN,
-  st_silence_getopts,
-  st_silence_start,
-  st_silence_flow,
-  st_silence_drain,
-  st_silence_stop,
+  SOX_EFF_MCHAN,
+  sox_silence_getopts,
+  sox_silence_start,
+  sox_silence_flow,
+  sox_silence_drain,
+  sox_silence_stop,
   delete
 };
 
-const st_effect_t *st_silence_effect_fn(void)
+const sox_effect_t *sox_silence_effect_fn(void)
 {
-    return &st_silence_effect;
+    return &sox_silence_effect;
 }
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -18,7 +18,7 @@
  * Foundation, Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301,
  * USA.  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 /* Private data for effect */
 typedef struct skeleff {
@@ -25,7 +25,7 @@
   int  localdata;
 } *skeleff_t;
 
-assert_static(sizeof(struct skeleff) <= ST_MAX_EFFECT_PRIVSIZE, 
+assert_static(sizeof(struct skeleff) <= SOX_MAX_EFFECT_PRIVSIZE, 
               /* else */ skeleff_PRIVSIZE_too_big);
 
 /*
@@ -39,11 +39,11 @@
   skeleff_t skeleff = (skeleff_t)effp->priv;
 
   if (n && n != 1) {
-    st_fail(effp->h->usage);
-    return ST_EOF;
+    sox_fail(effp->h->usage);
+    return SOX_EOF;
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
@@ -53,11 +53,11 @@
 static int start(eff_t effp)
 {
   if (effp->outinfo.channels == 1) {
-    st_fail("Can't run skeleff on mono data.");
-    return ST_EOF;
+    sox_fail("Can't run skeleff on mono data.");
+    return SOX_EOF;
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
@@ -64,11 +64,11 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                           st_size_t *isamp, st_size_t *osamp)
+static int flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                           sox_size_t *isamp, sox_size_t *osamp)
 {
   skeleff_t skeleff = (skeleff_t)effp->priv;
-  st_size_t len, done;
+  sox_size_t len, done;
 
   switch (effp->outinfo.channels) {
   case 2:
@@ -91,20 +91,20 @@
     break;
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
  * Drain out remaining samples if the effect generates any.
  */
-static int drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
   *osamp = 0;
-  /* Help out application and return ST_EOF when drain
+  /* Help out application and return SOX_EOF when drain
    * will not return any mre information.  *osamp == 0
    * also indicates that.
    */
-  return ST_EOF;
+  return SOX_EOF;
 }
 
 /*
@@ -112,7 +112,7 @@
  */
 static int stop(eff_t effp)
 {
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
@@ -121,7 +121,7 @@
  */
 static int delete(eff_t effp)
 {
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
@@ -131,10 +131,10 @@
  * the 6 functions, then the function can be deleted
  * and 0 used in place of the its name below.
  */
-static st_effect_t st_skel_effect = {
+static sox_effect_t sox_skel_effect = {
   "skel",
   "Usage: skel [option]",
-  ST_EFF_MCHAN,
+  SOX_EFF_MCHAN,
   getopts,
   start,
   flow,
@@ -147,7 +147,7 @@
  * Function returning effect descriptor. This should be the only
  * externally visible object.
  */
-const st_effect_t *st_skel_effect_fn(void)
+const sox_effect_t *sox_skel_effect_fn(void)
 {
-  return &st_skel_effect;
+  return &sox_skel_effect;
 }
--- a/src/skelform.c
+++ b/src/skelform.c
@@ -18,7 +18,7 @@
  * Foundation, Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301,
  * USA.  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <string.h>
 
@@ -25,14 +25,14 @@
 /* Private data for SKEL file */
 typedef struct skelform
 {
-  st_size_t remaining_samples;
+  sox_size_t remaining_samples;
 } *skelform_t;
 
-assert_static(sizeof(struct skelform) <= ST_MAX_FILE_PRIVSIZE, 
+assert_static(sizeof(struct skelform) <= SOX_MAX_FILE_PRIVSIZE, 
               /* else */ skel_PRIVSIZE_too_big);
 
 /* Note that if any of your methods doesn't need to do anything, you
-   can instead use the relevant st_*_nothing* method */
+   can instead use the relevant sox_*_nothing* method */
 
 /*
  * Do anything required before you start reading samples.
@@ -44,12 +44,12 @@
 static int startread(ft_t ft)
 {
   skelform_t sk = (skelform_t)ft->priv;
-  st_size_t samples_in_file;
+  sox_size_t samples_in_file;
 
   /* If you need to seek around the input file. */
   if (!ft->seekable) {
-    st_fail_errno(ft, ST_EOF, "skel inputfile must be a file");
-    return ST_EOF;
+    sox_fail_errno(ft, SOX_EOF, "skel inputfile must be a file");
+    return SOX_EOF;
   }
 
   /*
@@ -59,8 +59,8 @@
    * then you should set it here.
    */
   ft->signal.rate =  44100;
-  ft->signal.size = ST_SIZE_BYTE; /* or WORD ... */
-  ft->signal.encoding = ST_ENCODING_UNSIGNED; /* or SIGN2 ... */
+  ft->signal.size = SOX_SIZE_BYTE; /* or WORD ... */
+  ft->signal.encoding = SOX_ENCODING_UNSIGNED; /* or SIGN2 ... */
   ft->signal.channels = 1; /* or 2 or 4 */
   {
     char *comment = "any comment in file header.";
@@ -71,23 +71,23 @@
   /* If your format doesn't have a header then samples_in_file
    * can be determined by the file size.
    */
-  samples_in_file = st_filelength(ft) / ft->signal.size;
+  samples_in_file = sox_filelength(ft) / ft->signal.size;
 
   /* If you can detect the length of your file, record it here. */
   ft->length = samples_in_file;
   sk->remaining_samples = samples_in_file;
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
- * Read up to len samples of type st_sample_t from file into buf[].
+ * Read up to len samples of type sox_sample_t from file into buf[].
  * Return number of samples read, or 0 if at end of file.
  */
-static st_size_t read(ft_t ft, st_sample_t *buf, st_size_t len)
+static sox_size_t read(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
   skelform_t sk = (skelform_t)ft->priv;
-  st_size_t done;
+  sox_size_t done;
   unsigned char sample;
 
   for (done = 0; done < len; done++) {
@@ -95,18 +95,18 @@
       break;
     sample = fgetc(ft->fp);
     switch (ft->signal.size) {
-    case ST_SIZE_BYTE:
+    case SOX_SIZE_BYTE:
       switch (ft->signal.encoding) {
-      case ST_ENCODING_UNSIGNED:
-        *buf++ = ST_UNSIGNED_BYTE_TO_SAMPLE(sample,);
+      case SOX_ENCODING_UNSIGNED:
+        *buf++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(sample,);
         break;
       default:
-        st_fail("Undetected sample encoding in read!");
+        sox_fail("Undetected sample encoding in read!");
         exit(2);
       }
       break;
     default:
-      st_fail("Undetected bad sample size in read!");
+      sox_fail("Undetected bad sample size in read!");
       exit(2);
     }
   }
@@ -120,7 +120,7 @@
  */
 static int stopread(ft_t ft)
 {
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static int startwrite(ft_t ft)
@@ -133,16 +133,16 @@
    * just set the length to max value and not fail.
    */
   if (!ft->seekable) {
-    st_fail("Output .skel file must be a file, not a pipe");
-    return ST_EOF;
+    sox_fail("Output .skel file must be a file, not a pipe");
+    return SOX_EOF;
   }
 
   if (ft->signal.rate != 44100)
-    st_fail("Output .skel file must have a sample rate of 44100Hz");
+    sox_fail("Output .skel file must have a sample rate of 44100Hz");
 
   if (ft->signal.size == -1) {
-    st_fail("Did not specify a size for .skel output file");
-    return ST_EOF;
+    sox_fail("Did not specify a size for .skel output file");
+    return SOX_EOF;
   }
 
   /* error check ft->signal.encoding */
@@ -151,35 +151,35 @@
   /* Write file header, if any */
   /* Write comment field, if any */
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 
 }
 
 /*
- * Write len samples of type st_sample_t from buf[] to file.
+ * Write len samples of type sox_sample_t from buf[] to file.
  * Return number of samples written.
  */
-static st_size_t write(ft_t ft, const st_sample_t *buf, st_size_t len)
+static sox_size_t write(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
   skelform_t sk = (skelform_t)ft->priv;
 
   switch (ft->signal.size) {
-  case ST_SIZE_BYTE:
+  case SOX_SIZE_BYTE:
     switch (ft->signal.encoding) {
-    case ST_ENCODING_UNSIGNED:
+    case SOX_ENCODING_UNSIGNED:
       while (len--) {
-        len = st_writeb(ft, ST_SAMPLE_TO_UNSIGNED_BYTE(*buf++, ft->clips));
+        len = sox_writeb(ft, SOX_SAMPLE_TO_UNSIGNED_BYTE(*buf++, ft->clips));
         if (len == 0)
           break;
       }
       break;
     default:
-      st_fail("Undetected bad sample encoding in write!");
+      sox_fail("Undetected bad sample encoding in write!");
       exit(2);
     }
     break;
   default:
-    st_fail("Undetected bad sample size in write!");
+    sox_fail("Undetected bad sample size in write!");
     exit(2);
   }
 
@@ -191,13 +191,13 @@
   /* All samples are already written out. */
   /* If file header needs fixing up, for example it needs the number
      of samples in a field, seek back and write them here. */
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static int seek(ft_t ft, st_size_t offset)
+static int seek(ft_t ft, sox_size_t offset)
 {
   /* Seek relative to current position. */
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /* Format file suffixes */
@@ -207,10 +207,10 @@
 };
 
 /* Format descriptor */
-static st_format_t st_skel_format = {
+static sox_format_t sox_skel_format = {
   names,
   NULL,
-  ST_FILE_SEEK,
+  SOX_FILE_SEEK,
   startread,
   read,
   stopread,
@@ -220,7 +220,7 @@
   seek
 };
 
-const st_format_t *st_skel_format_fn(void)
+const sox_format_t *sox_skel_format_fn(void)
 {
-  return &st_skel_format;
+  return &sox_skel_format;
 }
--- a/src/smp.c
+++ b/src/smp.c
@@ -16,7 +16,7 @@
  * the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <string.h>
 #include <errno.h>
 
@@ -62,7 +62,7 @@
 /* Private data for SMP file */
 typedef struct smpstuff {
   uint32_t NoOfSamps;           /* Sample data count in words */
-  st_size_t dataStart;
+  sox_size_t dataStart;
   /* comment memory resides in private data because it's small */
   char comment[COMMENTLEN + NAMELEN + 3];
 } *smp_t;
@@ -78,38 +78,38 @@
         int i;
         int16_t trash16;
 
-        st_readw(ft, (unsigned short *)&trash16); /* read reserved word */
+        sox_readw(ft, (unsigned short *)&trash16); /* read reserved word */
         for(i = 0; i < 8; i++) {        /* read the 8 loops */
-                st_readdw(ft, &(trailer->loops[i].start));
+                sox_readdw(ft, &(trailer->loops[i].start));
                 ft->loops[i].start = trailer->loops[i].start;
-                st_readdw(ft, &(trailer->loops[i].end));
+                sox_readdw(ft, &(trailer->loops[i].end));
                 ft->loops[i].length = 
                         trailer->loops[i].end - trailer->loops[i].start;
-                st_readb(ft, (unsigned char *)&(trailer->loops[i].type));
+                sox_readb(ft, (unsigned char *)&(trailer->loops[i].type));
                 ft->loops[i].type = trailer->loops[i].type;
-                st_readw(ft, (unsigned short *)&(trailer->loops[i].count));
+                sox_readw(ft, (unsigned short *)&(trailer->loops[i].count));
                 ft->loops[i].count = trailer->loops[i].count;
         }
         for(i = 0; i < 8; i++) {        /* read the 8 markers */
-                if (st_readbuf(ft, trailer->markers[i].name, 1, MARKERLEN) != 10)
+                if (sox_readbuf(ft, trailer->markers[i].name, 1, MARKERLEN) != 10)
                 {
-                    st_fail_errno(ft,ST_EHDR,"EOF in SMP");
-                    return(ST_EOF);
+                    sox_fail_errno(ft,SOX_EHDR,"EOF in SMP");
+                    return(SOX_EOF);
                 }
                 trailer->markers[i].name[MARKERLEN] = 0;
-                st_readdw(ft, &(trailer->markers[i].position));
+                sox_readdw(ft, &(trailer->markers[i].position));
         }
-        st_readb(ft, (unsigned char *)&(trailer->MIDInote));
-        st_readdw(ft, &(trailer->rate));
-        st_readdw(ft, &(trailer->SMPTEoffset));
-        st_readdw(ft, &(trailer->CycleSize));
-        return(ST_SUCCESS);
+        sox_readb(ft, (unsigned char *)&(trailer->MIDInote));
+        sox_readdw(ft, &(trailer->rate));
+        sox_readdw(ft, &(trailer->SMPTEoffset));
+        sox_readdw(ft, &(trailer->CycleSize));
+        return(SOX_SUCCESS);
 }
 
 /*
  * set the trailer data - loops and markers, to reasonably benign values
  */
-static void settrailer(ft_t ft, struct smptrailer *trailer, st_rate_t rate)
+static void settrailer(ft_t ft, struct smptrailer *trailer, sox_rate_t rate)
 {
         int i;
 
@@ -147,29 +147,29 @@
 {
         int i;
 
-        st_writew(ft, 0);                       /* write the reserved word */
+        sox_writew(ft, 0);                       /* write the reserved word */
         for(i = 0; i < 8; i++) {        /* write the 8 loops */
-                st_writedw(ft, trailer->loops[i].start);
-                st_writedw(ft, trailer->loops[i].end);
-                st_writeb(ft, trailer->loops[i].type);
-                st_writew(ft, trailer->loops[i].count);
+                sox_writedw(ft, trailer->loops[i].start);
+                sox_writedw(ft, trailer->loops[i].end);
+                sox_writeb(ft, trailer->loops[i].type);
+                sox_writew(ft, trailer->loops[i].count);
         }
         for(i = 0; i < 8; i++) {        /* write the 8 markers */
-                if (st_writes(ft, trailer->markers[i].name) == ST_EOF)
+                if (sox_writes(ft, trailer->markers[i].name) == SOX_EOF)
                 {
-                    st_fail_errno(ft,ST_EHDR,"EOF in SMP");
-                    return(ST_EOF);
+                    sox_fail_errno(ft,SOX_EHDR,"EOF in SMP");
+                    return(SOX_EOF);
                 }
-                st_writedw(ft, trailer->markers[i].position);
+                sox_writedw(ft, trailer->markers[i].position);
         }
-        st_writeb(ft, trailer->MIDInote);
-        st_writedw(ft, trailer->rate);
-        st_writedw(ft, trailer->SMPTEoffset);
-        st_writedw(ft, trailer->CycleSize);
-        return(ST_SUCCESS);
+        sox_writeb(ft, trailer->MIDInote);
+        sox_writedw(ft, trailer->rate);
+        sox_writedw(ft, trailer->SMPTEoffset);
+        sox_writedw(ft, trailer->CycleSize);
+        return(SOX_SUCCESS);
 }
 
-static int st_smpseek(ft_t ft, st_size_t offset) 
+static int sox_smpseek(ft_t ft, sox_size_t offset) 
 {
     int new_offset, channel_block, alignment;
     smp_t smp = (smp_t) ft->priv;
@@ -186,12 +186,12 @@
         new_offset += (channel_block - alignment);
     new_offset += smp->dataStart;
 
-    ft->st_errno = st_seeki(ft, new_offset, SEEK_SET);
+    ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
 
-    if( ft->st_errno == ST_SUCCESS )
+    if( ft->sox_errno == SOX_SUCCESS )
         smp->NoOfSamps = ft->length - (new_offset / ft->signal.size);
 
-    return(ft->st_errno);
+    return(ft->sox_errno);
 }
 /*
  * Do anything required before you start reading samples.
@@ -200,7 +200,7 @@
  *      size and encoding of samples, 
  *      mono/stereo/quad.
  */
-static int st_smpstartread(ft_t ft) 
+static int sox_smpstartread(ft_t ft) 
 {
         smp_t smp = (smp_t) ft->priv;
         int i;
@@ -212,25 +212,25 @@
         /* If you need to seek around the input file. */
         if (! ft->seekable)
         {
-                st_fail_errno(ft,ST_EOF,"SMP input file must be a file, not a pipe");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EOF,"SMP input file must be a file, not a pipe");
+                return(SOX_EOF);
         }
 
         /* Read SampleVision header */
-        if (st_readbuf(ft, (char *)&header, 1, HEADERSIZE) != HEADERSIZE)
+        if (sox_readbuf(ft, (char *)&header, 1, HEADERSIZE) != HEADERSIZE)
         {
-                st_fail_errno(ft,ST_EHDR,"unexpected EOF in SMP header");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"unexpected EOF in SMP header");
+                return(SOX_EOF);
         }
         if (strncmp(header.Id, SVmagic, 17) != 0)
         {
-                st_fail_errno(ft,ST_EHDR,"SMP header does not begin with magic word %s", SVmagic);
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"SMP header does not begin with magic word %s", SVmagic);
+                return(SOX_EOF);
         }
         if (strncmp(header.version, SVvers, 4) != 0)
         {
-                st_fail_errno(ft,ST_EHDR,"SMP header is not version %s", SVvers);
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"SMP header is not version %s", SVvers);
+                return(SOX_EOF);
         }
 
         /* Format the sample name and comments to a single comment */
@@ -246,51 +246,51 @@
                 commentlen+1, header.comments);
         ft->comment = smp->comment;
 
-        st_report("SampleVision file name and comments: %s", ft->comment);
+        sox_report("SampleVision file name and comments: %s", ft->comment);
         /* Extract out the sample size (always intel format) */
-        st_readdw(ft, &(smp->NoOfSamps));
+        sox_readdw(ft, &(smp->NoOfSamps));
         /* mark the start of the sample data */
-        samplestart = st_tell(ft);
+        samplestart = sox_tell(ft);
 
         /* seek from the current position (the start of sample data) by */
         /* NoOfSamps * sizeof(int16_t) */
-        if (st_seeki(ft, smp->NoOfSamps * 2, 1) == -1)
+        if (sox_seeki(ft, smp->NoOfSamps * 2, 1) == -1)
         {
-                st_fail_errno(ft,errno,"SMP unable to seek to trailer");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"SMP unable to seek to trailer");
+                return(SOX_EOF);
         }
         if (readtrailer(ft, &trailer))
         {
-                st_fail_errno(ft,ST_EHDR,"unexpected EOF in SMP trailer");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"unexpected EOF in SMP trailer");
+                return(SOX_EOF);
         }
 
         /* seek back to the beginning of the data */
-        if (st_seeki(ft, samplestart, 0) == -1) 
+        if (sox_seeki(ft, samplestart, 0) == -1) 
         {
-                st_fail_errno(ft,errno,"SMP unable to seek back to start of sample data");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"SMP unable to seek back to start of sample data");
+                return(SOX_EOF);
         }
 
         ft->signal.rate = (int) trailer.rate;
-        ft->signal.size = ST_SIZE_16BIT;
-        ft->signal.encoding = ST_ENCODING_SIGN2;
+        ft->signal.size = SOX_SIZE_16BIT;
+        ft->signal.encoding = SOX_ENCODING_SIGN2;
         ft->signal.channels = 1;
         smp->dataStart = samplestart;
         ft->length = smp->NoOfSamps;
 
-        st_report("SampleVision trailer:");
+        sox_report("SampleVision trailer:");
         for(i = 0; i < 8; i++) if (1 || trailer.loops[i].count) {
-                st_report("Loop %d: start: %6d", i, trailer.loops[i].start);
-                st_report(" end:   %6d", trailer.loops[i].end);
-                st_report(" count: %6d", trailer.loops[i].count);
+                sox_report("Loop %d: start: %6d", i, trailer.loops[i].start);
+                sox_report(" end:   %6d", trailer.loops[i].end);
+                sox_report(" count: %6d", trailer.loops[i].count);
                 switch(trailer.loops[i].type) {
-                    case 0: st_report("type:  off"); break;
-                    case 1: st_report("type:  forward"); break;
-                    case 2: st_report("type:  forward/backward"); break;
+                    case 0: sox_report("type:  off"); break;
+                    case 1: sox_report("type:  forward"); break;
+                    case 2: sox_report("type:  forward/backward"); break;
                 }
         }
-        st_report("MIDI Note number: %d", trailer.MIDInote);
+        sox_report("MIDI Note number: %d", trailer.MIDInote);
 
         ft->instr.nloops = 0;
         for(i = 0; i < 8; i++) 
@@ -306,11 +306,11 @@
         ft->instr.MIDIlow = ft->instr.MIDIhi =
                 ft->instr.MIDInote = trailer.MIDInote;
         if (ft->instr.nloops > 0)
-                ft->instr.loopmode = ST_LOOP_8;
+                ft->instr.loopmode = SOX_LOOP_8;
         else
-                ft->instr.loopmode = ST_LOOP_NONE;
+                ft->instr.loopmode = SOX_LOOP_NONE;
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*
@@ -319,21 +319,21 @@
  * Place in buf[].
  * Return number of samples read.
  */
-static st_size_t st_smpread(ft_t ft, st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_smpread(ft_t ft, sox_sample_t *buf, sox_size_t len) 
 {
         smp_t smp = (smp_t) ft->priv;
         unsigned short datum;
-        st_size_t done = 0;
+        sox_size_t done = 0;
         
         for(; done < len && smp->NoOfSamps; done++, smp->NoOfSamps--) {
-                st_readw(ft, &datum);
+                sox_readw(ft, &datum);
                 /* scale signed up to long's range */
-                *buf++ = ST_SIGNED_WORD_TO_SAMPLE(datum,);
+                *buf++ = SOX_SIGNED_WORD_TO_SAMPLE(datum,);
         }
         return done;
 }
 
-static int st_smpstartwrite(ft_t ft) 
+static int sox_smpstartwrite(ft_t ft) 
 {
         smp_t smp = (smp_t) ft->priv;
         struct smpheader header;
@@ -341,13 +341,13 @@
         /* If you have to seek around the output file */
         if (! ft->seekable)
         {
-                st_fail_errno(ft,ST_EOF,"Output .smp file must be a file, not a pipe");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EOF,"Output .smp file must be a file, not a pipe");
+                return(SOX_EOF);
         }
 
         /* If your format specifies any of the following info. */
-        ft->signal.size = ST_SIZE_16BIT;
-        ft->signal.encoding = ST_ENCODING_SIGN2;
+        ft->signal.size = SOX_SIZE_16BIT;
+        ft->signal.encoding = SOX_ENCODING_SIGN2;
         ft->signal.channels = 1;
 
         strcpy(header.Id, SVmagic);
@@ -356,26 +356,26 @@
         sprintf(header.name, "%-*.*s", NAMELEN, NAMELEN, ft->comment);
 
         /* Write file header */
-        if(st_writebuf(ft, &header, 1, HEADERSIZE) != HEADERSIZE)
+        if(sox_writebuf(ft, &header, 1, HEADERSIZE) != HEADERSIZE)
         {
-            st_fail_errno(ft,errno,"SMP: Can't write header completely");
-            return(ST_EOF);
+            sox_fail_errno(ft,errno,"SMP: Can't write header completely");
+            return(SOX_EOF);
         }
-        st_writedw(ft, 0);      /* write as zero length for now, update later */
+        sox_writedw(ft, 0);      /* write as zero length for now, update later */
         smp->NoOfSamps = 0;
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
-static st_size_t st_smpwrite(ft_t ft, const st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_smpwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len) 
 {
         smp_t smp = (smp_t) ft->priv;
         int datum;
-        st_size_t done = 0;
+        sox_size_t done = 0;
 
         while(done < len) {
-                datum = (int) ST_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips);
-                st_writew(ft, datum);
+                datum = (int) SOX_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips);
+                sox_writew(ft, datum);
                 smp->NoOfSamps++;
                 done++;
         }
@@ -383,7 +383,7 @@
         return(done);
 }
 
-static int st_smpstopwrite(ft_t ft) 
+static int sox_smpstopwrite(ft_t ft) 
 {
         smp_t smp = (smp_t) ft->priv;
         struct smptrailer trailer;
@@ -391,14 +391,14 @@
         /* Assign the trailer data */
         settrailer(ft, &trailer, ft->signal.rate);
         writetrailer(ft, &trailer);
-        if (st_seeki(ft, 112, 0) == -1)
+        if (sox_seeki(ft, 112, 0) == -1)
         {
-                st_fail_errno(ft,errno,"SMP unable to seek back to save size");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"SMP unable to seek back to save size");
+                return(SOX_EOF);
         }
-        st_writedw(ft, smp->NoOfSamps);
+        sox_writedw(ft, smp->NoOfSamps);
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* SampleVision sound */
@@ -407,20 +407,20 @@
   NULL,
 };
 
-static st_format_t st_smp_format = {
+static sox_format_t sox_smp_format = {
   smpnames,
   NULL,
-  ST_FILE_LOOPS | ST_FILE_SEEK | ST_FILE_LIT_END,
-  st_smpstartread,
-  st_smpread,
-  st_format_nothing,
-  st_smpstartwrite,
-  st_smpwrite,
-  st_smpstopwrite,
-  st_smpseek
+  SOX_FILE_LOOPS | SOX_FILE_SEEK | SOX_FILE_LIT_END,
+  sox_smpstartread,
+  sox_smpread,
+  sox_format_nothing,
+  sox_smpstartwrite,
+  sox_smpwrite,
+  sox_smpstopwrite,
+  sox_smpseek
 };
 
-const st_format_t *st_smp_format_fn(void)
+const sox_format_t *sox_smp_format_fn(void)
 {
-    return &st_smp_format;
+    return &sox_smp_format;
 }
--- a/src/sndfile.c
+++ b/src/sndfile.c
@@ -19,7 +19,7 @@
  * Foundation, Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301,
  * USA.  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #ifdef HAVE_SNDFILE_H
 
@@ -36,14 +36,14 @@
   SF_INFO *sf_info;
 } *sndfile_t;
 
-assert_static(sizeof(struct sndfile) <= ST_MAX_FILE_PRIVSIZE, 
+assert_static(sizeof(struct sndfile) <= SOX_MAX_FILE_PRIVSIZE, 
               /* else */ sndfile_PRIVSIZE_too_big);
 
 /* Get sample encoding and size from libsndfile subtype; return value
-   is encoding if conversion was made, or ST_ENCODING_UNKNOWN for
+   is encoding if conversion was made, or SOX_ENCODING_UNKNOWN for
    invalid input. If the libsndfile subtype can't be represented in
    SoX types, use 16-bit signed. */
-static st_encoding_t sox_encoding_and_size(int format, int *size)
+static sox_encoding_t sox_encoding_and_size(int format, int *size)
 {
   *size = -1;                   /* Default */
   format &= SF_FORMAT_SUBMASK;
@@ -50,40 +50,40 @@
   
   switch (format) {
   case SF_FORMAT_PCM_S8:
-    *size = ST_SIZE_8BIT;
-    return ST_ENCODING_SIGN2;
+    *size = SOX_SIZE_8BIT;
+    return SOX_ENCODING_SIGN2;
   case SF_FORMAT_PCM_16:
-    *size = ST_SIZE_16BIT;
-    return ST_ENCODING_SIGN2;
+    *size = SOX_SIZE_16BIT;
+    return SOX_ENCODING_SIGN2;
   case SF_FORMAT_PCM_24:
-    *size = ST_SIZE_24BIT;
-    return ST_ENCODING_SIGN2;
+    *size = SOX_SIZE_24BIT;
+    return SOX_ENCODING_SIGN2;
   case SF_FORMAT_PCM_32:
-    *size = ST_SIZE_32BIT;
-    return ST_ENCODING_SIGN2;
+    *size = SOX_SIZE_32BIT;
+    return SOX_ENCODING_SIGN2;
   case SF_FORMAT_PCM_U8:
-    *size = ST_SIZE_8BIT;
-    return ST_ENCODING_UNSIGNED;
+    *size = SOX_SIZE_8BIT;
+    return SOX_ENCODING_UNSIGNED;
   case SF_FORMAT_FLOAT:
-    *size = ST_SIZE_32BIT;
-    return ST_ENCODING_FLOAT;
+    *size = SOX_SIZE_32BIT;
+    return SOX_ENCODING_FLOAT;
   case SF_FORMAT_DOUBLE:
-    *size = ST_SIZE_64BIT;
-    return ST_ENCODING_FLOAT;
+    *size = SOX_SIZE_64BIT;
+    return SOX_ENCODING_FLOAT;
   case SF_FORMAT_ULAW:
-    *size = ST_SIZE_8BIT;
-    return ST_ENCODING_ULAW;
+    *size = SOX_SIZE_8BIT;
+    return SOX_ENCODING_ULAW;
   case SF_FORMAT_ALAW:
-    *size = ST_SIZE_8BIT;
-    return ST_ENCODING_ALAW;
+    *size = SOX_SIZE_8BIT;
+    return SOX_ENCODING_ALAW;
   case SF_FORMAT_IMA_ADPCM:
-    return ST_ENCODING_IMA_ADPCM;
+    return SOX_ENCODING_IMA_ADPCM;
   case SF_FORMAT_MS_ADPCM:
-    return ST_ENCODING_MS_ADPCM;
+    return SOX_ENCODING_MS_ADPCM;
   case SF_FORMAT_GSM610:
-    return ST_ENCODING_GSM;
+    return SOX_ENCODING_GSM;
   case SF_FORMAT_VOX_ADPCM:
-    return ST_ENCODING_ADPCM;
+    return SOX_ENCODING_ADPCM;
 
   /* For encodings we can't represent, have a sensible default */
   case SF_FORMAT_G721_32:
@@ -95,20 +95,20 @@
   case SF_FORMAT_DWVW_N:
   case SF_FORMAT_DPCM_8:
   case SF_FORMAT_DPCM_16:
-    return ST_ENCODING_SIGN2;
+    return SOX_ENCODING_SIGN2;
 
   default: /* Invalid libsndfile subtype */
-    return ST_ENCODING_UNKNOWN;
+    return SOX_ENCODING_UNKNOWN;
   }
 
   assert(0); /* Should never reach here */
-  return ST_ENCODING_UNKNOWN;
+  return SOX_ENCODING_UNKNOWN;
 }
 
 /*
  * Open file in sndfile.
  */
-int st_sndfile_startread(ft_t ft)
+int sox_sndfile_startread(ft_t ft)
 {
   sndfile_t sf = (sndfile_t)ft->priv;
 
@@ -117,9 +117,9 @@
      invoked stdio buffering. */
   /* FIXME: If format parameters are set, assume file is raw. */
   if ((sf->sf_file = sf_open(ft->filename, SFM_READ, sf->sf_info)) == NULL) {
-    st_fail("sndfile cannot open file for reading: %s", sf_strerror(sf->sf_file));
+    sox_fail("sndfile cannot open file for reading: %s", sf_strerror(sf->sf_file));
     free(sf->sf_file);
-    return ST_EOF;
+    return SOX_EOF;
   }
 
   /* Copy format info */
@@ -128,29 +128,29 @@
   ft->signal.channels = sf->sf_info->channels;
   ft->length = sf->sf_info->frames * sf->sf_info->channels;
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
- * Read up to len samples of type st_sample_t from file into buf[].
+ * Read up to len samples of type sox_sample_t from file into buf[].
  * Return number of samples read.
  */
-st_size_t st_sndfile_read(ft_t ft, st_sample_t *buf, st_size_t len)
+sox_size_t sox_sndfile_read(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
   sndfile_t sf = (sndfile_t)ft->priv;
 
-  /* FIXME: We assume int == st_sample_t here */
-  return (st_size_t)sf_read_int(sf->sf_file, (int *)buf, len);
+  /* FIXME: We assume int == sox_sample_t here */
+  return (sox_size_t)sf_read_int(sf->sf_file, (int *)buf, len);
 }
 
 /*
  * Close file for libsndfile (this doesn't close the file handle)
  */
-int st_sndfile_stopread(ft_t ft)
+int sox_sndfile_stopread(ft_t ft)
 {
   sndfile_t sf = (sndfile_t)ft->priv;
   sf_close(sf->sf_file);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static struct {
@@ -218,18 +218,18 @@
 /* Make libsndfile subtype from sample encoding and size */
 static int sndfile_format(int encoding, int size)
 {
-  if (encoding < ST_ENCODING_SIZE_IS_WORD) {
+  if (encoding < SOX_ENCODING_SIZE_IS_WORD) {
     switch (encoding) {
-    case ST_ENCODING_ULAW:
+    case SOX_ENCODING_ULAW:
       return SF_FORMAT_ULAW;
-    case ST_ENCODING_ALAW:
+    case SOX_ENCODING_ALAW:
       return SF_FORMAT_ALAW;
-    case ST_ENCODING_ADPCM:
-    case ST_ENCODING_MS_ADPCM:
+    case SOX_ENCODING_ADPCM:
+    case SOX_ENCODING_MS_ADPCM:
       return SF_FORMAT_MS_ADPCM;
-    case ST_ENCODING_IMA_ADPCM:
+    case SOX_ENCODING_IMA_ADPCM:
       return SF_FORMAT_IMA_ADPCM;
-    case ST_ENCODING_OKI_ADPCM:
+    case SOX_ENCODING_OKI_ADPCM:
       return SF_FORMAT_VOX_ADPCM;
     default: /* Should be impossible */
       return 0;
@@ -236,24 +236,24 @@
     }
   } else {
     switch (encoding) {
-    case ST_ENCODING_UNSIGNED:
-      if (size == ST_SIZE_8BIT)
+    case SOX_ENCODING_UNSIGNED:
+      if (size == SOX_SIZE_8BIT)
         return SF_FORMAT_PCM_U8;
       else
         return 0;
-    case ST_ENCODING_SIGN2:
-    case ST_ENCODING_MP3:
-    case ST_ENCODING_VORBIS:
+    case SOX_ENCODING_SIGN2:
+    case SOX_ENCODING_MP3:
+    case SOX_ENCODING_VORBIS:
 #ifdef HAVE_SNDFILE_1_0_12
-    case ST_ENCODING_FLAC:
+    case SOX_ENCODING_FLAC:
       switch (size) {
-      case ST_SIZE_8BIT:
+      case SOX_SIZE_8BIT:
         return SF_FORMAT_PCM_S8;
-      case ST_SIZE_16BIT:
+      case SOX_SIZE_16BIT:
         return SF_FORMAT_PCM_16;
-      case ST_SIZE_24BIT:
+      case SOX_SIZE_24BIT:
         return SF_FORMAT_PCM_24;
-      case ST_SIZE_32BIT:
+      case SOX_SIZE_32BIT:
         return SF_FORMAT_PCM_32;
       default: /* invalid size */
         return 0;
@@ -260,9 +260,9 @@
       }
       break;
 #endif
-    case ST_ENCODING_FLOAT:
+    case SOX_ENCODING_FLOAT:
       return SF_FORMAT_FLOAT;
-    case ST_ENCODING_GSM:
+    case SOX_ENCODING_GSM:
       return SF_FORMAT_GSM610;
     default: /* Bad encoding */
       return 0;
@@ -270,7 +270,7 @@
   }
 }
 
-int st_sndfile_startwrite(ft_t ft)
+int sox_sndfile_startwrite(ft_t ft)
 {
   sndfile_t sf = (sndfile_t)ft->priv;
   int subtype = sndfile_format(ft->signal.encoding, ft->signal.size);
@@ -290,7 +290,7 @@
     SF_FORMAT_INFO format_info;
     int i, count;
 
-    st_warn("cannot use desired output encoding, choosing default");
+    sox_warn("cannot use desired output encoding, choosing default");
     sf_command(sf->sf_file, SFC_GET_SIMPLE_FORMAT_COUNT, &count, sizeof(int));
     for (i = 0; i < count; i++) {
       format_info.format = i;
@@ -304,46 +304,46 @@
     }
 
     if (!sf_format_check(sf->sf_info)) {
-      st_fail("cannot find a usable output encoding");
-      return ST_EOF;
+      sox_fail("cannot find a usable output encoding");
+      return SOX_EOF;
     }
   }
 
   if ((sf->sf_file = sf_open(ft->filename, SFM_WRITE, sf->sf_info)) == NULL) {
-    st_fail("sndfile cannot open file for writing: %s", sf_strerror(sf->sf_file));
-    return ST_EOF;
+    sox_fail("sndfile cannot open file for writing: %s", sf_strerror(sf->sf_file));
+    return SOX_EOF;
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
- * Write len samples of type st_sample_t from buf[] to file.
+ * Write len samples of type sox_sample_t from buf[] to file.
  * Return number of samples written.
  */
-st_size_t st_sndfile_write(ft_t ft, const st_sample_t *buf, st_size_t len)
+sox_size_t sox_sndfile_write(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
   sndfile_t sf = (sndfile_t)ft->priv;
 
-  /* FIXME: We assume int == st_sample_t here */
-  return (st_size_t)sf_write_int(sf->sf_file, (int *)buf, len);
+  /* FIXME: We assume int == sox_sample_t here */
+  return (sox_size_t)sf_write_int(sf->sf_file, (int *)buf, len);
 }
 
 /*
  * Close file for libsndfile (this doesn't close the file handle)
  */
-int st_sndfile_stopwrite(ft_t ft)
+int sox_sndfile_stopwrite(ft_t ft)
 {
   sndfile_t sf = (sndfile_t)ft->priv;
   sf_close(sf->sf_file);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-int st_sndfile_seek(ft_t ft, st_size_t offset)
+int sox_sndfile_seek(ft_t ft, sox_size_t offset)
 {
   sndfile_t sf = (sndfile_t)ft->priv;
   sf_seek(sf->sf_file, offset / ft->signal.channels, SEEK_CUR);
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /* Format file suffixes */
@@ -380,22 +380,22 @@
 };
 
 /* Format descriptor */
-static st_format_t st_sndfile_format = {
+static sox_format_t sox_sndfile_format = {
   names,
   NULL,
-  ST_FILE_SEEK,
-  st_sndfile_startread,
-  st_sndfile_read,
-  st_sndfile_stopread,
-  st_sndfile_startwrite,
-  st_sndfile_write,
-  st_sndfile_stopwrite,
-  st_sndfile_seek
+  SOX_FILE_SEEK,
+  sox_sndfile_startread,
+  sox_sndfile_read,
+  sox_sndfile_stopread,
+  sox_sndfile_startwrite,
+  sox_sndfile_write,
+  sox_sndfile_stopwrite,
+  sox_sndfile_seek
 };
 
-const st_format_t *st_sndfile_format_fn(void)
+const sox_format_t *sox_sndfile_format_fn(void)
 {
-  return &st_sndfile_format;
+  return &sox_sndfile_format;
 }
 
 #endif
--- a/src/sndrtool.c
+++ b/src/sndrtool.c
@@ -7,7 +7,7 @@
  *   Forced extra comment fields to zero.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <math.h>
 #include <string.h>
@@ -16,33 +16,33 @@
 
 /* Private data used by writer */
 typedef struct sndpriv {
-        st_size_t nsamples;
-        st_size_t dataStart;
+        sox_size_t nsamples;
+        sox_size_t dataStart;
 } *snd_t;
 
-static void sndtwriteheader(ft_t ft, st_size_t nsamples)
+static void sndtwriteheader(ft_t ft, sox_size_t nsamples)
 {
     char name_buf[97];
 
     /* sndtool header */
-    st_writes(ft, "SOUND"); /* magic */
-    st_writeb(ft, 0x1a);
-    st_writew (ft,0);  /* hGSound */
-    st_writedw (ft,nsamples);
-    st_writedw (ft,0);
-    st_writedw (ft,nsamples);
-    st_writew (ft,(int) ft->signal.rate);
-    st_writew (ft,0);
-    st_writew (ft,10);
-    st_writew (ft,4);
+    sox_writes(ft, "SOUND"); /* magic */
+    sox_writeb(ft, 0x1a);
+    sox_writew (ft,0);  /* hGSound */
+    sox_writedw (ft,nsamples);
+    sox_writedw (ft,0);
+    sox_writedw (ft,nsamples);
+    sox_writew (ft,(int) ft->signal.rate);
+    sox_writew (ft,0);
+    sox_writew (ft,10);
+    sox_writew (ft,4);
     memset (name_buf, 0, 96);
     sprintf (name_buf,"%.62s - File created by SoX",ft->filename);
-    st_writebuf(ft, name_buf, 1, 96);
+    sox_writebuf(ft, name_buf, 1, 96);
 }
 
-static int st_sndseek(ft_t ft, st_size_t offset) 
+static int sox_sndseek(ft_t ft, sox_size_t offset) 
 {
-    st_size_t new_offset, channel_block, alignment;
+    sox_size_t new_offset, channel_block, alignment;
     snd_t snd = (snd_t ) ft->priv;
 
     new_offset = offset * ft->signal.size;
@@ -57,10 +57,10 @@
         new_offset += (channel_block - alignment);
     new_offset += snd->dataStart;
 
-    return st_seeki(ft, new_offset, SEEK_SET);
+    return sox_seeki(ft, new_offset, SEEK_SET);
 }
 
-static int st_sndtstartread(ft_t ft)
+static int sox_sndtstartread(ft_t ft)
 {
         snd_t snd = (snd_t ) ft->priv;
 
@@ -70,7 +70,7 @@
         int rc;
 
         /* Needed for rawread() */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
@@ -82,100 +82,100 @@
          and second word is between 4000 & 25000 then this is sounder sound */
         /* otherwise, its probably raw, not handled here */
 
-        if (st_readbuf(ft, buf, 1, 2) != 2)
+        if (sox_readbuf(ft, buf, 1, 2) != 2)
         {
-                st_fail_errno(ft,errno,"SND: unexpected EOF");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"SND: unexpected EOF");
+                return(SOX_EOF);
         }
         if (strncmp(buf,"\0\0",2) == 0)
         {
         /* sounder */
-        st_readw(ft, &rate);
+        sox_readw(ft, &rate);
         if (rate < 4000 || rate > 25000 )
         {
-                st_fail_errno(ft,ST_EFMT,"SND: sample rate out of range");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EFMT,"SND: sample rate out of range");
+                return(SOX_EOF);
         }
-        st_seeki(ft, 4, SEEK_CUR);
+        sox_seeki(ft, 4, SEEK_CUR);
         }
         else
         {
         /* sndtool ? */
-        st_readbuf(ft, &buf[2], 1, 6);
+        sox_readbuf(ft, &buf[2], 1, 6);
         if (strncmp(buf,"SOUND",5))
         {
-                st_fail_errno(ft,ST_EFMT,"SND: unrecognized SND format");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EFMT,"SND: unrecognized SND format");
+                return(SOX_EOF);
         }
-        st_seeki(ft, 12, SEEK_CUR);
-        st_readw(ft, &rate);
-        st_seeki(ft, 6, SEEK_CUR);
-        if (st_reads(ft, buf, 96) == ST_EOF)
+        sox_seeki(ft, 12, SEEK_CUR);
+        sox_readw(ft, &rate);
+        sox_seeki(ft, 6, SEEK_CUR);
+        if (sox_reads(ft, buf, 96) == SOX_EOF)
         {
-                st_fail_errno(ft,ST_EHDR,"SND: unexpected EOF in SND header");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"SND: unexpected EOF in SND header");
+                return(SOX_EOF);
         }
-        st_debug("%s",buf);
+        sox_debug("%s",buf);
         }
 
         ft->signal.channels = 1;
         ft->signal.rate = rate;
-        ft->signal.encoding = ST_ENCODING_UNSIGNED;
-        ft->signal.size = ST_SIZE_BYTE;
+        ft->signal.encoding = SOX_ENCODING_UNSIGNED;
+        ft->signal.size = SOX_SIZE_BYTE;
 
-        snd->dataStart = st_tell(ft);
-        ft->length = st_filelength(ft) - snd->dataStart;
+        snd->dataStart = sox_tell(ft);
+        ft->length = sox_filelength(ft) - snd->dataStart;
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
-static int st_sndtstartwrite(ft_t ft)
+static int sox_sndtstartwrite(ft_t ft)
 {
         snd_t p = (snd_t ) ft->priv;
         int rc;
 
         /* Needed for rawwrite() */
-        rc = st_rawstartwrite(ft);
+        rc = sox_rawstartwrite(ft);
         if (rc)
             return rc;
 
         /* write header */
         ft->signal.channels = 1;
-        ft->signal.encoding = ST_ENCODING_UNSIGNED;
-        ft->signal.size = ST_SIZE_BYTE;
+        ft->signal.encoding = SOX_ENCODING_UNSIGNED;
+        ft->signal.size = SOX_SIZE_BYTE;
         p->nsamples = 0;
         sndtwriteheader(ft, 0);
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
-static st_size_t st_sndtwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static sox_size_t sox_sndtwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
         snd_t p = (snd_t ) ft->priv;
         p->nsamples += len;
-        return st_rawwrite(ft, buf, len);
+        return sox_rawwrite(ft, buf, len);
 }
 
-static int st_sndtstopwrite(ft_t ft)
+static int sox_sndtstopwrite(ft_t ft)
 {
         snd_t p = (snd_t ) ft->priv;
         int rc;
 
         /* Flush remaining buffer out */
-        rc = st_rawstopwrite(ft);
+        rc = sox_rawstopwrite(ft);
         if (rc)
             return rc;
 
         /* fixup file sizes in header */
-        if (st_seeki(ft, 0, 0) != 0){
-                st_fail_errno(ft,errno,"can't rewind output file to rewrite SND header");
-                return ST_EOF;
+        if (sox_seeki(ft, 0, 0) != 0){
+                sox_fail_errno(ft,errno,"can't rewind output file to rewrite SND header");
+                return SOX_EOF;
         }
                 
         sndtwriteheader(ft, p->nsamples);
                 
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /* Sndtool Sound File */
@@ -184,20 +184,20 @@
   NULL
 };
 
-const st_format_t st_snd_format = {
+const sox_format_t sox_snd_format = {
   sndtnames,
   NULL,
-  ST_FILE_SEEK | ST_FILE_LIT_END,
-  st_sndtstartread,
-  st_rawread,
-  st_rawstopread,
-  st_sndtstartwrite,
-  st_sndtwrite,
-  st_sndtstopwrite,
-  st_sndseek
+  SOX_FILE_SEEK | SOX_FILE_LIT_END,
+  sox_sndtstartread,
+  sox_rawread,
+  sox_rawstopread,
+  sox_sndtstartwrite,
+  sox_sndtwrite,
+  sox_sndtstopwrite,
+  sox_sndseek
 };
 
-const st_format_t *st_snd_format_fn(void)
+const sox_format_t *sox_snd_format_fn(void)
 {
-    return &st_snd_format;
+    return &sox_snd_format;
 }
--- a/src/sox.c
+++ b/src/sox.c
@@ -22,7 +22,7 @@
  * USA.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <math.h>
 #include <stdio.h>
 #include <string.h>
@@ -55,48 +55,48 @@
 #include <io.h>
 #endif
 
-static st_bool play = st_false, rec = st_false;
+static sox_bool play = sox_false, rec = sox_false;
 static enum {SOX_sequence, SOX_concatenate, SOX_mix, SOX_merge} combine_method = SOX_concatenate;
-static st_size_t mixing_clips = 0;
-static st_bool repeatable_random = st_false;  /* Whether to invoke srand. */
-static st_bool interactive = st_false;
-static st_globalinfo_t globalinfo = {st_false, 1};
-static st_bool uservolume = st_false;
+static sox_size_t mixing_clips = 0;
+static sox_bool repeatable_random = sox_false;  /* Whether to invoke srand. */
+static sox_bool interactive = sox_false;
+static sox_globalinfo_t globalinfo = {sox_false, 1};
+static sox_bool uservolume = sox_false;
 typedef enum {RG_off, RG_track, RG_album} rg_mode;
 static rg_mode replay_gain_mode = RG_off;
 
-static st_bool user_abort = st_false;
-static st_bool user_skip = st_false;
+static sox_bool user_abort = sox_false;
+static sox_bool user_skip = sox_false;
 static int success = 0;
 
-static st_option_t show_progress = ST_OPTION_DEFAULT;
+static sox_option_t show_progress = SOX_OPTION_DEFAULT;
 static unsigned long input_wide_samples = 0;
 static unsigned long read_wide_samples = 0;
 static unsigned long output_samples = 0;
 
-static st_sample_t ibufl[ST_BUFSIZ / 2]; /* Left/right interleave buffers */
-static st_sample_t ibufr[ST_BUFSIZ / 2];
-static st_sample_t obufl[ST_BUFSIZ / 2];
-static st_sample_t obufr[ST_BUFSIZ / 2];
+static sox_sample_t ibufl[SOX_BUFSIZ / 2]; /* Left/right interleave buffers */
+static sox_sample_t ibufr[SOX_BUFSIZ / 2];
+static sox_sample_t obufl[SOX_BUFSIZ / 2];
+static sox_sample_t obufr[SOX_BUFSIZ / 2];
 
 typedef struct file_info
 {
   char *filename;
   char *filetype;
-  st_signalinfo_t signal;
+  sox_signalinfo_t signal;
   double volume;
   double replay_gain;
   char *comment;
-  st_size_t volume_clips;
+  sox_size_t volume_clips;
   ft_t desc;                              /* stlib file descriptor */
 } *file_t;
 
 /* local forward declarations */
-static st_bool doopts(file_t, int, char **);
+static sox_bool doopts(file_t, int, char **);
 static void usage(char const *) NORET;
 static void usage_effect(char *) NORET;
 static int process(void);
-static void update_status(st_bool all_done);
+static void update_status(sox_bool all_done);
 static void report_file_info(file_t f);
 static void parse_effects(int argc, char **argv);
 static void build_effects_table(void);
@@ -116,7 +116,7 @@
 static size_t file_count = 0;
 static size_t input_count = 0;
 static size_t current_input = 0;
-static st_signalinfo_t combiner, ofile_signal;
+static sox_signalinfo_t combiner, ofile_signal;
 
 /* We parse effects into a temporary effects table and then place into
  * the real effects table.  This makes it easier to reorder some effects
@@ -137,40 +137,40 @@
  *
  * If one was to support effects for quad-channel files, there would
  * need to be an effect table for each channel to handle effects
- * that don't set ST_EFF_MCHAN.
+ * that don't set SOX_EFF_MCHAN.
  */
 
-static struct st_effect efftab[MAX_EFF]; /* left/mono channel effects */
-static struct st_effect efftabR[MAX_EFF];/* right channel effects */
+static struct sox_effect efftab[MAX_EFF]; /* left/mono channel effects */
+static struct sox_effect efftabR[MAX_EFF];/* right channel effects */
 static int neffects;                     /* # of effects to run on data */
 static int input_eff;                    /* last input effect with data */
 static int input_eff_eof;                /* has input_eff reached EOF? */
 
-static struct st_effect user_efftab[MAX_USER_EFF];
+static struct sox_effect user_efftab[MAX_USER_EFF];
 static int nuser_effects;
 
 static char *myname = NULL;
 
-static void sox_output_message(int level, const char *filename, const char *fmt, va_list ap)
+static void output_message(int level, const char *filename, const char *fmt, va_list ap)
 {
-  if (st_output_verbosity_level >= level) {
+  if (sox_output_verbosity_level >= level) {
     fprintf(stderr, "%s ", myname);
-    st_output_message(stderr, filename, fmt, ap);
+    sox_output_message(stderr, filename, fmt, ap);
     fprintf(stderr, "\n");
   }
 }
 
-static st_bool overwrite_permitted(char const * filename)
+static sox_bool overwrite_permitted(char const * filename)
 {
   char c;
 
   if (!interactive) {
-    st_report("Overwriting '%s'", filename);
-    return st_true;
+    sox_report("Overwriting '%s'", filename);
+    return sox_true;
   }
-  st_warn("Output file '%s' already exists", filename);
+  sox_warn("Output file '%s' already exists", filename);
   if (!isatty(fileno(stdin)))
-    return st_false;
+    return sox_false;
   do fprintf(stderr, "%s sox: overwrite '%s' (y/n)? ", myname, filename);
   while (scanf(" %c%*[^\n]", &c) != 1 || !strchr("yYnN", c));
   return c == 'y' || c == 'Y';
@@ -184,7 +184,7 @@
   /* Close the input and output files before exiting. */
   for (i = 0; i < input_count; i++) {
     if (files[i]->desc) {
-      st_close(files[i]->desc);
+      sox_close(files[i]->desc);
       free(files[i]->desc);
     }
     free(files[i]);
@@ -192,7 +192,7 @@
 
   if (file_count) {
     if (ofile->desc) {
-      if (!(ofile->desc->h->flags & ST_FILE_NOSTDIO)) {
+      if (!(ofile->desc->h->flags & SOX_FILE_NOSTDIO)) {
         struct stat st;
         fstat(fileno(ofile->desc->fp), &st);
 
@@ -201,8 +201,8 @@
           unlink(ofile->desc->filename);
       }
 
-      /* Assumption: we can unlink a file before st_closing it. */
-      st_close(ofile->desc);
+      /* Assumption: we can unlink a file before sox_closing it. */
+      sox_close(ofile->desc);
       free(ofile->desc);
     }
     free(ofile);
@@ -214,11 +214,11 @@
   file_t f = xcalloc(sizeof(*f), 1);
 
   f->signal.size = -1;
-  f->signal.encoding = ST_ENCODING_UNKNOWN;
+  f->signal.encoding = SOX_ENCODING_UNKNOWN;
   f->signal.channels = 0;
-  f->signal.reverse_bytes = ST_OPTION_DEFAULT;
-  f->signal.reverse_nibbles = ST_OPTION_DEFAULT;
-  f->signal.reverse_bits = ST_OPTION_DEFAULT;
+  f->signal.reverse_bytes = SOX_OPTION_DEFAULT;
+  f->signal.reverse_nibbles = SOX_OPTION_DEFAULT;
+  f->signal.reverse_bits = SOX_OPTION_DEFAULT;
   f->signal.compression = HUGE_VAL;
   f->volume = HUGE_VAL;
   f->replay_gain = HUGE_VAL;
@@ -240,7 +240,7 @@
   f->filetype = "sunau";
   f->filename = xstrdup(device ? device : "/dev/audio");
 #else
-  st_fail("Sorry, there is no default audio device configured");
+  sox_fail("Sorry, there is no default audio device configured");
   exit(1);
 #endif
 }
@@ -276,13 +276,13 @@
     fi_none = *f;
 
     if (file_count >= MAX_FILES) {
-      st_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
+      sox_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
       exit(1);
     }
 
     if (doopts(f, argc, argv)) { /* is null file? */
       if (f->filetype != NULL && strcmp(f->filetype, "null") != 0)
-        st_warn("Ignoring '-t %s'.", f->filetype);
+        sox_warn("Ignoring '-t %s'.", f->filetype);
       f->filetype = "null";
       f->filename = xstrdup("-n");
     } else {
@@ -296,7 +296,7 @@
 
   if (play) {
     if (file_count >= MAX_FILES) {
-      st_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
+      sox_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
       exit(1);
     }
 
@@ -311,10 +311,10 @@
   }
 
   if (rec) {
-    st_size_t i;
+    sox_size_t i;
 
     if (file_count >= MAX_FILES) {
-      st_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
+      sox_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
       exit(1);
     }
 
@@ -334,17 +334,17 @@
 
   myname = argv[0];
   atexit(cleanup);
-  st_output_message_handler = sox_output_message;
+  sox_output_message_handler = output_message;
 
   i = strlen(myname);
   if (i >= sizeof("play") - 1 &&
       strcmp(myname + i - (sizeof("play") - 1), "play") == 0) {
-    play = st_true;
+    play = sox_true;
     replay_gain_mode = RG_track;
     combine_method = SOX_sequence;
   } else if (i >= sizeof("rec") - 1 &&
       strcmp(myname + i - (sizeof("rec") - 1), "rec") == 0) {
-    rec = st_true;
+    rec = sox_true;
   }
   parse_options_and_filenames(argc, argv);
 
@@ -384,15 +384,15 @@
         f->signal.channels = files[1]->signal.channels;
       }
     }
-    files[j]->desc = st_open_read(f->filename, &f->signal, f->filetype);
+    files[j]->desc = sox_open_read(f->filename, &f->signal, f->filetype);
     if (!files[j]->desc)
-      /* st_open_read() will call st_warn for most errors.
+      /* sox_open_read() will call sox_warn for most errors.
        * Rely on that printing something. */
       exit(2);
-    if (show_progress == ST_OPTION_DEFAULT &&
-        (files[j]->desc->h->flags & ST_FILE_DEVICE) != 0 &&
-        (files[j]->desc->h->flags & ST_FILE_PHONY) == 0)
-      show_progress = ST_OPTION_YES;
+    if (show_progress == SOX_OPTION_DEFAULT &&
+        (files[j]->desc->h->flags & SOX_FILE_DEVICE) != 0 &&
+        (files[j]->desc->h->flags & SOX_FILE_PHONY) == 0)
+      show_progress = SOX_OPTION_YES;
     if (files[j]->desc->comment)
       set_replay_gain(files[j]->desc->comment, f);
   }
@@ -409,7 +409,7 @@
   }
 
   if (repeatable_random)
-    st_debug("Not reseeding PRNG; randomness is repeatable");
+    sox_debug("Not reseeding PRNG; randomness is repeatable");
   else {
     time_t t;
 
@@ -420,9 +420,9 @@
   ofile_signal = ofile->signal;
   if (combine_method == SOX_sequence) do {
     if (ofile->desc)
-      st_close(ofile->desc);
+      sox_close(ofile->desc);
     free(ofile->desc);
-  } while (process() != ST_EOF && !user_abort && current_input < input_count);
+  } while (process() != SOX_EOF && !user_abort && current_input < input_count);
   else process();
 
   delete_effects();
@@ -429,18 +429,18 @@
 
   for (i = 0; i < file_count; ++i)
     if (files[i]->desc->clips != 0)
-      st_warn(i < input_count?"%s: input clipped %u samples" :
+      sox_warn(i < input_count?"%s: input clipped %u samples" :
                               "%s: output clipped %u samples; decrease volume?",
-          (files[i]->desc->h->flags & ST_FILE_DEVICE)?
+          (files[i]->desc->h->flags & SOX_FILE_DEVICE)?
                        files[i]->desc->h->names[0] : files[i]->desc->filename,
           files[i]->desc->clips);
 
   if (mixing_clips > 0)
-    st_warn("mix-combining clipped %u samples; decrease volume?", mixing_clips);
+    sox_warn("mix-combining clipped %u samples; decrease volume?", mixing_clips);
 
   for (i = 0; i < file_count; i++)
     if (files[i]->volume_clips > 0)
-      st_warn("%s: balancing clipped %u samples; decrease volume?", files[i]->filename,
+      sox_warn("%s: balancing clipped %u samples; decrease volume?", files[i]->filename,
               files[i]->volume_clips);
 
   if (show_progress) {
@@ -456,13 +456,13 @@
 
 static char * read_comment_file(char const * const filename)
 {
-  st_bool file_error;
+  sox_bool file_error;
   int file_length = 0;
   char * result;
   FILE * file = fopen(filename, "rt");
 
   if (file == NULL) {
-    st_fail("Cannot open comment file %s", filename);
+    sox_fail("Cannot open comment file %s", filename);
     exit(1);
   }
   file_error = fseeko(file, (off_t)0, SEEK_END);
@@ -476,7 +476,7 @@
     }
   }
   if (file_error) {
-    st_fail("Error reading comment file %s", filename);
+    sox_fail("Error reading comment file %s", filename);
     exit(1);
   }
   fclose(file);
@@ -546,7 +546,7 @@
       set = xrealloc(set, len += 2 + strlen(p->text));
       strcat(set, ", "); strcat(set, p->text);
     }
-    st_fail("--%s: '%s' is not one of: %s.",
+    sox_fail("--%s: '%s' is not one of: %s.",
         long_options[option_index].name, optarg, set + 2);
     free(set);
     exit(1);
@@ -569,25 +569,25 @@
     if (input_count == 1 && neffects > 1 &&
         strcmp(efftab[1].name, "trim") == 0)
     {
-        if ((files[0]->desc->h->flags & ST_FILE_SEEK) &&
+        if ((files[0]->desc->h->flags & SOX_FILE_SEEK) &&
             files[0]->desc->seekable)
         { 
-            if (st_seek(files[0]->desc, st_trim_get_start(&efftab[1]), 
-                        ST_SEEK_SET) != ST_EOF)
+            if (sox_seek(files[0]->desc, sox_trim_get_start(&efftab[1]), 
+                        SOX_SEEK_SET) != SOX_EOF)
             { 
                 /* Assuming a failed seek stayed where it was.  If the 
                  * seek worked then reset the start location of 
                  * trim so that it thinks user didn't request a skip.
                  */ 
-                st_trim_clear_start(&efftab[1]);
+                sox_trim_clear_start(&efftab[1]);
             }    
         }        
     }    
 }
 
-static st_bool doopts(file_t f, int argc, char **argv)
+static sox_bool doopts(file_t f, int argc, char **argv)
 {
-  while (st_true) {
+  while (sox_true) {
     int option_index;
     int i;          /* Needed since scanf %u allows negative numbers :( */
     char dummy;     /* To check for extraneous chars in optarg. */
@@ -594,7 +594,7 @@
 
     switch (getopt_long(argc, argv, getoptstr, long_options, &option_index)) {
     case -1:        /* @ one of: file-name, effect name, end of arg-list. */
-      return st_false; /* I.e. not null file. */
+      return sox_false; /* I.e. not null file. */
 
     case 0:         /* Long options with no short equivalent. */
       switch (option_index) {
@@ -612,14 +612,14 @@
 
       case 3:
         switch (enum_option(option_index, endian_options)) {
-          case ENDIAN_little: f->signal.reverse_bytes = ST_IS_BIGENDIAN; break;
-          case ENDIAN_big: f->signal.reverse_bytes = ST_IS_LITTLEENDIAN; break;
-          case ENDIAN_swap: f->signal.reverse_bytes = st_true; break;
+          case ENDIAN_little: f->signal.reverse_bytes = SOX_IS_BIGENDIAN; break;
+          case ENDIAN_big: f->signal.reverse_bytes = SOX_IS_LITTLEENDIAN; break;
+          case ENDIAN_swap: f->signal.reverse_bytes = sox_true; break;
         }
         break;
 
       case 4:
-        interactive = st_true;
+        interactive = sox_true;
         break;
 
       case 5:
@@ -627,7 +627,7 @@
         break;
 
       case 6:
-        globalinfo.octave_plot_effect = st_true;
+        globalinfo.octave_plot_effect = sox_true;
         break;
 
       case 7:
@@ -650,11 +650,11 @@
       break;
 
     case 'R': /* Useful for regression testing. */
-      repeatable_random = st_true;
+      repeatable_random = sox_true;
       break;
 
     case 'e': case 'n':
-      return st_true;  /* I.e. is null file. */
+      return sox_true;  /* I.e. is null file. */
       break;
 
     case 'h': case '?':
@@ -669,7 +669,7 @@
 
     case 'r':
       if (sscanf(optarg, "%i %c", &i, &dummy) != 1 || i <= 0) {
-        st_fail("Rate value '%s' is not a positive integer", optarg);
+        sox_fail("Rate value '%s' is not a positive integer", optarg);
         exit(1);
       }
       f->signal.rate = i;
@@ -677,18 +677,18 @@
 
     case 'v':
       if (sscanf(optarg, "%lf %c", &f->volume, &dummy) != 1) {
-        st_fail("Volume value '%s' is not a number", optarg);
+        sox_fail("Volume value '%s' is not a number", optarg);
         exit(1);
       }
-      uservolume = st_true;
+      uservolume = sox_true;
       if (f->volume < 0.0)
-        st_report("Volume adjustment is negative; "
+        sox_report("Volume adjustment is negative; "
                   "this will result in a phase change");
       break;
 
     case 'c':
       if (sscanf(optarg, "%i %c", &i, &dummy) != 1 || i <= 0) {
-        st_fail("Channels value '%s' is not a positive integer", optarg);
+        sox_fail("Channels value '%s' is not a positive integer", optarg);
         exit(1);
       }
       f->signal.channels = i;
@@ -696,52 +696,52 @@
 
     case 'C':
       if (sscanf(optarg, "%lf %c", &f->signal.compression, &dummy) != 1) {
-        st_fail("Compression value '%s' is not a number", optarg);
+        sox_fail("Compression value '%s' is not a number", optarg);
         exit(1);
       }
       break;
 
-    case '1': case 'b': f->signal.size = ST_SIZE_BYTE;   break;
-    case '2': case 'w': f->signal.size = ST_SIZE_16BIT;   break;
-    case '3':           f->signal.size = ST_SIZE_24BIT;  break;
-    case '4': case 'l': f->signal.size = ST_SIZE_32BIT;  break;
-    case '8': case 'd': f->signal.size = ST_SIZE_64BIT; break;
+    case '1': case 'b': f->signal.size = SOX_SIZE_BYTE;   break;
+    case '2': case 'w': f->signal.size = SOX_SIZE_16BIT;   break;
+    case '3':           f->signal.size = SOX_SIZE_24BIT;  break;
+    case '4': case 'l': f->signal.size = SOX_SIZE_32BIT;  break;
+    case '8': case 'd': f->signal.size = SOX_SIZE_64BIT; break;
 
-    case 's': f->signal.encoding = ST_ENCODING_SIGN2;     break;
-    case 'u': f->signal.encoding = ST_ENCODING_UNSIGNED;  break;
-    case 'f': f->signal.encoding = ST_ENCODING_FLOAT;     break;
-    case 'a': f->signal.encoding = ST_ENCODING_ADPCM;     break;
-    case 'D': f->signal.encoding = ST_ENCODING_MS_ADPCM;  break;
-    case 'i': f->signal.encoding = ST_ENCODING_IMA_ADPCM; break;
-    case 'o': f->signal.encoding = ST_ENCODING_OKI_ADPCM; break;
-    case 'g': f->signal.encoding = ST_ENCODING_GSM;       break;
+    case 's': f->signal.encoding = SOX_ENCODING_SIGN2;     break;
+    case 'u': f->signal.encoding = SOX_ENCODING_UNSIGNED;  break;
+    case 'f': f->signal.encoding = SOX_ENCODING_FLOAT;     break;
+    case 'a': f->signal.encoding = SOX_ENCODING_ADPCM;     break;
+    case 'D': f->signal.encoding = SOX_ENCODING_MS_ADPCM;  break;
+    case 'i': f->signal.encoding = SOX_ENCODING_IMA_ADPCM; break;
+    case 'o': f->signal.encoding = SOX_ENCODING_OKI_ADPCM; break;
+    case 'g': f->signal.encoding = SOX_ENCODING_GSM;       break;
 
-    case 'U': f->signal.encoding = ST_ENCODING_ULAW;
+    case 'U': f->signal.encoding = SOX_ENCODING_ULAW;
       if (f->signal.size == -1)
-        f->signal.size = ST_SIZE_BYTE;
+        f->signal.size = SOX_SIZE_BYTE;
       break;
 
-    case 'A': f->signal.encoding = ST_ENCODING_ALAW;
+    case 'A': f->signal.encoding = SOX_ENCODING_ALAW;
       if (f->signal.size == -1)
-        f->signal.size = ST_SIZE_BYTE;
+        f->signal.size = SOX_SIZE_BYTE;
       break;
 
-    case 'L': f->signal.reverse_bytes   = ST_IS_BIGENDIAN;    break;
-    case 'B': f->signal.reverse_bytes   = ST_IS_LITTLEENDIAN; break;
-    case 'x': f->signal.reverse_bytes   = ST_OPTION_YES;      break;
-    case 'X': f->signal.reverse_bits    = ST_OPTION_YES;      break;
-    case 'N': f->signal.reverse_nibbles = ST_OPTION_YES;      break;
+    case 'L': f->signal.reverse_bytes   = SOX_IS_BIGENDIAN;    break;
+    case 'B': f->signal.reverse_bytes   = SOX_IS_LITTLEENDIAN; break;
+    case 'x': f->signal.reverse_bytes   = SOX_OPTION_YES;      break;
+    case 'X': f->signal.reverse_bits    = SOX_OPTION_YES;      break;
+    case 'N': f->signal.reverse_nibbles = SOX_OPTION_YES;      break;
 
-    case 'S': show_progress = ST_OPTION_YES; break;
-    case 'q': show_progress = ST_OPTION_NO;  break;
+    case 'S': show_progress = SOX_OPTION_YES; break;
+    case 'q': show_progress = SOX_OPTION_NO;  break;
 
     case 'V':
       if (optarg == NULL)
-        ++st_output_verbosity_level;
-      else if (sscanf(optarg, "%i %c", &st_output_verbosity_level, &dummy) != 1
-          || st_output_verbosity_level < 0) {
-        st_output_verbosity_level = 2;
-        st_fail("Verbosity value '%s' is not an integer >= 0", optarg);
+        ++sox_output_verbosity_level;
+      else if (sscanf(optarg, "%i %c", &sox_output_verbosity_level, &dummy) != 1
+          || sox_output_verbosity_level < 0) {
+        sox_output_verbosity_level = 2;
+        sox_fail("Verbosity value '%s' is not an integer >= 0", optarg);
         exit(1);
       }
       break;
@@ -759,13 +759,13 @@
   return string[i];
 }
 
-static void display_file_info(file_t f, st_bool full)
+static void display_file_info(file_t f, sox_bool full)
 {
   static char const * const no_yes[] = {"no", "yes"};
 
   fprintf(stderr, "\n%s: '%s'",
     f->desc->mode == 'r'? "Input File     " : "Output File    ", f->desc->filename);
-  if (strcmp(f->desc->filename, "-") == 0 || (f->desc->h->flags & ST_FILE_DEVICE))
+  if (strcmp(f->desc->filename, "-") == 0 || (f->desc->h->flags & SOX_FILE_DEVICE))
     fprintf(stderr, " (%s)", f->desc->h->names[0]);
 
   fprintf(stderr, "\n"
@@ -773,14 +773,14 @@
     "Sample Encoding: %s\n"
     "Channels       : %u\n"
     "Sample Rate    : %u\n",
-    st_size_bits_str[f->desc->signal.size], st_sizes_str[f->desc->signal.size],
-    st_encodings_str[f->desc->signal.encoding],
+    sox_size_bits_str[f->desc->signal.size], sox_sizes_str[f->desc->signal.size],
+    sox_encodings_str[f->desc->signal.encoding],
     f->desc->signal.channels,
     f->desc->signal.rate);
 
   if (full) {
     if (f->desc->length && f->desc->signal.channels && f->desc->signal.rate) {
-      st_size_t ws = f->desc->length / f->desc->signal.channels;
+      sox_size_t ws = f->desc->length / f->desc->signal.channels;
       fprintf(stderr,
         "Duration       : %s = %u samples = %g CDDA sectors\n",
         str_time((double)ws / f->desc->signal.rate),
@@ -791,7 +791,7 @@
       "Reverse Nibbles: %s\n"
       "Reverse Bits   : %s\n",
       f->desc->signal.size == 1? "N/A" :
-        f->desc->signal.reverse_bytes != ST_IS_BIGENDIAN ? "big" : "little",
+        f->desc->signal.reverse_bytes != SOX_IS_BIGENDIAN ? "big" : "little",
       no_yes[f->desc->signal.reverse_nibbles],
       no_yes[f->desc->signal.reverse_bits]);
   }
@@ -801,7 +801,7 @@
   if (f->volume != HUGE_VAL)
     fprintf(stderr, "Level adjust   : %g (linear gain)\n" , f->volume);
 
-  if (!(f->desc->h->flags & ST_FILE_DEVICE) && f->desc->comment) {
+  if (!(f->desc->h->flags & SOX_FILE_DEVICE) && f->desc->comment) {
     if (strchr(f->desc->comment, '\n'))
       fprintf(stderr, "Comments       : \n%s\n", f->desc->comment);
     else
@@ -812,8 +812,8 @@
 
 static void report_file_info(file_t f)
 {
-  if (st_output_verbosity_level > 2)
-    display_file_info(f, st_true);
+  if (sox_output_verbosity_level > 2)
+    display_file_info(f, sox_true);
 }
 
 static void progress_to_file(file_t f)
@@ -820,19 +820,19 @@
 {
   read_wide_samples = 0;
   input_wide_samples = f->desc->length / f->desc->signal.channels;
-  if (show_progress && (st_output_verbosity_level < 3 ||
+  if (show_progress && (sox_output_verbosity_level < 3 ||
                         (combine_method <= SOX_concatenate && input_count > 1)))
-    display_file_info(f, st_false);
+    display_file_info(f, sox_false);
   if (f->volume == HUGE_VAL)
     f->volume = 1;
   if (f->replay_gain != HUGE_VAL)
     f->volume *= pow(10.0, f->replay_gain / 20);
-  f->desc->st_errno = errno = 0;
+  f->desc->sox_errno = errno = 0;
 }
 
-static st_bool since(struct timeval * then, double secs, st_bool always_reset)
+static sox_bool since(struct timeval * then, double secs, sox_bool always_reset)
 {
-  st_bool ret;
+  sox_bool ret;
   struct timeval now;
   time_t d;
   gettimeofday(&now, NULL);
@@ -847,12 +847,12 @@
 {
   static struct timeval then;
   if (show_progress && s == SIGINT && combine_method <= SOX_concatenate &&
-      since(&then, 1., st_true))
-    user_skip = st_true;
-  else user_abort = st_true;
+      since(&then, 1., sox_true))
+    user_skip = sox_true;
+  else user_abort = sox_true;
 }
 
-static st_bool can_segue(st_size_t i)
+static sox_bool can_segue(sox_size_t i)
 {
   return
     files[i]->desc->signal.channels == files[i - 1]->desc->signal.channels &&
@@ -859,23 +859,23 @@
     files[i]->desc->signal.rate     == files[i - 1]->desc->signal.rate;
 }
 
-static st_size_t st_read_wide(ft_t desc, st_sample_t * buf)
+static sox_size_t sox_read_wide(ft_t desc, sox_sample_t * buf)
 {
-  st_size_t len = ST_BUFSIZ / combiner.channels;
-  len = st_read(desc, buf, len * desc->signal.channels) / desc->signal.channels;
-  if (!len && desc->st_errno)
-    st_fail("%s: %s (%s)", desc->filename, desc->st_errstr, strerror(desc->st_errno));
+  sox_size_t len = SOX_BUFSIZ / combiner.channels;
+  len = sox_read(desc, buf, len * desc->signal.channels) / desc->signal.channels;
+  if (!len && desc->sox_errno)
+    sox_fail("%s: %s (%s)", desc->filename, desc->sox_errstr, strerror(desc->sox_errno));
   return len;
 }
 
-static void balance_input(st_sample_t * buf, st_size_t ws, file_t f)
+static void balance_input(sox_sample_t * buf, sox_size_t ws, file_t f)
 {
-  st_size_t s = ws * f->desc->signal.channels;
+  sox_size_t s = ws * f->desc->signal.channels;
 
   if (f->volume != 1)
     while (s--) {
       double d = f->volume * *buf;
-      *buf++ = ST_ROUND_CLIP_COUNT(d, f->volume_clips);
+      *buf++ = SOX_ROUND_CLIP_COUNT(d, f->volume_clips);
     }
 }
 
@@ -885,9 +885,9 @@
 
 static int process(void) {
   int e, flowstatus = 0;
-  st_size_t ws, s, i;
-  st_size_t ilen[MAX_INPUT_FILES];
-  st_sample_t *ibuf[MAX_INPUT_FILES];
+  sox_size_t ws, s, i;
+  sox_size_t ilen[MAX_INPUT_FILES];
+  sox_sample_t *ibuf[MAX_INPUT_FILES];
 
   combiner = files[current_input]->desc->signal;
   if (combine_method == SOX_sequence) {
@@ -894,11 +894,11 @@
     if (!current_input) for (i = 0; i < input_count; i++)
       report_file_info(files[i]);
   } else {
-    st_size_t total_channels = 0;
-    st_size_t min_channels = ST_SIZE_MAX;
-    st_size_t max_channels = 0;
-    st_size_t min_rate = ST_SIZE_MAX;
-    st_size_t max_rate = 0;
+    sox_size_t total_channels = 0;
+    sox_size_t min_channels = SOX_SIZE_MAX;
+    sox_size_t max_channels = 0;
+    sox_size_t min_rate = SOX_SIZE_MAX;
+    sox_size_t max_rate = 0;
 
     for (i = 0; i < input_count; i++) { /* Report all inputs, then check */
       report_file_info(files[i]);
@@ -909,13 +909,13 @@
       max_rate = max(max_rate, files[i]->desc->signal.rate);
     }
     if (min_rate != max_rate)
-      st_fail("Input files must have the same sample-rate");
+      sox_fail("Input files must have the same sample-rate");
     if (min_channels != max_channels) {
       if (combine_method == SOX_concatenate) {
-        st_fail("Input files must have the same # channels");
+        sox_fail("Input files must have the same # channels");
         exit(1);
       } else if (combine_method == SOX_mix)
-        st_warn("Input files don't have the same # channels");
+        sox_warn("Input files don't have the same # channels");
     }
     if (min_rate != max_rate)
       exit(1);
@@ -929,7 +929,7 @@
     ofile->signal.rate = combiner.rate;
   if (ofile->signal.size == -1)
     ofile->signal.size = combiner.size;
-  if (ofile->signal.encoding == ST_ENCODING_UNKNOWN)
+  if (ofile->signal.encoding == SOX_ENCODING_UNKNOWN)
     ofile->signal.encoding = combiner.encoding;
   if (ofile->signal.channels == 0)
     ofile->signal.channels = combiner.channels;
@@ -937,7 +937,7 @@
   combiner.rate = combiner.rate * globalinfo.speed + .5;
 
   {
-    st_loopinfo_t loops[ST_MAX_NLOOPS];
+    sox_loopinfo_t loops[SOX_MAX_NLOOPS];
     double factor;
     int i;
     char const *comment = NULL;
@@ -954,7 +954,7 @@
      * effects that change file length.
      */
     factor = (double) ofile->signal.rate / combiner.rate;
-    for (i = 0; i < ST_MAX_NLOOPS; i++) {
+    for (i = 0; i < SOX_MAX_NLOOPS; i++) {
       loops[i].start = files[0]->desc->loops[i].start * factor;
       loops[i].length = files[0]->desc->loops[i].length * factor;
       loops[i].count = files[0]->desc->loops[i].count;
@@ -961,7 +961,7 @@
       loops[i].type = files[0]->desc->loops[i].type;
     }
 
-    ofile->desc = st_open_write(overwrite_permitted,
+    ofile->desc = sox_open_write(overwrite_permitted,
                           ofile->filename,
                           &ofile->signal,
                           ofile->filetype,
@@ -970,7 +970,7 @@
                           loops);
 
     if (!ofile->desc)
-      /* st_open_write() will call st_warn for most errors.
+      /* sox_open_write() will call sox_warn for most errors.
        * Rely on that printing something. */
       exit(2);
 
@@ -977,9 +977,9 @@
     /* When writing to an audio device, auto turn on the
      * progress display to match behavior of ogg123,
      * unless the user requested us not to display anything. */
-    if (show_progress == ST_OPTION_DEFAULT)
-      show_progress = (ofile->desc->h->flags & ST_FILE_DEVICE) != 0 &&
-                      (ofile->desc->h->flags & ST_FILE_PHONY) == 0;
+    if (show_progress == SOX_OPTION_DEFAULT)
+      show_progress = (ofile->desc->h->flags & SOX_FILE_DEVICE) != 0 &&
+                      (ofile->desc->h->flags & SOX_FILE_PHONY) == 0;
 
     report_file_info(ofile);
   }
@@ -986,14 +986,14 @@
 
   build_effects_table();
 
-  if (start_all_effects() != ST_SUCCESS)
+  if (start_all_effects() != SOX_SUCCESS)
     exit(2); /* Failing effect should have displayed an error message */
 
   /* Allocate output buffers for effects */
   for (e = 0; e < neffects; e++) {
-    efftab[e].obuf = (st_sample_t *)xmalloc(ST_BUFSIZ * sizeof(st_sample_t));
+    efftab[e].obuf = (sox_sample_t *)xmalloc(SOX_BUFSIZ * sizeof(sox_sample_t));
     if (efftabR[e].name)
-      efftabR[e].obuf = (st_sample_t *)xmalloc(ST_BUFSIZ * sizeof(st_sample_t));
+      efftabR[e].obuf = (sox_sample_t *)xmalloc(SOX_BUFSIZ * sizeof(sox_sample_t));
   }
 
   if (combine_method <= SOX_concatenate)
@@ -1001,7 +1001,7 @@
   else {
     ws = 0;
     for (i = 0; i < input_count; i++) {
-      ibuf[i] = (st_sample_t *)xmalloc(ST_BUFSIZ * sizeof(st_sample_t));
+      ibuf[i] = (sox_sample_t *)xmalloc(SOX_BUFSIZ * sizeof(sox_sample_t));
       progress_to_file(files[i]);
       ws = max(ws, input_wide_samples);
     }
@@ -1024,11 +1024,11 @@
     efftab[0].olen = 0;
     if (combine_method <= SOX_concatenate) {
       if (!user_skip)
-        efftab[0].olen = st_read_wide(files[current_input]->desc, efftab[0].obuf);
+        efftab[0].olen = sox_read_wide(files[current_input]->desc, efftab[0].obuf);
       if (efftab[0].olen == 0) {   /* If EOF, go to the next input file. */
-        update_status(st_true);
+        update_status(sox_true);
         if (user_skip) {
-          user_skip = st_false;
+          user_skip = sox_false;
           fprintf(stderr, "Skipped.\n");
         }
         if (++current_input < input_count) {
@@ -1040,9 +1040,9 @@
       }
       balance_input(efftab[0].obuf, efftab[0].olen, files[current_input]);
     } else {
-      st_sample_t * p = efftab[0].obuf;
+      sox_sample_t * p = efftab[0].obuf;
       for (i = 0; i < input_count; ++i) {
-        ilen[i] = st_read_wide(files[i]->desc, ibuf[i]);
+        ilen[i] = sox_read_wide(files[i]->desc, ibuf[i]);
         balance_input(ibuf[i], ilen[i], files[i]);
         efftab[0].olen = max(efftab[0].olen, ilen[i]);
       }
@@ -1054,7 +1054,7 @@
               if (ws < ilen[i] && s < files[i]->desc->signal.channels) {
                 /* Cast to double prevents integer overflow */
                 double sample = *p + (double)ibuf[i][ws * files[i]->desc->signal.channels + s];
-                *p = ST_ROUND_CLIP_COUNT(sample, mixing_clips);
+                *p = SOX_ROUND_CLIP_COUNT(sample, mixing_clips);
             }
           }
         } else { /* SOX_merge: like a multi-track recorder */
@@ -1070,7 +1070,7 @@
     read_wide_samples += efftab[0].olen;
     efftab[0].olen *= combiner.channels;
     flowstatus = flow_effect_out();
-    update_status(user_abort || ofile->desc->st_errno || flowstatus);
+    update_status(user_abort || ofile->desc->sox_errno || flowstatus);
 
     /* Quit reading/writing on user aborts.  This will close
      * the files nicely as if an EOF was reached on read. */
@@ -1078,12 +1078,12 @@
       break;
 
     /* If there's an error, don't try to write more. */
-    if (ofile->desc->st_errno)
+    if (ofile->desc->sox_errno)
       break;
   } while (flowstatus == 0);
 
   /* Drain the effects; don't write if output is indicating errors. */
-  if (ofile->desc->st_errno == 0)
+  if (ofile->desc->sox_errno == 0)
     drain_effect_out();
 
   if (combine_method > SOX_concatenate)
@@ -1107,24 +1107,24 @@
   int argc_effect;
 
   for (nuser_effects = 0; optind < argc; ++nuser_effects) {
-    struct st_effect * e = &user_efftab[nuser_effects];
+    struct sox_effect * e = &user_efftab[nuser_effects];
     int (*getopts)(eff_t effp, int argc, char *argv[]);
 
     if (nuser_effects >= MAX_USER_EFF) {
-      st_fail("too many effects specified (at most %i allowed)", MAX_USER_EFF);
+      sox_fail("too many effects specified (at most %i allowed)", MAX_USER_EFF);
       exit(1);
     }
 
-    argc_effect = st_geteffect_opt(e, argc - optind, &argv[optind]);
-    if (argc_effect == ST_EOF) {
-      st_fail("Effect `%s' does not exist!", argv[optind]);
+    argc_effect = sox_geteffect_opt(e, argc - optind, &argv[optind]);
+    if (argc_effect == SOX_EOF) {
+      sox_fail("Effect `%s' does not exist!", argv[optind]);
       exit(1);
     }
 
     optind++; /* Skip past effect name */
     e->globalinfo = &globalinfo;
-    getopts = e->h->getopts?  e->h->getopts : st_effect_nothing_getopts;
-    if (getopts(e, argc_effect, &argv[optind]) == ST_EOF)
+    getopts = e->h->getopts?  e->h->getopts : sox_effect_nothing_getopts;
+    if (getopts(e, argc_effect, &argv[optind]) == SOX_EOF)
       exit(2);
 
     optind += argc_effect; /* Skip past the effect arguments */
@@ -1133,14 +1133,14 @@
 
 static void add_effect(int * effects_mask)
 {
-  struct st_effect * e = &efftab[neffects];
+  struct sox_effect * e = &efftab[neffects];
 
   /* Copy format info to effect table */
   *effects_mask =
-    st_updateeffect(e, &combiner, &ofile->desc->signal, *effects_mask);
+    sox_updateeffect(e, &combiner, &ofile->desc->signal, *effects_mask);
 
   /* If this effect can't handle multiple channels then account for this. */
-  if (e->ininfo.channels > 1 && !(e->h->flags & ST_EFF_MCHAN))
+  if (e->ininfo.channels > 1 && !(e->h->flags & SOX_EFF_MCHAN))
     memcpy(&efftabR[neffects], e, sizeof(*e));
   else memset(&efftabR[neffects], 0, sizeof(*e));
 
@@ -1149,16 +1149,16 @@
 
 static void add_default_effect(char const * name, int * effects_mask)
 {
-  struct st_effect * e = &efftab[neffects];
+  struct sox_effect * e = &efftab[neffects];
   int (*getopts)(eff_t effp, int argc, char *argv[]);
 
   /* Find effect and update initial pointers */
-  st_geteffect(e, name);
+  sox_geteffect(e, name);
 
   /* Set up & give default opts for added effects */
   e->globalinfo = &globalinfo;
-  getopts = e->h->getopts?  e->h->getopts : st_effect_nothing_getopts;
-  if (getopts(e, 0, NULL) == ST_EOF)
+  getopts = e->h->getopts?  e->h->getopts : sox_effect_nothing_getopts;
+  if (getopts(e, 0, NULL) == SOX_EOF)
     exit(2);
 
   add_effect(effects_mask);
@@ -1170,8 +1170,8 @@
 {
   int i;
   int effects_mask = 0;
-  st_bool need_rate = combiner.rate     != ofile->desc->signal.rate;
-  st_bool need_chan = combiner.channels != ofile->desc->signal.channels;
+  sox_bool need_rate = combiner.rate     != ofile->desc->signal.rate;
+  sox_bool need_chan = combiner.channels != ofile->desc->signal.channels;
 
   { /* Check if we have to add effects to change rate/chans or if the
        user has specified effects to do this, in which case, check if
@@ -1179,21 +1179,21 @@
     int user_chan_effects = 0, user_rate_effects = 0;
 
     for (i = 0; i < nuser_effects; i++) {
-      if (user_efftab[i].h->flags & ST_EFF_CHAN) {
-        need_chan = st_false;
+      if (user_efftab[i].h->flags & SOX_EFF_CHAN) {
+        need_chan = sox_false;
         ++user_chan_effects;
       }
-      if (user_efftab[i].h->flags & ST_EFF_RATE) {
-        need_rate = st_false;
+      if (user_efftab[i].h->flags & SOX_EFF_RATE) {
+        need_rate = sox_false;
         ++user_rate_effects;
       }
     }
     if (user_chan_effects > 1) {
-      st_fail("Cannot specify multiple effects that change number of channels");
+      sox_fail("Cannot specify multiple effects that change number of channels");
       exit(2);
     }
     if (user_rate_effects > 1)
-      st_report("Cannot specify multiple effects that change sample rate");
+      sox_report("Cannot specify multiple effects that change sample rate");
       /* FIXME: exit here or add comment as to why not */
   }
 
@@ -1205,13 +1205,13 @@
   /* If reducing channels, it's faster to do so before all other effects: */
   if (need_chan && combiner.channels > ofile->desc->signal.channels) {
     add_default_effect("mixer", &effects_mask);
-    need_chan = st_false;
+    need_chan = sox_false;
   }
   /* If reducing rate, it's faster to do so before all other effects
    * (except reducing channels): */
   if (need_rate && combiner.rate > ofile->desc->signal.rate) {
     add_default_effect("resample", &effects_mask);
-    need_rate = st_false;
+    need_rate = sox_false;
   }
   /* Copy user specified effects into the real efftab */
   for (i = 0; i < nuser_effects; i++) {
@@ -1230,25 +1230,25 @@
 
 static int start_all_effects(void)
 {
-  int i, j, ret = ST_SUCCESS;
+  int i, j, ret = SOX_SUCCESS;
 
   for (i = 1; i < neffects; i++) {
-    struct st_effect * e = &efftab[i];
-    st_bool is_always_null = (e->h->flags & ST_EFF_NULL) != 0;
-    int (*start)(eff_t effp) = e->h->start? e->h->start : st_effect_nothing;
+    struct sox_effect * e = &efftab[i];
+    sox_bool is_always_null = (e->h->flags & SOX_EFF_NULL) != 0;
+    int (*start)(eff_t effp) = e->h->start? e->h->start : sox_effect_nothing;
 
     if (is_always_null)
-      st_report("'%s' has no effect (is a proxy effect)", e->name);
+      sox_report("'%s' has no effect (is a proxy effect)", e->name);
     else {
       e->clips = 0;
       ret = start(e);
-      if (ret == ST_EFF_NULL)
-        st_warn("'%s' has no effect in this configuration", e->name);
-      else if (ret != ST_SUCCESS)
-        return ST_EOF;
+      if (ret == SOX_EFF_NULL)
+        sox_warn("'%s' has no effect in this configuration", e->name);
+      else if (ret != SOX_SUCCESS)
+        return SOX_EOF;
     }
-    if (is_always_null || ret == ST_EFF_NULL) { /* remove from the chain */
-      int (*delete)(eff_t effp) = e->h->kill? e->h->kill: st_effect_nothing;
+    if (is_always_null || ret == SOX_EFF_NULL) { /* remove from the chain */
+      int (*delete)(eff_t effp) = e->h->kill? e->h->kill: sox_effect_nothing;
 
       /* No left & right delete as there is no left & right getopts */
       delete(e);
@@ -1261,17 +1261,17 @@
     /* No null checks here; the left channel looks after this */
     else if (efftabR[i].name) {
       efftabR[i].clips = 0;
-      if (start(&efftabR[i]) != ST_SUCCESS)
-        return ST_EOF;
+      if (start(&efftabR[i]) != SOX_SUCCESS)
+        return SOX_EOF;
     }
   }
   for (i = 1; i < neffects; ++i) {
-    struct st_effect * e = &efftab[i];
-    st_report("Effects chain: %-10s %-6s %uHz", e->name,
+    struct sox_effect * e = &efftab[i];
+    sox_report("Effects chain: %-10s %-6s %uHz", e->name,
         e->ininfo.channels < 2 ? "mono" :
-        (e->h->flags & ST_EFF_MCHAN)? "multi" : "stereo", e->ininfo.rate);
+        (e->h->flags & SOX_EFF_MCHAN)? "multi" : "stereo", e->ininfo.rate);
   }
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static int flow_effect_out(void)
@@ -1290,7 +1290,7 @@
       if (e == input_eff && input_eff_eof)
         continue;
 
-      /* flow_effect returns ST_EOF when it will not process
+      /* flow_effect returns SOX_EOF when it will not process
        * any more samples.  This is used to bail out early.
        * Since we are "pulling" data, it is OK that we are not
        * calling any more previous effects since their output
@@ -1297,7 +1297,7 @@
        * would not be looked at anyways.
        */
       flowstatus = flow_effect(e);
-      if (flowstatus == ST_EOF) {
+      if (flowstatus == SOX_EOF) {
         input_eff = e;
         /* Assume next effect hasn't reach EOF yet */
         input_eff_eof = 0;
@@ -1310,7 +1310,7 @@
        * starts with an empty output buffer.
        */
       if (efftab[e].odone < efftab[e].olen) {
-        st_debug_more("Breaking out of loop to flush buffer");
+        sox_debug_more("Breaking out of loop to flush buffer");
         break;
       }
     }
@@ -1323,15 +1323,15 @@
          * we may be stuck in an infinite writing loop.
          */
         if (user_abort)
-          return ST_EOF;
+          return SOX_EOF;
 
-        len = st_write(ofile->desc,
+        len = sox_write(ofile->desc,
                        &efftab[neffects - 1].obuf[total],
                        efftab[neffects - 1].olen - total);
 
         if (len == 0 || ofile->desc->eof) {
-          st_warn("Error writing: %s", ofile->desc->st_errstr);
-          return ST_EOF;
+          sox_warn("Error writing: %s", ofile->desc->sox_errstr);
+          return SOX_EOF;
         }
         total += len;
       } while (total < efftab[neffects-1].olen);
@@ -1345,7 +1345,7 @@
     }
 
     /* if stuff still in pipeline, set up to flow effects again */
-    /* When all effects have reported ST_EOF then this check will
+    /* When all effects have reported SOX_EOF then this check will
      * show no more data.
      */
     havedata = 0;
@@ -1367,7 +1367,7 @@
             ofile->desc->signal.channels)
           havedata = 1;
         else
-          st_warn("Received buffer with incomplete amount of samples.");
+          sox_warn("Received buffer with incomplete amount of samples.");
         /* Don't break out because other things are being
          * done in loop.
          */
@@ -1398,7 +1398,7 @@
           input_eff_eof = 0;
         } else {
           havedata = 1;
-          input_eff_eof = (rc == ST_EOF) ? 1 : 0;
+          input_eff_eof = (rc == SOX_EOF) ? 1 : 0;
           break;
         }
       }
@@ -1410,31 +1410,31 @@
    * fact to caller.
    */
   if (input_eff > 0) {
-    st_debug("Effect return ST_EOF");
-    return ST_EOF;
+    sox_debug("Effect return SOX_EOF");
+    return SOX_EOF;
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static int flow_effect(int e)
 {
-  st_size_t i, done, idone, odone, idonel, odonel, idoner, odoner;
-  const st_sample_t *ibuf;
-  st_sample_t *obuf;
+  sox_size_t i, done, idone, odone, idonel, odonel, idoner, odoner;
+  const sox_sample_t *ibuf;
+  sox_sample_t *obuf;
   int effstatus, effstatusl, effstatusr;
-  int (*flow)(eff_t, st_sample_t const*, st_sample_t*, st_size_t*, st_size_t*) =
-    efftab[e].h->flow? efftab[e].h->flow : st_effect_nothing_flow;
+  int (*flow)(eff_t, sox_sample_t const*, sox_sample_t*, sox_size_t*, sox_size_t*) =
+    efftab[e].h->flow? efftab[e].h->flow : sox_effect_nothing_flow;
 
   /* Do not attempt to do any more effect processing during
    * user aborts as we may be stuck in an infinite flow loop.
    */
   if (user_abort)
-    return ST_EOF;
+    return SOX_EOF;
 
   /* I have no input data ? */
   if (efftab[e - 1].odone == efftab[e - 1].olen) {
-    st_debug("%s no data to pull to me!", efftab[e].name);
+    sox_debug("%s no data to pull to me!", efftab[e].name);
     return 0;
   }
 
@@ -1443,21 +1443,21 @@
      * run effect over entire buffer.
      */
     idone = efftab[e - 1].olen - efftab[e - 1].odone;
-    odone = ST_BUFSIZ - efftab[e].olen;
-    st_debug_more("pre %s idone=%d, odone=%d", efftab[e].name, idone, odone);
-    st_debug_more("pre %s odone1=%d, olen1=%d odone=%d olen=%d", efftab[e].name, efftab[e-1].odone, efftab[e-1].olen, efftab[e].odone, efftab[e].olen);
+    odone = SOX_BUFSIZ - efftab[e].olen;
+    sox_debug_more("pre %s idone=%d, odone=%d", efftab[e].name, idone, odone);
+    sox_debug_more("pre %s odone1=%d, olen1=%d odone=%d olen=%d", efftab[e].name, efftab[e-1].odone, efftab[e-1].olen, efftab[e].odone, efftab[e].olen);
 
     effstatus = flow(&efftab[e],
                      &efftab[e - 1].obuf[efftab[e - 1].odone],
                      &efftab[e].obuf[efftab[e].olen],
-                     (st_size_t *)&idone,
-                     (st_size_t *)&odone);
+                     (sox_size_t *)&idone,
+                     (sox_size_t *)&odone);
 
     efftab[e - 1].odone += idone;
     /* Don't update efftab[e].odone as we didn't consume data */
     efftab[e].olen += odone;
-    st_debug_more("post %s idone=%d, odone=%d", efftab[e].name, idone, odone);
-    st_debug_more("post %s odone1=%d, olen1=%d odone=%d olen=%d", efftab[e].name, efftab[e-1].odone, efftab[e-1].olen, efftab[e].odone, efftab[e].olen);
+    sox_debug_more("post %s idone=%d, odone=%d", efftab[e].name, idone, odone);
+    sox_debug_more("post %s odone1=%d, olen1=%d odone=%d olen=%d", efftab[e].name, efftab[e-1].odone, efftab[e-1].olen, efftab[e].odone, efftab[e].olen);
 
     done = idone + odone;
   } else {
@@ -1465,7 +1465,7 @@
      * on each of them.
      */
     idone = efftab[e - 1].olen - efftab[e - 1].odone;
-    odone = ST_BUFSIZ - efftab[e].olen;
+    odone = SOX_BUFSIZ - efftab[e].olen;
 
     ibuf = &efftab[e - 1].obuf[efftab[e - 1].odone];
     for (i = 0; i < idone; i += 2) {
@@ -1476,19 +1476,19 @@
     /* left */
     idonel = (idone + 1) / 2;   /* odd-length logic */
     odonel = odone / 2;
-    st_debug_more("pre %s idone=%d, odone=%d", efftab[e].name, idone, odone);
-    st_debug_more("pre %s odone1=%d, olen1=%d odone=%d olen=%d", efftab[e].name, efftab[e - 1].odone, efftab[e - 1].olen, efftab[e].odone, efftab[e].olen);
+    sox_debug_more("pre %s idone=%d, odone=%d", efftab[e].name, idone, odone);
+    sox_debug_more("pre %s odone1=%d, olen1=%d odone=%d olen=%d", efftab[e].name, efftab[e - 1].odone, efftab[e - 1].olen, efftab[e].odone, efftab[e].olen);
 
     effstatusl = flow(&efftab[e],
-                      ibufl, obufl, (st_size_t *)&idonel,
-                      (st_size_t *)&odonel);
+                      ibufl, obufl, (sox_size_t *)&idonel,
+                      (sox_size_t *)&odonel);
 
     /* right */
     idoner = idone / 2;               /* odd-length logic */
     odoner = odone / 2;
     effstatusr = flow(&efftabR[e],
-                      ibufr, obufr, (st_size_t *)&idoner,
-                      (st_size_t *)&odoner);
+                      ibufr, obufr, (sox_size_t *)&idoner,
+                      (sox_size_t *)&odoner);
 
     obuf = &efftab[e].obuf[efftab[e].olen];
     /* This loop implies left and right effect will always output
@@ -1501,8 +1501,8 @@
     efftab[e-1].odone += idonel + idoner;
     /* Don't zero efftab[e].odone since nothing has been consumed yet */
     efftab[e].olen += odonel + odoner;
-    st_debug_more("post %s idone=%d, odone=%d", efftab[e].name, idone, odone);
-    st_debug_more("post %s odone1=%d, olen1=%d odone=%d olen=%d", efftab[e].name, efftab[e - 1].odone, efftab[e - 1].olen, efftab[e].odone, efftab[e].olen);
+    sox_debug_more("post %s idone=%d, odone=%d", efftab[e].name, idone, odone);
+    sox_debug_more("post %s odone1=%d, olen1=%d odone=%d olen=%d", efftab[e].name, efftab[e - 1].odone, efftab[e - 1].olen, efftab[e].odone, efftab[e].olen);
 
     done = idonel + idoner + odonel + odoner;
 
@@ -1511,13 +1511,13 @@
     else
       effstatus = effstatusr;
   }
-  if (effstatus == ST_EOF)
-    return ST_EOF;
+  if (effstatus == SOX_EOF)
+    return SOX_EOF;
   if (done == 0) {
-    st_fail("Effect took & gave no samples!");
+    sox_fail("Effect took & gave no samples!");
     exit(2);
   }
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 static int drain_effect_out(void)
@@ -1538,7 +1538,7 @@
       /* Assuming next effect hasn't reached EOF yet. */
       input_eff_eof = 0;
     } else {
-      input_eff_eof = (rc == ST_EOF) ? 1 : 0;
+      input_eff_eof = (rc == SOX_EOF) ? 1 : 0;
       break;
     }
   }
@@ -1549,33 +1549,33 @@
 
 static int drain_effect(int e)
 {
-  st_ssize_t i, olen, olenl, olenr;
-  st_sample_t *obuf;
+  sox_ssize_t i, olen, olenl, olenr;
+  sox_sample_t *obuf;
   int rc;
-  int (*drain)(eff_t effp, st_sample_t *obuf, st_size_t *osamp) =
-    efftab[e].h->drain? efftab[e].h->drain : st_effect_nothing_drain;
+  int (*drain)(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp) =
+    efftab[e].h->drain? efftab[e].h->drain : sox_effect_nothing_drain;
 
   if (! efftabR[e].name) {
-    efftab[e].olen = ST_BUFSIZ;
+    efftab[e].olen = SOX_BUFSIZ;
     rc = drain(&efftab[e],efftab[e].obuf, &efftab[e].olen);
     efftab[e].odone = 0;
   } else {
     int rc_l, rc_r;
 
-    olen = ST_BUFSIZ;
+    olen = SOX_BUFSIZ;
 
     /* left */
     olenl = olen/2;
-    rc_l = drain(&efftab[e], obufl, (st_size_t *)&olenl);
+    rc_l = drain(&efftab[e], obufl, (sox_size_t *)&olenl);
 
     /* right */
     olenr = olen/2;
-    rc_r = drain(&efftabR[e], obufr, (st_size_t *)&olenr);
+    rc_r = drain(&efftabR[e], obufr, (sox_size_t *)&olenr);
 
-    if (rc_l == ST_EOF || rc_r == ST_EOF)
-      rc = ST_EOF;
+    if (rc_l == SOX_EOF || rc_r == SOX_EOF)
+      rc = SOX_EOF;
     else
-      rc = ST_SUCCESS;
+      rc = SOX_SUCCESS;
 
     obuf = efftab[e].obuf;
     /* This loop implies left and right effect will always output
@@ -1596,9 +1596,9 @@
   int e;
 
   for (e = 1; e < neffects; e++) {
-    st_size_t clips;
+    sox_size_t clips;
     int (*stop)(eff_t effp) =
-       efftab[e].h->stop? efftab[e].h->stop : st_effect_nothing;
+       efftab[e].h->stop? efftab[e].h->stop : sox_effect_nothing;
 
     stop(&efftab[e]);
     clips = efftab[e].clips;
@@ -1608,7 +1608,7 @@
       clips += efftab[e].clips;
     }
     if (clips != 0)
-      st_warn("'%s' clipped %u samples; decrease volume?",efftab[e].name,clips);
+      sox_warn("'%s' clipped %u samples; decrease volume?",efftab[e].name,clips);
   }
 }
 
@@ -1618,7 +1618,7 @@
 
   for (e = 1; e < neffects; e++) {
     int (*delete)(eff_t effp) =
-       efftab[e].h->kill? efftab[e].h->kill : st_effect_nothing;
+       efftab[e].h->kill? efftab[e].h->kill : sox_effect_nothing;
 
     /* No left & right delete as there is no left & right getopts */
     delete(&efftab[e]);
@@ -1625,10 +1625,10 @@
   }
 }
 
-static st_size_t total_clips(void)
+static sox_size_t total_clips(void)
 {
   int i;
-  st_size_t clips = 0;
+  sox_size_t clips = 0;
   for (i = 0; i < file_count; ++i)
     clips += files[i]->desc->clips + files[i]->volume_clips;
   clips += mixing_clips;
@@ -1640,7 +1640,7 @@
   return clips;
 }
 
-static char const * sigfigs3(st_size_t number)
+static char const * sigfigs3(sox_size_t number)
 {
   static char string[16][10];
   static unsigned n;
@@ -1669,12 +1669,12 @@
   }
 }
 
-static void update_status(st_bool all_done)
+static void update_status(sox_bool all_done)
 {
   static struct timeval then;
   if (!show_progress)
     return;
-  if (all_done || since(&then, .15, st_false)) {
+  if (all_done || since(&then, .15, sox_false)) {
     double read_time = (double)read_wide_samples / combiner.rate;
     double left_time = 0, in_time = 0, percentage = 0;
 
@@ -1700,7 +1700,7 @@
 {
   size_t i, formats;
   const char **format_list;
-  const st_effect_t *e;
+  const sox_effect_t *e;
 
   printf("%s: ", myname);
   printf("SoX Version %s\n\n", PACKAGE_VERSION);
@@ -1755,14 +1755,14 @@
          "\n");
 
   printf("SUPPORTED FILE FORMATS:");
-  for (i = 0, formats = 0; st_format_fns[i]; i++) {
-    char const * const *names = st_format_fns[i]()->names;
+  for (i = 0, formats = 0; sox_format_fns[i]; i++) {
+    char const * const *names = sox_format_fns[i]()->names;
     while (*names++)
       formats++;
   }
   format_list = (const char **)xmalloc(formats * sizeof(char *));
-  for (i = 0, formats = 0; st_format_fns[i]; i++) {
-    char const * const *names = st_format_fns[i]()->names;
+  for (i = 0, formats = 0; sox_format_fns[i]; i++) {
+    char const * const *names = sox_format_fns[i]()->names;
     while (*names)
       format_list[formats++] = *names++;
   }
@@ -1772,9 +1772,9 @@
   free(format_list);
 
   printf("\n\nSUPPORTED EFFECTS:");
-  for (i = 0; st_effect_fns[i]; i++) {
-    e = st_effect_fns[i]();
-    if (e && e->name && !(e->flags & ST_EFF_DEPRECATED))
+  for (i = 0; sox_effect_fns[i]; i++) {
+    e = sox_effect_fns[i]();
+    if (e && e->name && !(e->flags & SOX_EFF_DEPRECATED))
       printf(" %s", e->name);
   }
 
@@ -1789,7 +1789,7 @@
 static void usage_effect(char *effect)
 {
   int i;
-  const st_effect_t *e;
+  const sox_effect_t *e;
 
   printf("%s: ", myname);
   printf("v%s\n\n", PACKAGE_VERSION);
@@ -1796,8 +1796,8 @@
 
   printf("Effect usage:\n\n");
 
-  for (i = 0; st_effect_fns[i]; i++) {
-    e = st_effect_fns[i]();
+  for (i = 0; sox_effect_fns[i]; i++) {
+    e = sox_effect_fns[i]();
     if (e && e->name && (!strcmp("all", effect) ||  !strcmp(e->name, effect))) {
       char *p = strstr(e->usage, "Usage: ");
       printf("%s\n\n", p ? p + 7 : e->usage);
--- /dev/null
+++ b/src/sox.h
@@ -1,0 +1,452 @@
+/*
+ * Sound Tools Library
+ *
+ * Copyright 1999-2007 Chris Bagwell and SoX Contributors.
+ *
+ * This source code is freely redistributable and may be used for
+ * any purpose.  This copyright notice must be maintained.
+ * Chris Bagwell And SoX Contributors are not responsible for
+ * the consequences of using this software.
+ */
+
+#ifndef SOX_H
+#define SOX_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "ststdint.h"
+
+/* The following is the API version of libst.  It is not meant
+ * to follow the version number of SoX but it has historically.
+ * Please do not count of these numbers being in sync.
+ * The following is at 13.0.0
+ */
+#define SOX_LIB_VERSION_CODE 0x0d0000
+#define SOX_LIB_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+
+/* Avoid warnings about unused parameters. */
+#ifdef __GNUC__
+#define UNUSED __attribute__ ((unused))
+#endif
+
+/* C language enhancements: */
+
+/* Boolean type, compatible with C++ */
+typedef enum {sox_false, sox_true} sox_bool;
+
+typedef int32_t int24_t;     /* But beware of the extra byte. */
+typedef uint32_t uint24_t;   /* ditto */
+
+#define SOX_INT_MIN(bits) (1 <<((bits)-1))
+#define SOX_INT_MAX(bits) (-1U>>(33-(bits)))
+#define SOX_UINT_MAX(bits) (SOX_INT_MIN(bits)|SOX_INT_MAX(bits))
+
+#define SOX_INT8_MAX  SOX_INT_MAX(8)
+#define SOX_INT16_MAX SOX_INT_MAX(16)
+#define SOX_INT24_MAX SOX_INT_MAX(24)
+#define SOX_INT32_MAX SOX_INT_MAX(32)
+#define SOX_INT64_MAX 0x7fffffffffffffffLL /* Not in use yet */
+
+typedef int32_t sox_sample_t;
+typedef uint32_t sox_usample_t; /* FIXME: this naming is different from
+                                  other types */
+/* Minimum and maximum values a sample can hold. */
+#define SOX_SAMPLE_MAX (sox_sample_t)SOX_INT_MAX(32)
+#define SOX_SAMPLE_MIN (sox_sample_t)SOX_INT_MIN(32)
+
+
+
+/*                Conversions: Linear PCM <--> sox_sample_t
+ *
+ *   I/O       I/O     sox_sample_t  Clips?    I/O     sox_sample_t  Clips? 
+ *  Format   Minimum     Minimum     I O    Maximum     Maximum     I O      
+ *  ------  ---------  ------------ -- --   --------  ------------ -- --  
+ *  Float      -1     -1.00000000047 y y       1           1        y n         
+ *  Byte      -128        -128       n n      127     127.9999999   n y   
+ *  Word     -32768      -32768      n n     32767    32767.99998   n y   
+ *  24bit   -8388608    -8388608     n n    8388607   8388607.996   n y   
+ *  Dword  -2147483648 -2147483648   n n   2147483647 2147483647    n n   
+ *
+ * Conversions are as accurate as possible (with rounding).
+ *
+ * Rounding: halves toward +inf, all others to nearest integer.
+ *
+ * Clips? shows whether on not there is the possibility of a conversion
+ * clipping to the minimum or maximum value when inputing from or outputing 
+ * to a given type.
+ *
+ * Unsigned integers are converted to and from signed integers by flipping
+ * the upper-most bit then treating them as signed integers.
+ */
+
+/* Temporary variables to prevent multiple evaluation of macro arguments: */
+static sox_sample_t sox_macro_temp_sample UNUSED;
+static double sox_macro_temp_double UNUSED;
+
+#define SOX_SAMPLE_NEG SOX_INT_MIN(32)
+#define SOX_SAMPLE_TO_UNSIGNED(bits,d,clips) \
+  (uint##bits##_t)( \
+    sox_macro_temp_sample=d, \
+    sox_macro_temp_sample>(sox_sample_t)(SOX_SAMPLE_MAX-(1U<<(31-bits)))? \
+      ++(clips),SOX_UINT_MAX(bits): \
+      ((uint32_t)(sox_macro_temp_sample^SOX_SAMPLE_NEG)+(1U<<(31-bits)))>>(32-bits))
+#define SOX_SAMPLE_TO_SIGNED(bits,d,clips) \
+  (int##bits##_t)(SOX_SAMPLE_TO_UNSIGNED(bits,d,clips)^SOX_INT_MIN(bits))
+#define SOX_SIGNED_TO_SAMPLE(bits,d)((sox_sample_t)(d)<<(32-bits))
+#define SOX_UNSIGNED_TO_SAMPLE(bits,d)(SOX_SIGNED_TO_SAMPLE(bits,d)^SOX_SAMPLE_NEG)
+
+#define SOX_UNSIGNED_BYTE_TO_SAMPLE(d,clips) SOX_UNSIGNED_TO_SAMPLE(8,d)
+#define SOX_SIGNED_BYTE_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(8,d)
+#define SOX_UNSIGNED_WORD_TO_SAMPLE(d,clips) SOX_UNSIGNED_TO_SAMPLE(16,d)
+#define SOX_SIGNED_WORD_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(16,d)
+#define SOX_UNSIGNED_24BIT_TO_SAMPLE(d,clips) SOX_UNSIGNED_TO_SAMPLE(24,d)
+#define SOX_SIGNED_24BIT_TO_SAMPLE(d,clips) SOX_SIGNED_TO_SAMPLE(24,d)
+#define SOX_UNSIGNED_DWORD_TO_SAMPLE(d,clips) (sox_sample_t)((d)^SOX_SAMPLE_NEG)
+#define SOX_SIGNED_DWORD_TO_SAMPLE(d,clips) (sox_sample_t)(d)
+#define SOX_FLOAT_DWORD_TO_SAMPLE SOX_FLOAT_DDWORD_TO_SAMPLE
+#define SOX_FLOAT_DDWORD_TO_SAMPLE(d,clips) (sox_macro_temp_double=d,sox_macro_temp_double<-1?++(clips),(-SOX_SAMPLE_MAX):sox_macro_temp_double>1?++(clips),SOX_SAMPLE_MAX:(sox_sample_t)((uint32_t)((double)(sox_macro_temp_double)*SOX_SAMPLE_MAX+(SOX_SAMPLE_MAX+.5))-SOX_SAMPLE_MAX))
+#define SOX_SAMPLE_TO_UNSIGNED_BYTE(d,clips) SOX_SAMPLE_TO_UNSIGNED(8,d,clips)
+#define SOX_SAMPLE_TO_SIGNED_BYTE(d,clips) SOX_SAMPLE_TO_SIGNED(8,d,clips)
+#define SOX_SAMPLE_TO_UNSIGNED_WORD(d,clips) SOX_SAMPLE_TO_UNSIGNED(16,d,clips)
+#define SOX_SAMPLE_TO_SIGNED_WORD(d,clips) SOX_SAMPLE_TO_SIGNED(16,d,clips)
+#define SOX_SAMPLE_TO_UNSIGNED_24BIT(d,clips) SOX_SAMPLE_TO_UNSIGNED(24,d,clips)
+#define SOX_SAMPLE_TO_SIGNED_24BIT(d,clips) SOX_SAMPLE_TO_SIGNED(24,d,clips)
+#define SOX_SAMPLE_TO_UNSIGNED_DWORD(d,clips) (uint32_t)((d)^SOX_SAMPLE_NEG)
+#define SOX_SAMPLE_TO_SIGNED_DWORD(d,clips) (int32_t)(d)
+#define SOX_SAMPLE_TO_FLOAT_DWORD SOX_SAMPLE_TO_FLOAT_DDWORD
+#define SOX_SAMPLE_TO_FLOAT_DDWORD(d,clips) (sox_macro_temp_sample=d,sox_macro_temp_sample==SOX_SAMPLE_MIN?++(clips),-1.0:((double)(sox_macro_temp_sample)*(1.0/SOX_SAMPLE_MAX)))
+
+
+
+/* MACRO to clip a data type that is greater then sox_sample_t to
+ * sox_sample_t's limits and increment a counter if clipping occurs..
+ */
+#define SOX_SAMPLE_CLIP_COUNT(samp, clips) \
+  do { \
+    if (samp > SOX_SAMPLE_MAX) \
+      { samp = SOX_SAMPLE_MAX; clips++; } \
+    else if (samp < SOX_SAMPLE_MIN) \
+      { samp = SOX_SAMPLE_MIN; clips++; } \
+  } while (0)
+
+/* Rvalue MACRO to round and clip a double to a sox_sample_t,
+ * and increment a counter if clipping occurs.
+ */
+#define SOX_ROUND_CLIP_COUNT(d, clips) \
+  ((d) < 0? (d) <= SOX_SAMPLE_MIN - 0.5? ++(clips), SOX_SAMPLE_MIN: (d) - 0.5 \
+        : (d) >= SOX_SAMPLE_MAX + 0.5? ++(clips), SOX_SAMPLE_MAX: (d) + 0.5)
+
+/* Rvalue MACRO to clip a sox_sample_t to 24 bits,
+ * and increment a counter if clipping occurs.
+ */
+#define SOX_24BIT_CLIP_COUNT(l, clips) \
+  ((l) >= ((sox_sample_t)1 << 23)? ++(clips), ((sox_sample_t)1 << 23) - 1 : \
+   (l) <=-((sox_sample_t)1 << 23)? ++(clips),-((sox_sample_t)1 << 23) + 1 : (l))
+
+
+
+typedef uint32_t sox_size_t;
+/* Maximum value size type can hold. (Minimum is 0). */
+#define SOX_SIZE_MAX 0xffffffff
+
+typedef int32_t sox_ssize_t;
+/* Minimum and maximum value signed size type can hold. */
+#define SOX_SSIZE_MAX 0x7fffffff
+#define SOX_SSIZE_MIN (-SOX_SSIZE_MAX - 1)
+
+typedef unsigned sox_rate_t;
+/* Warning, this is a MAX value used in the library.  Each format and
+ * effect may have its own limitations of rate.
+ */
+#define SOX_MAXRATE      (50U * 1024) /* maximum sample rate in library */
+
+typedef enum {
+  SOX_ENCODING_UNKNOWN   ,
+
+  SOX_ENCODING_ULAW      , /* u-law signed logs: US telephony, SPARC */
+  SOX_ENCODING_ALAW      , /* A-law signed logs: non-US telephony */
+  SOX_ENCODING_ADPCM     , /* G72x Compressed PCM */
+  SOX_ENCODING_MS_ADPCM  , /* Microsoft Compressed PCM */
+  SOX_ENCODING_IMA_ADPCM , /* IMA Compressed PCM */
+  SOX_ENCODING_OKI_ADPCM , /* Dialogic/OKI Compressed PCM */
+
+  SOX_ENCODING_SIZE_IS_WORD, /* FIXME: marks raw types (above) that mis-report size. sox_signalinfo_t really needs a precision_in_bits item */
+
+  SOX_ENCODING_UNSIGNED  , /* unsigned linear: Sound Blaster */
+  SOX_ENCODING_SIGN2     , /* signed linear 2's comp: Mac */
+  SOX_ENCODING_FLOAT     , /* 32-bit float */
+  SOX_ENCODING_GSM       , /* GSM 6.10 33byte frame lossy compression */
+  SOX_ENCODING_MP3       , /* MP3 compression */
+  SOX_ENCODING_VORBIS    , /* Vorbis compression */
+  SOX_ENCODING_FLAC      , /* FLAC compression */
+  SOX_ENCODING_AMR_WB    , /* AMR-WB compression */
+
+  SOX_ENCODINGS            /* End of list marker */
+} sox_encoding_t;
+
+/* Global parameters */
+
+typedef struct  sox_globalinfo
+{
+    sox_bool octave_plot_effect;/* To help user choose effect & options */
+    double speed;         /* Gather up all speed changes here, then resample */
+} sox_globalinfo_t;
+
+typedef enum {SOX_OPTION_NO, SOX_OPTION_YES, SOX_OPTION_DEFAULT} sox_option_t;
+
+/* Signal parameters */
+
+typedef struct sox_signalinfo
+{
+    sox_rate_t rate;       /* sampling rate */
+    int size;             /* compressed or uncompressed datum size */
+    sox_encoding_t encoding; /* format of sample numbers */
+    unsigned channels;    /* number of sound channels */
+    double compression;   /* compression factor (where applicable) */
+
+    /* There is a delineation between these vars being tri-state and
+     * effectively boolean.  Logically the line falls between setting
+     * them up (could be done in stlib, or by the stlib client) and
+     * using them (in stlib).  Stlib's logic to set them up includes
+     * knowledge of the machine default and the format default.  (The
+     * sox client logic adds to this a layer of overridability via user
+     * options.)  The physical delineation is in the somewhat
+     * snappily-named stlib function `set_endianness_if_not_already_set'
+     * which is called at the right times (as files are openned) by the
+     * stlib core, not by the file drivers themselves.  The file drivers
+     * indicate to the stlib core if they have a preference using
+     * SOX_FILE_xxx flags.
+     */
+    sox_option_t reverse_bytes;    /* endiannesses... */
+    sox_option_t reverse_nibbles;
+    sox_option_t reverse_bits;
+} sox_signalinfo_t;
+
+/* Loop parameters */
+
+typedef struct  sox_loopinfo
+{
+    sox_size_t    start;          /* first sample */
+    sox_size_t    length;         /* length */
+    unsigned int count;          /* number of repeats, 0=forever */
+    signed char  type;           /* 0=no, 1=forward, 2=forward/back */
+} sox_loopinfo_t;
+
+/* Instrument parameters */
+
+/* vague attempt at generic information for sampler-specific info */
+
+typedef struct  sox_instrinfo
+{
+    char MIDInote;       /* for unity pitch playback */
+    char MIDIlow, MIDIhi;/* MIDI pitch-bend range */
+    char loopmode;       /* semantics of loop data */
+    signed char nloops;  /* number of active loops (max SOX_MAX_NLOOPS) */
+} sox_instrinfo_t;
+
+/* Loop modes, upper 4 bits mask the loop blass, lower 4 bits describe */
+/* the loop behaviour, ie. single shot, bidirectional etc. */
+#define SOX_LOOP_NONE          0
+#define SOX_LOOP_8             32 /* 8 loops: don't know ?? */
+#define SOX_LOOP_SUSTAIN_DECAY 64 /* AIFF style: one sustain & one decay loop */
+
+/*
+ * File buffer info.  Holds info so that data can be read in blocks.
+ */
+
+typedef struct sox_fileinfo
+{
+    char          *buf;                 /* Pointer to data buffer */
+    size_t        size;                 /* Size of buffer */
+    size_t        count;                /* Count read in to buffer */
+    size_t        pos;                  /* Position in buffer */
+    unsigned char eof;                  /* Marker that EOF has been reached */
+} sox_fileinfo_t;
+
+
+/*
+ *  Format information for input and output files.
+ */
+
+#define SOX_MAX_FILE_PRIVSIZE    1000
+#define SOX_MAX_EFFECT_PRIVSIZE 1000
+
+#define SOX_MAX_NLOOPS           8
+
+/*
+ * Handler structure for each format.
+ */
+
+typedef struct sox_soundstream *ft_t;
+
+typedef struct sox_format {
+    const char   * const *names;
+    const char   *usage;
+    unsigned int flags;
+    int          (*startread)(ft_t ft);
+    sox_size_t    (*read)(ft_t ft, sox_sample_t *buf, sox_size_t len);
+    int          (*stopread)(ft_t ft);
+    int          (*startwrite)(ft_t ft);
+    sox_size_t    (*write)(ft_t ft, const sox_sample_t *buf, sox_size_t len);
+    int          (*stopwrite)(ft_t ft);
+    int          (*seek)(ft_t ft, sox_size_t offset);
+} sox_format_t;
+
+struct sox_soundstream {
+    sox_signalinfo_t signal;               /* signal specifications */
+    sox_instrinfo_t  instr;                /* instrument specification */
+    sox_loopinfo_t   loops[SOX_MAX_NLOOPS]; /* Looping specification */
+    sox_bool         seekable;             /* can seek on this file */
+    char            mode;                 /* read or write mode */
+    sox_size_t       length;               /* frames in file, or 0 if unknown. */
+    sox_size_t       clips;                /* increment if clipping occurs */
+    char            *filename;            /* file name */
+    char            *filetype;            /* type of file */
+    char            *comment;             /* comment string */
+    FILE            *fp;                  /* File stream pointer */
+    unsigned char   eof;                  /* Marker that EOF has been reached */
+    int             sox_errno;             /* Failure error codes */
+    char            sox_errstr[256];       /* Extend Failure text */
+    const sox_format_t *h;                 /* format struct for this file */
+    /* The following is a portable trick to align this variable on
+     * an 8-byte boundery.  Once this is done, the buffer alloced
+     * after it should be align on an 8-byte boundery as well.
+     * This lets you cast any structure over the private area
+     * without concerns of alignment.
+     */
+    double priv1;
+    char   priv[SOX_MAX_FILE_PRIVSIZE]; /* format's private data area */
+};
+
+/* file flags field */
+#define SOX_FILE_LOOPS   1  /* does file format support loops? */
+#define SOX_FILE_INSTR   2  /* does file format support instrument specs? */
+#define SOX_FILE_SEEK    4  /* does file format support seeking? */
+#define SOX_FILE_NOSTDIO 8  /* does not use stdio routines */
+#define SOX_FILE_DEVICE  16 /* file is an audio device */
+#define SOX_FILE_PHONY   32 /* phony file/device */
+/* These two for use by the stlib core or stlib clients: */
+#define SOX_FILE_ENDIAN  64 /* is file format endian? */
+#define SOX_FILE_ENDBIG  128/* if so, is it big endian? */
+/* These two for use by stlib drivers: */
+#define SOX_FILE_LIT_END  (0   + 64)
+#define SOX_FILE_BIG_END  (128 + 64)
+
+/* Size field */
+#define SOX_SIZE_BYTE    1
+#define SOX_SIZE_8BIT    1
+#define SOX_SIZE_16BIT   2
+#define SOX_SIZE_24BIT   3
+#define SOX_SIZE_32BIT   4
+#define SOX_SIZE_64BIT   8
+#define SOX_INFO_SIZE_MAX     8
+
+/* declared in misc.c */
+extern const char * const sox_sizes_str[];
+extern const char * const sox_size_bits_str[];
+extern const char * const sox_encodings_str[];
+
+#define SOX_EFF_CHAN     1           /* Effect can mix channels up/down */
+#define SOX_EFF_RATE     2           /* Effect can alter data rate */
+#define SOX_EFF_MCHAN    4           /* Effect can handle multi-channel */
+#define SOX_EFF_REPORT   8           /* Effect does not affect the audio */
+#define SOX_EFF_DEPRECATED 16        /* Effect is living on borrowed time */
+#define SOX_EFF_NULL     32          /* Effect does nothing */
+
+/*
+ * Handler structure for each effect.
+ */
+
+typedef struct sox_effect *eff_t;
+
+typedef struct
+{
+    char const *name;               /* effect name */
+    char const *usage;
+    unsigned int flags;
+
+    int (*getopts)(eff_t effp, int argc, char *argv[]);
+    int (*start)(eff_t effp);
+    int (*flow)(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf,
+                sox_size_t *isamp, sox_size_t *osamp);
+    int (*drain)(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp);
+    int (*stop)(eff_t effp);
+    int (*kill)(eff_t effp);
+} sox_effect_t;
+
+struct sox_effect
+{
+    char const *name;               /* effect name */
+    struct sox_globalinfo * globalinfo;/* global ST parameters */
+    struct sox_signalinfo ininfo;    /* input signal specifications */
+    struct sox_signalinfo outinfo;   /* output signal specifications */
+    const sox_effect_t *h;           /* effects driver */
+    sox_sample_t     *obuf;          /* output buffer */
+    sox_size_t       odone, olen;    /* consumed, total length */
+    sox_size_t       clips;   /* increment if clipping occurs */
+    /* The following is a portable trick to align this variable on
+     * an 8-byte boundary.  Once this is done, the buffer alloced
+     * after it should be align on an 8-byte boundery as well.
+     * This lets you cast any structure over the private area
+     * without concerns of alignment.
+     */
+    double priv1;
+    char priv[SOX_MAX_EFFECT_PRIVSIZE]; /* private area for effect */
+};
+
+void set_endianness_if_not_already_set(ft_t ft);
+extern ft_t sox_open_read(const char *path, const sox_signalinfo_t *info, 
+                         const char *filetype);
+ft_t sox_open_write(
+    sox_bool (*overwrite_permitted)(const char *filename),
+    const char *path,
+    const sox_signalinfo_t *info,
+    const char *filetype,
+    const char *comment,
+    const sox_instrinfo_t *instr,
+    const sox_loopinfo_t *loops);
+extern sox_size_t sox_read(ft_t ft, sox_sample_t *buf, sox_size_t len);
+extern sox_size_t sox_write(ft_t ft, const sox_sample_t *buf, sox_size_t len);
+extern int sox_close(ft_t ft);
+
+#define SOX_SEEK_SET 0
+extern int sox_seek(ft_t ft, sox_size_t offset, int whence);
+
+int sox_geteffect_opt(eff_t, int, char **);
+int sox_geteffect(eff_t, const char *);
+sox_bool is_effect_name(char const * text);
+int sox_updateeffect(eff_t, const sox_signalinfo_t *in, const sox_signalinfo_t *out, int);
+int sox_gettype(ft_t, sox_bool);
+ft_t sox_initformat(void);
+char const * sox_parsesamples(sox_rate_t rate, const char *str, sox_size_t *samples, char def);
+
+/* The following routines are unique to the trim effect.
+ * sox_trim_get_start can be used to find what is the start
+ * of the trim operation as specified by the user.
+ * sox_trim_clear_start will reset what ever the user specified
+ * back to 0.
+ * These two can be used together to find out what the user
+ * wants to trim and use a sox_seek() operation instead.  After
+ * sox_seek()'ing, you should set the trim option to 0.
+ */
+sox_size_t sox_trim_get_start(eff_t effp);
+void sox_trim_clear_start(eff_t effp);
+
+extern char const * sox_message_filename;
+
+#define SOX_EOF (-1)
+#define SOX_SUCCESS (0)
+
+const char *sox_version(void);                   /* return version number */
+
+/* ST specific error codes.  The rest directly map from errno. */
+#define SOX_EHDR 2000            /* Invalid Audio Header */
+#define SOX_EFMT 2001            /* Unsupported data format */
+#define SOX_ERATE 2002           /* Unsupported rate for format */
+#define SOX_ENOMEM 2003          /* Can't alloc memory */
+#define SOX_EPERM 2004           /* Operation not permitted */
+#define SOX_ENOTSUP 2005         /* Operation not supported */
+#define SOX_EINVAL 2006          /* Invalid argument */
+#define SOX_EFFMT 2007           /* Unsupported file format */
+
+#endif
--- /dev/null
+++ b/src/sox_i.h
@@ -1,0 +1,370 @@
+/*
+ * Sound Tools Internal header
+ *
+ *   This file is meant for libst internal use only
+ *
+ * Copyright 2001-2007 Chris Bagwell and SoX Contributors
+ *
+ * This source code is freely redistributable and may be used for
+ * any purpose.  This copyright notice must be maintained.
+ * Chris Bagwell And SoX Contributors are not responsible for
+ * the consequences of using this software.
+ */
+
+#ifndef SOX_I_H
+#define SOX_I_H
+
+#include "stconfig.h"
+#include "sox.h"
+#include "xmalloc.h"
+
+#include <stdarg.h>
+
+#ifdef HAVE_BYTESWAP_H
+#include <byteswap.h>
+#endif
+
+/* various gcc optimizations and portablity defines */
+#ifdef __GNUC__
+#define NORET __attribute__((noreturn))
+#else
+#define NORET
+#endif
+
+/* C language enhancements: */
+
+/* Compile-time ("static") assertion */
+/*   e.g. assert_static(sizeof(int) >= 4, int_type_too_small)    */
+#define assert_static(e,f) enum {assert_static__##f = 1/(e)}
+
+#ifdef min
+#undef min
+#endif
+#define min(a, b) ((a) <= (b) ? (a) : (b))
+
+#ifdef max
+#undef max
+#endif
+#define max(a, b) ((a) >= (b) ? (a) : (b))
+
+#define range_limit(x, lower, upper) (min(max(x, lower), upper))
+
+/* Array-length operator */
+#define array_length(a) (sizeof(a)/sizeof(a[0]))
+
+/* declared in misc.c */
+typedef struct {char const *text; int value;} enum_item;
+#define ENUM_ITEM(prefix, item) {#item, prefix##item},
+enum_item const * find_enum_text(
+    char const * text, enum_item const * enum_items);
+
+typedef enum {SOX_SHORT, SOX_INT, SOX_FLOAT, SOX_DOUBLE} sox_data_t;
+typedef enum {SOX_WAVE_SINE, SOX_WAVE_TRIANGLE} sox_wave_t;
+extern enum_item const sox_wave_enum[];
+
+/* Define fseeko and ftello for platforms lacking them */
+#ifndef HAVE_FSEEKO
+#define fseeko fseek
+#define ftello ftell
+#define off_t long
+#endif
+
+/* Digitise one cycle of a wave and store it as
+ * a table of samples of a specified data-type.
+ */
+void sox_generate_wave_table(
+    sox_wave_t wave_type,
+    sox_data_t data_type,
+    void * table,       /* Really of type indicated by data_type. */
+    uint32_t table_size,/* Number of points on the x-axis. */
+    double min,         /* Minimum value on the y-axis. (e.g. -1) */
+    double max,         /* Maximum value on the y-axis. (e.g. +1) */
+    double phase);      /* Phase at 1st point; 0..2pi. (e.g. pi/2 for cosine) */
+
+sox_sample_t sox_gcd(sox_sample_t a, sox_sample_t b);
+sox_sample_t sox_lcm(sox_sample_t a, sox_sample_t b);
+
+#ifndef HAVE_STRCASECMP
+int strcasecmp(const char *s1, const char *s2);
+int strncasecmp(char const * s1, char const * s2, size_t n);
+#endif
+
+#ifndef HAVE_STRDUP
+char *strdup(const char *s);
+#endif
+
+/* Read and write basic data types from "ft" stream.  Uses ft->swap for
+ * possible byte swapping.
+ */
+/* declared in misc.c */
+size_t sox_readbuf(ft_t ft, void *buf, size_t size, sox_size_t len);
+int sox_skipbytes(ft_t ft, sox_size_t n);
+int sox_padbytes(ft_t ft, sox_size_t n);
+size_t sox_writebuf(ft_t ft, void const *buf, size_t size, sox_size_t len);
+int sox_reads(ft_t ft, char *c, sox_size_t len);
+int sox_writes(ft_t ft, char *c);
+int sox_readb(ft_t ft, uint8_t *ub);
+int sox_writeb(ft_t ft, uint8_t ub);
+int sox_readw(ft_t ft, uint16_t *uw);
+int sox_writew(ft_t ft, uint16_t uw);
+int sox_read3(ft_t ft, uint24_t *u3);
+int sox_write3(ft_t ft, uint24_t u3);
+int sox_readdw(ft_t ft, uint32_t *udw);
+int sox_writedw(ft_t ft, uint32_t udw);
+int sox_readf(ft_t ft, float *f);
+int sox_writef(ft_t ft, float f);
+int sox_readdf(ft_t ft, double *d);
+int sox_writedf(ft_t ft, double d);
+int sox_seeki(ft_t ft, sox_size_t offset, int whence);
+sox_size_t sox_filelength(ft_t ft);
+int sox_flush(ft_t ft);
+sox_size_t sox_tell(ft_t ft);
+int sox_eof(ft_t ft);
+int sox_error(ft_t ft);
+void sox_rewind(ft_t ft);
+void sox_clearerr(ft_t ft);
+
+/* Utilities to read/write values endianness-independently */
+uint32_t get32_le(unsigned char **p);
+uint16_t get16_le(unsigned char **p);
+void put32_le(unsigned char **p, uint32_t val);
+void put16_le(unsigned char **p, int16_t val);
+void put32_be(unsigned char **p, int32_t val);
+void put16_be(unsigned char **p, short val);
+
+/* Utilities to byte-swap values, use libc optimized macros if possible  */
+#ifdef HAVE_BYTESWAP_H
+#define sox_swapw(x) bswap_16(x)
+#define sox_swapdw(x) bswap_32(x)
+#else
+#define sox_swapw(uw) (((uw >> 8) | (uw << 8)) & 0xffff)
+#define sox_swapdw(udw) ((udw >> 24) | ((udw >> 8) & 0xff00) | ((udw << 8) & 0xff0000) | (udw << 24))
+#endif
+float sox_swapf(float f);
+uint32_t sox_swap24(uint32_t udw);
+double sox_swapd(double d);
+
+/* util.c */
+typedef void (*sox_output_message_handler_t)(int level, const char *filename, const char *fmt, va_list ap);
+extern sox_output_message_handler_t sox_output_message_handler;
+extern int sox_output_verbosity_level;
+void sox_output_message(FILE *file, const char *filename, const char *fmt, va_list ap);
+
+void sox_fail(const char *, ...);
+void sox_warn(const char *, ...);
+void sox_report(const char *, ...);
+void sox_debug(const char *, ...);
+void sox_debug_more(char const * fmt, ...);
+void sox_debug_most(char const * fmt, ...);
+
+#define sox_fail       sox_message_filename=__FILE__,sox_fail
+#define sox_warn       sox_message_filename=__FILE__,sox_warn
+#define sox_report     sox_message_filename=__FILE__,sox_report
+#define sox_debug      sox_message_filename=__FILE__,sox_debug
+#define sox_debug_more sox_message_filename=__FILE__,sox_debug_more
+#define sox_debug_most sox_message_filename=__FILE__,sox_debug_most
+
+void sox_fail_errno(ft_t, int, const char *, ...);
+
+int sox_is_bigendian(void);
+int sox_is_littleendian(void);
+
+#ifdef WORDS_BIGENDIAN
+#define SOX_IS_BIGENDIAN 1
+#define SOX_IS_LITTLEENDIAN 0
+#else
+#define SOX_IS_BIGENDIAN 0
+#define SOX_IS_LITTLEENDIAN 1
+#endif
+
+#ifndef M_PI
+#define M_PI    3.14159265358979323846
+#endif
+#ifndef M_PI_2
+#define M_PI_2  1.57079632679489661923  /* pi/2 */
+#endif
+
+/* The following is used at times in libst when alloc()ing buffers
+ * to perform file I/O.  It can be useful to pass in similar sized
+ * data to get max performance.
+ */
+#define SOX_BUFSIZ 8192
+
+/*=============================================================================
+ * File Handlers
+ *=============================================================================
+ */
+
+/* Psion record header check, defined in prc.c */
+int prc_checkheader(ft_t ft, char *head);
+
+typedef const sox_format_t *(*sox_format_fn_t)(void);
+
+extern sox_format_fn_t sox_format_fns[];
+
+extern const sox_format_t *sox_aiff_format_fn(void);
+extern const sox_format_t *sox_aifc_format_fn(void);
+#ifdef HAVE_ALSA
+extern const sox_format_t *sox_alsa_format_fn(void);
+#endif
+extern const sox_format_t *sox_amr_wb_format_fn(void);
+extern const sox_format_t *sox_au_format_fn(void);
+extern const sox_format_t *sox_auto_format_fn(void);
+extern const sox_format_t *sox_avr_format_fn(void);
+extern const sox_format_t *sox_cdr_format_fn(void);
+extern const sox_format_t *sox_cvsd_format_fn(void);
+extern const sox_format_t *sox_dvms_format_fn(void);
+extern const sox_format_t *sox_dat_format_fn(void);
+#ifdef HAVE_LIBFLAC
+extern const sox_format_t *sox_flac_format_fn(void);
+#endif
+extern const sox_format_t *sox_gsm_format_fn(void);
+extern const sox_format_t *sox_hcom_format_fn(void);
+extern const sox_format_t *sox_ima_format_fn(void);
+extern const sox_format_t *sox_maud_format_fn(void);
+extern const sox_format_t *sox_mp3_format_fn(void);
+extern const sox_format_t *sox_nul_format_fn(void);
+#ifdef HAVE_OSS
+extern const sox_format_t *sox_ossdsp_format_fn(void);
+#endif
+extern const sox_format_t *sox_prc_format_fn(void);
+extern const sox_format_t *sox_raw_format_fn(void);
+extern const sox_format_t *sox_al_format_fn(void);
+extern const sox_format_t *sox_la_format_fn(void);
+extern const sox_format_t *sox_lu_format_fn(void);
+extern const sox_format_t *sox_s3_format_fn(void);
+extern const sox_format_t *sox_sb_format_fn(void);
+extern const sox_format_t *sox_sl_format_fn(void);
+extern const sox_format_t *sox_sw_format_fn(void);
+extern const sox_format_t *sox_u3_format_fn(void);
+extern const sox_format_t *sox_ub_format_fn(void);
+extern const sox_format_t *sox_u4_format_fn(void);
+extern const sox_format_t *sox_ul_format_fn(void);
+extern const sox_format_t *sox_uw_format_fn(void);
+extern const sox_format_t *sox_sf_format_fn(void);
+extern const sox_format_t *sox_smp_format_fn(void);
+extern const sox_format_t *sox_snd_format_fn(void);
+#ifdef HAVE_SNDFILE_H
+extern const sox_format_t *sox_sndfile_format_fn(void);
+#endif
+extern const sox_format_t *sox_sphere_format_fn(void);
+#ifdef HAVE_SUN_AUDIO
+extern const sox_format_t *sox_sun_format_fn(void);
+#endif
+extern const sox_format_t *sox_svx_format_fn(void);
+extern const sox_format_t *sox_txw_format_fn(void);
+extern const sox_format_t *sox_voc_format_fn(void);
+#if defined HAVE_LIBVORBISENC && defined HAVE_LIBVORBISFILE
+extern const sox_format_t *sox_vorbis_format_fn(void);
+#endif
+extern const sox_format_t *sox_vox_format_fn(void);
+extern const sox_format_t *sox_wav_format_fn(void);
+extern const sox_format_t *sox_wve_format_fn(void);
+extern const sox_format_t *sox_xa_format_fn(void);
+
+/* Raw I/O */
+int sox_rawstartread(ft_t ft);
+sox_size_t sox_rawread(ft_t ft, sox_sample_t *buf, sox_size_t nsamp);
+int sox_rawstopread(ft_t ft);
+int sox_rawstartwrite(ft_t ft);
+sox_size_t sox_rawwrite(ft_t ft, const sox_sample_t *buf, sox_size_t nsamp);
+int sox_rawstopwrite(ft_t ft);
+int sox_rawseek(ft_t ft, sox_size_t offset);
+
+/* libsndfile I/O */
+int sox_sndfile_startread(ft_t ft);
+sox_size_t sox_sndfile_read(ft_t ft, sox_sample_t *buf, sox_size_t len);
+int sox_sndfile_stopread(ft_t ft);
+int sox_sndfile_startwrite(ft_t ft);
+sox_size_t sox_sndfile_write(ft_t ft, const sox_sample_t *buf, sox_size_t len);
+int sox_sndfile_stopwrite(ft_t ft);
+int sox_sndfile_seek(ft_t ft, sox_size_t offset);
+
+
+/* The following functions can be used to simply return success if
+ * a file handler or effect doesn't need to do anything special
+ */
+int sox_format_nothing(ft_t ft);
+sox_size_t sox_format_nothing_read_io(ft_t ft, sox_sample_t *buf, sox_size_t len);
+sox_size_t sox_format_nothing_write_io(ft_t ft, const sox_sample_t *buf, sox_size_t len);
+int sox_format_nothing_seek(ft_t ft, sox_size_t offset);
+int sox_effect_nothing(eff_t effp);
+int sox_effect_nothing_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, sox_size_t *isamp, sox_size_t *osamp);
+int sox_effect_nothing_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp);
+int sox_effect_nothing_getopts(eff_t effp, int n, char **argv UNUSED);
+
+int sox_rawstart(ft_t ft, sox_bool default_rate, sox_bool default_channels, sox_encoding_t encoding, signed char size, sox_option_t rev_bits);
+#define sox_rawstartread(ft) sox_rawstart(ft, sox_false, sox_false, SOX_ENCODING_UNKNOWN, -1, SOX_OPTION_DEFAULT)
+#define sox_rawstartwrite sox_rawstartread
+#define sox_rawstopread sox_format_nothing
+
+/*=============================================================================
+ * Effects
+ *=============================================================================
+ */
+
+typedef const sox_effect_t *(*sox_effect_fn_t)(void);
+
+extern sox_effect_fn_t sox_effect_fns[];
+
+extern const sox_effect_t *sox_allpass_effect_fn(void);
+extern const sox_effect_t *sox_avg_effect_fn(void);
+extern const sox_effect_t *sox_band_effect_fn(void);
+extern const sox_effect_t *sox_bandpass_effect_fn(void);
+extern const sox_effect_t *sox_bandreject_effect_fn(void);
+extern const sox_effect_t *sox_bass_effect_fn(void);
+extern const sox_effect_t *sox_chorus_effect_fn(void);
+extern const sox_effect_t *sox_compand_effect_fn(void);
+extern const sox_effect_t *sox_dcshift_effect_fn(void);
+extern const sox_effect_t *sox_deemph_effect_fn(void);
+extern const sox_effect_t *sox_dither_effect_fn(void);
+extern const sox_effect_t *sox_earwax_effect_fn(void);
+extern const sox_effect_t *sox_echo_effect_fn(void);
+extern const sox_effect_t *sox_echos_effect_fn(void);
+extern const sox_effect_t *sox_equalizer_effect_fn(void);
+extern const sox_effect_t *sox_fade_effect_fn(void);
+extern const sox_effect_t *sox_filter_effect_fn(void);
+extern const sox_effect_t *sox_flanger_effect_fn(void);
+extern const sox_effect_t *sox_highpass_effect_fn(void);
+extern const sox_effect_t *sox_highp_effect_fn(void);
+extern const sox_effect_t *sox_lowpass_effect_fn(void);
+extern const sox_effect_t *sox_lowp_effect_fn(void);
+extern const sox_effect_t *sox_mask_effect_fn(void);
+extern const sox_effect_t *sox_mcompand_effect_fn(void);
+extern const sox_effect_t *sox_mixer_effect_fn(void);
+extern const sox_effect_t *sox_noiseprof_effect_fn(void);
+extern const sox_effect_t *sox_noisered_effect_fn(void);
+extern const sox_effect_t *sox_pad_effect_fn(void);
+extern const sox_effect_t *sox_pan_effect_fn(void);
+extern const sox_effect_t *sox_phaser_effect_fn(void);
+extern const sox_effect_t *sox_pick_effect_fn(void);
+extern const sox_effect_t *sox_pitch_effect_fn(void);
+extern const sox_effect_t *sox_polyphase_effect_fn(void);
+#ifdef HAVE_SAMPLERATE_H
+extern const sox_effect_t *sox_rabbit_effect_fn(void);
+#endif
+extern const sox_effect_t *sox_rate_effect_fn(void);
+extern const sox_effect_t *sox_repeat_effect_fn(void);
+extern const sox_effect_t *sox_resample_effect_fn(void);
+extern const sox_effect_t *sox_reverb_effect_fn(void);
+extern const sox_effect_t *sox_reverse_effect_fn(void);
+extern const sox_effect_t *sox_silence_effect_fn(void);
+extern const sox_effect_t *sox_speed_effect_fn(void);
+extern const sox_effect_t *sox_stat_effect_fn(void);
+extern const sox_effect_t *sox_stretch_effect_fn(void);
+extern const sox_effect_t *sox_swap_effect_fn(void);
+extern const sox_effect_t *sox_synth_effect_fn(void);
+extern const sox_effect_t *sox_treble_effect_fn(void);
+extern const sox_effect_t *sox_tremolo_effect_fn(void);
+extern const sox_effect_t *sox_trim_effect_fn(void);
+extern const sox_effect_t *sox_vibro_effect_fn(void);
+extern const sox_effect_t *sox_vol_effect_fn(void);
+
+/* Needed in rate.c */
+int sox_resample_start(eff_t effp);
+int sox_resample_getopts(eff_t effp, int n, char **argv);
+int sox_resample_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, sox_size_t *isamp, sox_size_t *osamp);
+int sox_resample_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp);
+int sox_resample_stop(eff_t effp);
+
+#endif
--- /dev/null
+++ b/src/sox_sample_test.c
@@ -1,0 +1,177 @@
+#define DEBUG
+#include <assert.h>
+#include "sox.h"
+
+#define TEST_UINT(bits) \
+  uint##bits = 0; \
+  sample = SOX_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
+  assert(sample == SOX_SAMPLE_MIN); \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == 0 && clips == 0); \
+ \
+  uint##bits = 1; \
+  sample = SOX_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
+  assert(sample > SOX_SAMPLE_MIN && sample < 0); \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == 1 && clips == 0); \
+ \
+  uint##bits = SOX_INT_MAX(bits); \
+  sample = SOX_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
+  assert(sample * SOX_INT_MAX(bits) == SOX_UNSIGNED_TO_SAMPLE(bits,1)); \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == SOX_INT_MAX(bits) && clips == 0); \
+ \
+  sample =SOX_UNSIGNED_TO_SAMPLE(bits,1)+SOX_UNSIGNED_TO_SAMPLE(bits,SOX_INT_MAX(bits))/2; \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == 1 && clips == 0); \
+ \
+  sample = SOX_UNSIGNED_TO_SAMPLE(bits,1)+SOX_UNSIGNED_TO_SAMPLE(bits,SOX_INT_MAX(bits))/2-1; \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == 0 && clips == 0); \
+ \
+  uint##bits = (0^SOX_INT_MIN(bits)); \
+  sample = SOX_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
+  assert(sample == 0); \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == (0^SOX_INT_MIN(bits)) && clips == 0); \
+ \
+  uint##bits = ((0^SOX_INT_MIN(bits))+1); \
+  sample = SOX_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
+  assert(sample > 0 && sample < SOX_SAMPLE_MAX); \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == ((0^SOX_INT_MIN(bits))+1) && clips == 0); \
+ \
+  uint##bits = SOX_UINT_MAX(bits); \
+  sample = SOX_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
+  assert(sample == SOX_INT_MAX(bits) * SOX_UNSIGNED_TO_SAMPLE(bits,((0^SOX_INT_MIN(bits))+1))); \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == SOX_UINT_MAX(bits) && clips == 0); \
+ \
+  sample =SOX_UNSIGNED_TO_SAMPLE(bits,SOX_UINT_MAX(bits))+SOX_UNSIGNED_TO_SAMPLE(bits,((0^SOX_INT_MIN(bits))+1))/2-1; \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == SOX_UINT_MAX(bits) && clips == 0); \
+ \
+  sample = SOX_UNSIGNED_TO_SAMPLE(bits,SOX_UINT_MAX(bits))+SOX_UNSIGNED_TO_SAMPLE(bits,((0^SOX_INT_MIN(bits))+1))/2; \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == SOX_UINT_MAX(bits) && --clips == 0); \
+ \
+  sample = SOX_SAMPLE_MAX; \
+  uint##bits = SOX_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
+  assert(uint##bits == SOX_UINT_MAX(bits) && --clips == 0); \
+
+#define TEST_SINT(bits) \
+  int##bits = SOX_INT_MIN(bits); \
+  sample = SOX_SIGNED_TO_SAMPLE(bits,int##bits); \
+  assert(sample == SOX_SAMPLE_MIN); \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && clips == 0); \
+ \
+  int##bits = SOX_INT_MIN(bits)+1; \
+  sample = SOX_SIGNED_TO_SAMPLE(bits,int##bits); \
+  assert(sample > SOX_SAMPLE_MIN && sample < 0); \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && clips == 0); \
+ \
+  int##bits = SOX_UINT_MAX(bits) /* i.e. -1 */; \
+  sample = SOX_SIGNED_TO_SAMPLE(bits,int##bits); \
+  assert(sample * SOX_INT_MAX(bits) == SOX_SIGNED_TO_SAMPLE(bits,SOX_INT_MIN(bits)+1)); \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && clips == 0); \
+ \
+  int##bits = SOX_INT_MIN(bits)+1; \
+  sample =SOX_UNSIGNED_TO_SAMPLE(bits,1)+SOX_UNSIGNED_TO_SAMPLE(bits,SOX_INT_MAX(bits))/2; \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && clips == 0); \
+ \
+  int##bits = SOX_INT_MIN(bits); \
+  sample = SOX_UNSIGNED_TO_SAMPLE(bits,1)+SOX_UNSIGNED_TO_SAMPLE(bits,SOX_INT_MAX(bits))/2-1; \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && clips == 0); \
+ \
+  int##bits = 0; \
+  sample = SOX_SIGNED_TO_SAMPLE(bits,int##bits); \
+  assert(sample == 0); \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && clips == 0); \
+ \
+  int##bits = 1; \
+  sample = SOX_SIGNED_TO_SAMPLE(bits,int##bits); \
+  assert(sample > 0 && sample < SOX_SAMPLE_MAX); \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && clips == 0); \
+ \
+  int##bits = SOX_INT_MAX(bits); \
+  sample = SOX_SIGNED_TO_SAMPLE(bits,int##bits); \
+  assert(sample == SOX_INT_MAX(bits) * SOX_SIGNED_TO_SAMPLE(bits,1)); \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && clips == 0); \
+ \
+  sample =SOX_UNSIGNED_TO_SAMPLE(bits,SOX_UINT_MAX(bits))+SOX_UNSIGNED_TO_SAMPLE(bits,((0^SOX_INT_MIN(bits))+1))/2-1; \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && clips == 0); \
+ \
+  sample =SOX_UNSIGNED_TO_SAMPLE(bits,SOX_UINT_MAX(bits))+SOX_UNSIGNED_TO_SAMPLE(bits,((0^SOX_INT_MIN(bits))+1))/2; \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && --clips == 0); \
+ \
+  sample = SOX_SAMPLE_MAX; \
+  int##bits##_2 = SOX_SAMPLE_TO_SIGNED(bits,sample, clips); \
+  assert(int##bits##_2 == int##bits && --clips == 0);
+
+int main()
+{
+  int8_t int8;
+  int16_t int16;
+  int24_t int24;
+
+  uint8_t uint8;
+  uint16_t uint16;
+  uint24_t uint24;
+
+  int8_t int8_2;
+  int16_t int16_2;
+  int24_t int24_2;
+
+  sox_sample_t sample;
+  sox_size_t clips = 0;
+
+  double d;
+
+  TEST_UINT(8)
+  TEST_UINT(16)
+  TEST_UINT(24)
+
+  TEST_SINT(8)
+  TEST_SINT(16)
+  TEST_SINT(24)
+
+  d = -1.0000000001;
+  sample = SOX_FLOAT_DDWORD_TO_SAMPLE(d, clips);
+  assert(sample == -SOX_SAMPLE_MAX && --clips == 0);
+
+  d = -1;
+  sample = SOX_FLOAT_DDWORD_TO_SAMPLE(d, clips);
+  assert(sample == -SOX_SAMPLE_MAX && clips == 0);
+  d = SOX_SAMPLE_TO_FLOAT_DDWORD(sample,clips);
+  assert(d == -1 && clips == 0);
+
+  --sample;
+  d = SOX_SAMPLE_TO_FLOAT_DDWORD(sample,clips);
+  assert(d == -1 && --clips == 0);
+
+  d = 1;
+  sample = SOX_FLOAT_DDWORD_TO_SAMPLE(d, clips);
+  assert(sample == SOX_SAMPLE_MAX && clips == 0);
+  d = SOX_SAMPLE_TO_FLOAT_DDWORD(sample,clips);
+  assert(d == 1 && clips == 0);
+
+  d = 1.0000000001;
+  sample = SOX_FLOAT_DDWORD_TO_SAMPLE(d, clips);
+  assert(sample == SOX_SAMPLE_MAX && --clips == 0);
+
+  {
+    enum {MEANT_TO_FAIL};
+    assert(MEANT_TO_FAIL);
+  }
+  return 0;
+}
--- /dev/null
+++ b/src/soxio.c
@@ -1,0 +1,347 @@
+#include "sox_i.h"
+
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/types.h> /* for fstat() */
+#include <sys/stat.h> /* for fstat() */
+
+#ifdef _MSC_VER
+/* __STDC__ is defined, so these symbols aren't created. */
+#define S_IFMT   _S_IFMT
+#define S_IFREG  _S_IFREG
+#define fstat _fstat
+#endif
+
+/* Based on zlib's minigzip: */
+#if defined(WIN32) || defined(__NT__)
+#include <fcntl.h>
+#include <io.h>
+#ifndef O_BINARY
+#define O_BINARY _O_BINARY
+#endif
+#define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
+#else
+#define SET_BINARY_MODE(file)
+#endif
+
+void set_endianness_if_not_already_set(ft_t ft)
+{
+  if (ft->signal.reverse_bytes == SOX_OPTION_DEFAULT) {
+    if (ft->h->flags & SOX_FILE_ENDIAN)
+      ft->signal.reverse_bytes = SOX_IS_LITTLEENDIAN != !(ft->h->flags & SOX_FILE_ENDBIG);
+    else
+      ft->signal.reverse_bytes = SOX_OPTION_NO;
+  }
+  if (ft->signal.reverse_nibbles == SOX_OPTION_DEFAULT)
+    ft->signal.reverse_nibbles = SOX_OPTION_NO;
+  if (ft->signal.reverse_bits == SOX_OPTION_DEFAULT)
+    ft->signal.reverse_bits = SOX_OPTION_NO;
+}
+
+static int is_seekable(ft_t ft)
+{
+        struct stat st;
+
+        fstat(fileno(ft->fp), &st);
+
+        return ((st.st_mode & S_IFMT) == S_IFREG);
+}
+
+/* check that all settings have been given */
+static int sox_checkformat(ft_t ft)
+{
+
+        ft->sox_errno = SOX_SUCCESS;
+
+        if (ft->signal.rate == 0)
+        {
+                sox_fail_errno(ft,SOX_EFMT,"sampling rate was not specified");
+                return SOX_EOF;
+        }
+
+        if (ft->signal.size == -1)
+        {
+                sox_fail_errno(ft,SOX_EFMT,"data size was not specified");
+                return SOX_EOF;
+        }
+
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN)
+        {
+                sox_fail_errno(ft,SOX_EFMT,"data encoding was not specified");
+                return SOX_EOF;
+        }
+
+        if ((ft->signal.size <= 0) || (ft->signal.size > SOX_INFO_SIZE_MAX))
+        {
+                sox_fail_errno(ft,SOX_EFMT,"data size %d is invalid", ft->signal.size);
+                return SOX_EOF;
+        }
+
+        if (ft->signal.encoding <= 0  || ft->signal.encoding >= SOX_ENCODINGS)
+        {
+                sox_fail_errno(ft,SOX_EFMT,"data encoding %d is invalid", ft->signal.encoding);
+                return SOX_EOF;
+        }
+
+        return SOX_SUCCESS;
+}
+
+ft_t sox_open_read(const char *path, const sox_signalinfo_t *info,
+                  const char *filetype)
+{
+    ft_t ft = (ft_t)xcalloc(sizeof(struct sox_soundstream), 1);
+
+    ft->filename = xstrdup(path);
+
+    /* Let auto type do the work if user is not overriding. */
+    if (!filetype)
+        ft->filetype = xstrdup("auto");
+    else
+        ft->filetype = xstrdup(filetype);
+
+    if (sox_gettype(ft, sox_false) != SOX_SUCCESS) {
+        sox_warn("Unknown input file format for `%s':  %s",
+                ft->filename,
+                ft->sox_errstr);
+        goto input_error;
+    }
+
+    ft->signal.size = -1;
+    ft->signal.encoding = SOX_ENCODING_UNKNOWN;
+    ft->signal.channels = 0;
+    if (info)
+        ft->signal = *info;
+    ft->mode = 'r';
+
+    if (!(ft->h->flags & SOX_FILE_NOSTDIO))
+    {
+        /* Open file handler based on input name.  Used stdin file handler
+         * if the filename is "-"
+         */
+        if (!strcmp(ft->filename, "-"))
+        {
+            SET_BINARY_MODE(stdin);
+            ft->fp = stdin;
+        }
+        else if ((ft->fp = fopen(ft->filename, "rb")) == NULL)
+        {
+            sox_warn("Can't open input file `%s': %s", ft->filename,
+                    strerror(errno));
+            goto input_error;
+        }
+
+        /* See if this file is seekable or not */
+        ft->seekable = is_seekable(ft);
+    }
+
+    if (filetype)
+      set_endianness_if_not_already_set(ft);
+
+    /* Read and write starters can change their formats. */
+    if ((*ft->h->startread)(ft) != SOX_SUCCESS)
+    {
+        sox_warn("Failed reading `%s': %s", ft->filename, ft->sox_errstr);
+        goto input_error;
+    }
+
+    /* Go a head and assume 1 channel audio if nothing is detected.
+     * This is because libst usually doesn't set this for mono file
+     * formats (for historical reasons).
+     */
+    if (ft->signal.channels == 0)
+        ft->signal.channels = 1;
+
+    if (sox_checkformat(ft) )
+    {
+        sox_warn("bad input format for file %s: %s", ft->filename,
+                ft->sox_errstr);
+        goto input_error;
+    }
+    return ft;
+
+input_error:
+
+    free(ft->filename);
+    free(ft->filetype);
+    free(ft);
+    return NULL;
+}
+
+#if defined(DOS) || defined(WIN32)
+#define LASTCHAR '\\'
+#else
+#define LASTCHAR '/'
+#endif
+
+ft_t sox_open_write(
+    sox_bool (*overwrite_permitted)(const char *filename),
+    const char *path,
+    const sox_signalinfo_t *info,
+    const char *filetype,
+    const char *comment,
+    const sox_instrinfo_t *instr,
+    const sox_loopinfo_t *loops)
+{
+    ft_t ft = (ft_t)xcalloc(sizeof(struct sox_soundstream), 1);
+    int i;
+    sox_bool no_filetype_given = filetype == NULL;
+
+    ft->filename = xstrdup(path);
+
+    /* Let auto effect do the work if user is not overriding. */
+    if (!filetype) {
+        char *chop;
+        int len;
+
+        len = strlen(ft->filename);
+
+        /* Use filename extension to determine audio type.
+         * Search for the last '.' appearing in the filename, same
+         * as for input files.
+         */
+        chop = ft->filename + len;
+        while (chop > ft->filename && *chop != LASTCHAR && *chop != '.')
+            chop--;
+
+        if (*chop == '.') {
+            chop++;
+            ft->filetype = xstrdup(chop);
+        }
+    } else
+        ft->filetype = xstrdup(filetype);
+
+    if (!ft->filetype || sox_gettype(ft, no_filetype_given) != SOX_SUCCESS)
+    {
+        sox_fail("Unknown output file format for '%s':  %s",
+                ft->filename,
+                ft->sox_errstr);
+        goto output_error;
+    }
+
+    ft->signal.size = -1;
+    ft->signal.encoding = SOX_ENCODING_UNKNOWN;
+    ft->signal.channels = 0;
+    if (info)
+        ft->signal = *info;
+    ft->mode = 'w';
+
+    if (!(ft->h->flags & SOX_FILE_NOSTDIO))
+    {
+        /* Open file handler based on output name.  Used stdout file handler
+         * if the filename is "-"
+         */
+        if (!strcmp(ft->filename, "-"))
+        {
+            SET_BINARY_MODE(stdout);
+            ft->fp = stdout;
+        }
+        else {
+          struct stat st;
+          if (!stat(ft->filename, &st) && (st.st_mode & S_IFMT) == S_IFREG &&
+              !overwrite_permitted(ft->filename)) {
+            sox_fail("Permission to overwrite '%s' denied", ft->filename);
+            goto output_error;
+          }
+          if ((ft->fp = fopen(ft->filename, "wb")) == NULL) {
+            sox_fail("Can't open output file '%s': %s", ft->filename,
+                    strerror(errno));
+            goto output_error;
+          }
+        }
+
+        /* stdout tends to be line-buffered.  Override this */
+        /* to be Full Buffering. */
+        if (setvbuf (ft->fp, NULL, _IOFBF, sizeof(char)*SOX_BUFSIZ))
+        {
+            sox_fail("Can't set write buffer");
+            goto output_error;
+        }
+
+        /* See if this file is seekable or not */
+        ft->seekable = is_seekable(ft);
+    }
+
+    ft->comment = xstrdup(comment);
+
+    if (loops)
+        for (i = 0; i < SOX_MAX_NLOOPS; i++)
+            ft->loops[i] = loops[i];
+
+    /* leave SMPTE # alone since it's absolute */
+    if (instr)
+        ft->instr = *instr;
+
+    set_endianness_if_not_already_set(ft);
+
+    /* Read and write starters can change their formats. */
+    if ((*ft->h->startwrite)(ft) != SOX_SUCCESS)
+    {
+        sox_fail("Failed writing %s: %s", ft->filename, ft->sox_errstr);
+        goto output_error;
+    }
+
+    if (sox_checkformat(ft) )
+    {
+        sox_fail("bad output format for file %s: %s", ft->filename,
+                ft->sox_errstr);
+        goto output_error;
+    }
+
+    return ft;
+
+output_error:
+
+    free(ft->filename);
+    free(ft->filetype);
+    free(ft);
+    return NULL;
+}
+
+sox_size_t sox_read(ft_t f, sox_sample_t * buf, sox_size_t len)
+{
+  sox_size_t actual = (*f->h->read)(f, buf, len);
+  return (actual > len? 0 : actual);
+}
+
+sox_size_t sox_write(ft_t ft, const sox_sample_t *buf, sox_size_t len)
+{
+    return (*ft->h->write)(ft, buf, len);
+}
+
+/* N.B. The file (if any) may already have been deleted. */
+int sox_close(ft_t ft)
+{
+    int rc;
+
+    if (ft->mode == 'r')
+        rc = (*ft->h->stopread)(ft);
+    else
+        rc = (*ft->h->stopwrite)(ft);
+
+    if (!(ft->h->flags & SOX_FILE_NOSTDIO))
+        fclose(ft->fp);
+    free(ft->filename);
+    free(ft->filetype);
+    /* Currently, since startread() mallocs comments, stopread
+     * is expected to also free it. */
+    if (ft->mode == 'w')
+        free(ft->comment);
+
+    return rc;
+}
+
+int sox_seek(ft_t ft, sox_size_t offset, int whence)       
+{       
+    /* FIXME: Implement SOX_SEEK_CUR and SOX_SEEK_END. */         
+    if (whence != SOX_SEEK_SET)          
+        return SOX_EOF; /* FIXME: return SOX_EINVAL */    
+
+    /* If file is a seekable file and this handler supports seeking,    
+     * the invoke handlers function.    
+     */         
+    if (ft->seekable  && (ft->h->flags & SOX_FILE_SEEK))         
+        return (*ft->h->seek)(ft, offset);      
+    else        
+        return SOX_EOF; /* FIXME: return SOX_EBADF */     
+}
--- a/src/speed.c
+++ b/src/speed.c
@@ -23,18 +23,18 @@
  * actually performed by whichever resampling effect is in effect.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <math.h>
 #include <string.h>
 
 static int getopts(eff_t effp, int n, char * * argv)
 {
-  st_bool is_cents = st_false;
+  sox_bool is_cents = sox_false;
   double speed;
 
   /* Be quietly compatible with the old speed effect: */
   if (n != 0 && strcmp(*argv, "-c") == 0)
-    is_cents = st_true, ++argv, --n;
+    is_cents = sox_true, ++argv, --n;
 
   if (n == 1) {
     char c, dummy;
@@ -43,17 +43,17 @@
       is_cents |= scanned == 2;
       if (is_cents || speed > 0) {
         effp->globalinfo->speed *= is_cents? pow(2, speed/1200) : speed;
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
       }
     }
   }
-  st_fail(effp->h->usage);
-  return ST_EOF;
+  sox_fail(effp->h->usage);
+  return SOX_EOF;
 }
 
-st_effect_t const *st_speed_effect_fn(void)
+sox_effect_t const *sox_speed_effect_fn(void)
 {
-  static st_effect_t driver = {
-    "speed", "Usage: speed factor[c]", ST_EFF_NULL, getopts, 0, 0, 0, 0, 0};
+  static sox_effect_t driver = {
+    "speed", "Usage: speed factor[c]", SOX_EFF_NULL, getopts, 0, 0, 0, 0, 0};
   return &driver;
 }
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -7,7 +7,7 @@
  *
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <math.h>
 #include <string.h>
@@ -16,7 +16,7 @@
 /* Private data for sphere file */
 typedef struct spherestuff {
         char      shorten_check[4];
-        st_size_t numSamples;
+        sox_size_t numSamples;
 } *sphere_t;
 
 /*
@@ -26,7 +26,7 @@
  *      size and encoding of samples, 
  *      mono/stereo/quad.
  */
-static int st_spherestartread(ft_t ft) 
+static int sox_spherestartread(ft_t ft) 
 {
         sphere_t sphere = (sphere_t) ft->priv;
         int rc;
@@ -37,21 +37,21 @@
         long rate;
 
         /* Needed for rawread() */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
         /* Magic header */
-        if (st_reads(ft, fldname, 8) == ST_EOF || strncmp(fldname, "NIST_1A", 7) != 0)
+        if (sox_reads(ft, fldname, 8) == SOX_EOF || strncmp(fldname, "NIST_1A", 7) != 0)
         {
-            st_fail_errno(ft,ST_EHDR,"Sphere header does not begin with magic mord 'NIST_1A'");
-            return(ST_EOF);
+            sox_fail_errno(ft,SOX_EHDR,"Sphere header does not begin with magic mord 'NIST_1A'");
+            return(SOX_EOF);
         }
 
-        if (st_reads(ft, fldsval, 8) == ST_EOF)
+        if (sox_reads(ft, fldsval, 8) == SOX_EOF)
         {
-            st_fail_errno(ft,ST_EHDR,"Error reading Sphere header");
-            return(ST_EOF);
+            sox_fail_errno(ft,SOX_EHDR,"Error reading Sphere header");
+            return(SOX_EOF);
         }
 
         /* Determine header size, and allocate a buffer large enough to hold it. */
@@ -61,11 +61,11 @@
         /* Skip what we have read so far */
         header_size -= 16;
 
-        if (st_reads(ft, buf, header_size) == ST_EOF)
+        if (sox_reads(ft, buf, header_size) == SOX_EOF)
         {
-            st_fail_errno(ft,ST_EHDR,"Error reading Sphere header");
+            sox_fail_errno(ft,SOX_EHDR,"Error reading Sphere header");
             free(buf);
-            return(ST_EOF);
+            return(SOX_EOF);
         }
 
         header_size -= (strlen(buf) + 1);
@@ -89,10 +89,10 @@
                 /* Only bother looking for ulaw flag.  All others
                  * should be caught below by default PCM check
                  */
-                if (ft->signal.encoding == ST_ENCODING_UNKNOWN && 
+                if (ft->signal.encoding == SOX_ENCODING_UNKNOWN && 
                     strncmp(fldsval,"ulaw",4) == 0)
                 {
-                    ft->signal.encoding = ST_ENCODING_ULAW;
+                    ft->signal.encoding = SOX_ENCODING_ULAW;
                 }
             }
             if (strncmp(buf, "sample_rate ", 12) == 0 &&
@@ -105,16 +105,16 @@
             {
                 sscanf(buf, "%53s %15s %127s", fldname, fldtype, fldsval);
                 if (strncmp(fldsval,"01",2) == 0)
-                  ft->signal.reverse_bytes = ST_IS_BIGENDIAN; /* Data is little endian. */
+                  ft->signal.reverse_bytes = SOX_IS_BIGENDIAN; /* Data is little endian. */
                 else if (strncmp(fldsval,"10",2) == 0)
-                  ft->signal.reverse_bytes = ST_IS_LITTLEENDIAN; /* Data is big endian. */
+                  ft->signal.reverse_bytes = SOX_IS_LITTLEENDIAN; /* Data is big endian. */
             }
 
-            if (st_reads(ft, buf, header_size) == ST_EOF)
+            if (sox_reads(ft, buf, header_size) == SOX_EOF)
             {
-                st_fail_errno(ft,ST_EHDR,"Error reading Sphere header");
+                sox_fail_errno(ft,SOX_EHDR,"Error reading Sphere header");
                 free(buf);
-                return(ST_EOF);
+                return(SOX_EOF);
             }
 
             header_size -= (strlen(buf) + 1);
@@ -121,27 +121,27 @@
         }
 
         if (ft->signal.size == -1)
-            ft->signal.size = ST_SIZE_BYTE;
+            ft->signal.size = SOX_SIZE_BYTE;
 
         /* sample_coding is optional and is PCM if missing.
          * This means encoding is signed if size = word or
          * unsigned if size = byte.
          */
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN)
         {
             if (ft->signal.size == 1)
-                ft->signal.encoding = ST_ENCODING_UNSIGNED;
+                ft->signal.encoding = SOX_ENCODING_UNSIGNED;
             else
-                ft->signal.encoding = ST_ENCODING_SIGN2;
+                ft->signal.encoding = SOX_ENCODING_SIGN2;
         }
 
         while (header_size)
         {
-            bytes_read = st_readbuf(ft, buf, ST_SIZE_BYTE, header_size);
+            bytes_read = sox_readbuf(ft, buf, SOX_SIZE_BYTE, header_size);
             if (bytes_read == 0)
             {
                 free(buf);
-                return(ST_EOF);
+                return(SOX_EOF);
             }
             header_size -= bytes_read;
         }
@@ -151,17 +151,17 @@
         /* Check first four bytes of data to see if it's shorten
          * compressed or not.
          */
-        st_reads(ft, sphere->shorten_check, 4);
+        sox_reads(ft, sphere->shorten_check, 4);
 
         if (!strcmp(sphere->shorten_check,"ajkg"))
         {
-            st_fail_errno(ft,ST_EFMT,"File uses shorten compression, cannot handle this.");
+            sox_fail_errno(ft,SOX_EFMT,"File uses shorten compression, cannot handle this.");
             free(buf);
-            return(ST_EOF);
+            return(SOX_EOF);
         }
 
         free(buf);
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /*
@@ -171,7 +171,7 @@
  * Return number of samples read.
  */
 
-static st_size_t st_sphereread(ft_t ft, st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_sphereread(ft_t ft, sox_sample_t *buf, sox_size_t len) 
 {
     sphere_t sphere = (sphere_t) ft->priv;
 
@@ -182,10 +182,10 @@
          */
         sphere->shorten_check[0] = 0;
     }
-    return st_rawread(ft, buf, len);
+    return sox_rawread(ft, buf, len);
 }
 
-static int st_spherestartwrite(ft_t ft) 
+static int sox_spherestartwrite(ft_t ft) 
 {
     int rc;
     int x;
@@ -193,46 +193,46 @@
 
     if (!ft->seekable)
     {
-        st_fail_errno(ft,ST_EOF,"File must be seekable for sphere file output");
-        return (ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"File must be seekable for sphere file output");
+        return (SOX_EOF);
     }
 
     switch (ft->signal.encoding)
     {
-        case ST_ENCODING_ULAW:
-        case ST_ENCODING_SIGN2:
-        case ST_ENCODING_UNSIGNED:
+        case SOX_ENCODING_ULAW:
+        case SOX_ENCODING_SIGN2:
+        case SOX_ENCODING_UNSIGNED:
             break;
         default:
-            st_fail_errno(ft,ST_EFMT,"SPHERE format only supports ulaw and PCM data.");
-            return(ST_EOF);
+            sox_fail_errno(ft,SOX_EFMT,"SPHERE format only supports ulaw and PCM data.");
+            return(SOX_EOF);
     }
 
     sphere->numSamples = 0;
 
     /* Needed for rawwrite */
-    rc = st_rawstartwrite(ft);
+    rc = sox_rawstartwrite(ft);
     if (rc)
         return rc;
 
     for (x = 0; x < 1024; x++)
     {
-        st_writeb(ft, ' ');
+        sox_writeb(ft, ' ');
     }
 
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
         
 }
 
-static st_size_t st_spherewrite(ft_t ft, const st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_spherewrite(ft_t ft, const sox_sample_t *buf, sox_size_t len) 
 {
     sphere_t sphere = (sphere_t) ft->priv;
 
     sphere->numSamples += len; /* must later be divided by channels */
-    return st_rawwrite(ft, buf, len);
+    return sox_rawwrite(ft, buf, len);
 }
 
-static int st_spherestopwrite(ft_t ft) 
+static int sox_spherestopwrite(ft_t ft) 
 {
     int rc;
     char buf[128];
@@ -239,45 +239,45 @@
     sphere_t sphere = (sphere_t) ft->priv;
     long samples, rate;
 
-    rc = st_rawstopwrite(ft);
+    rc = sox_rawstopwrite(ft);
     if (rc)
         return rc;
 
-    if (st_seeki(ft, 0, 0) != 0)
+    if (sox_seeki(ft, 0, 0) != 0)
     {
-        st_fail_errno(ft,errno,"Could not rewird output file to rewrite sphere header.");
-        return (ST_EOF);
+        sox_fail_errno(ft,errno,"Could not rewird output file to rewrite sphere header.");
+        return (SOX_EOF);
     }
 
-    st_writes(ft, "NIST_1A\n");
-    st_writes(ft, "   1024\n");
+    sox_writes(ft, "NIST_1A\n");
+    sox_writes(ft, "   1024\n");
 
     samples = sphere->numSamples/ft->signal.channels;
     sprintf(buf, "sample_count -i %ld\n", samples);
-    st_writes(ft, buf);
+    sox_writes(ft, buf);
 
     sprintf(buf, "sample_n_bytes -i %d\n", ft->signal.size);
-    st_writes(ft, buf);
+    sox_writes(ft, buf);
 
     sprintf(buf, "channel_count -i %d\n", ft->signal.channels);
-    st_writes(ft, buf);
+    sox_writes(ft, buf);
 
     sprintf(buf, "sample_byte_format -s2 %s\n",
-        ft->signal.reverse_bytes != ST_IS_BIGENDIAN ? "10" : "01");
-    st_writes(ft, buf);
+        ft->signal.reverse_bytes != SOX_IS_BIGENDIAN ? "10" : "01");
+    sox_writes(ft, buf);
 
     rate = ft->signal.rate;
     sprintf(buf, "sample_rate -i %ld\n", rate);
-    st_writes(ft, buf);
+    sox_writes(ft, buf);
 
-    if (ft->signal.encoding == ST_ENCODING_ULAW)
-        st_writes(ft, "sample_coding -s4 ulaw\n");
+    if (ft->signal.encoding == SOX_ENCODING_ULAW)
+        sox_writes(ft, "sample_coding -s4 ulaw\n");
     else
-        st_writes(ft, "sample_coding -s3 pcm\n");
+        sox_writes(ft, "sample_coding -s3 pcm\n");
 
-    st_writes(ft, "end_head\n");
+    sox_writes(ft, "end_head\n");
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /* NIST Sphere File */
@@ -287,20 +287,20 @@
   NULL
 };
 
-static st_format_t st_sphere_format = {
+static sox_format_t sox_sphere_format = {
   spherenames,
   NULL,
   0,
-  st_spherestartread,
-  st_sphereread,
-  st_rawstopread,
-  st_spherestartwrite,
-  st_spherewrite,
-  st_spherestopwrite,
-  st_format_nothing_seek
+  sox_spherestartread,
+  sox_sphereread,
+  sox_rawstopread,
+  sox_spherestartwrite,
+  sox_spherewrite,
+  sox_spherestopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_sphere_format_fn(void)
+const sox_format_t *sox_sphere_format_fn(void)
 {
-    return &st_sphere_format;
+    return &sox_sphere_format;
 }
--- a/src/st.h
+++ /dev/null
@@ -1,452 +1,0 @@
-/*
- * Sound Tools Library
- *
- * Copyright 1999-2007 Chris Bagwell and SoX Contributors.
- *
- * This source code is freely redistributable and may be used for
- * any purpose.  This copyright notice must be maintained.
- * Chris Bagwell And SoX Contributors are not responsible for
- * the consequences of using this software.
- */
-
-#ifndef ST_H
-#define ST_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "ststdint.h"
-
-/* The following is the API version of libst.  It is not meant
- * to follow the version number of SoX but it has historically.
- * Please do not count of these numbers being in sync.
- * The following is at 13.0.0
- */
-#define ST_LIB_VERSION_CODE 0x0d0000
-#define ST_LIB_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-
-/* Avoid warnings about unused parameters. */
-#ifdef __GNUC__
-#define UNUSED __attribute__ ((unused))
-#endif
-
-/* C language enhancements: */
-
-/* Boolean type, compatible with C++ */
-typedef enum {st_false, st_true} st_bool;
-
-typedef int32_t int24_t;     /* But beware of the extra byte. */
-typedef uint32_t uint24_t;   /* ditto */
-
-#define ST_INT_MIN(bits) (1 <<((bits)-1))
-#define ST_INT_MAX(bits) (-1U>>(33-(bits)))
-#define ST_UINT_MAX(bits) (ST_INT_MIN(bits)|ST_INT_MAX(bits))
-
-#define ST_INT8_MAX  ST_INT_MAX(8)
-#define ST_INT16_MAX ST_INT_MAX(16)
-#define ST_INT24_MAX ST_INT_MAX(24)
-#define ST_INT32_MAX ST_INT_MAX(32)
-#define ST_INT64_MAX 0x7fffffffffffffffLL /* Not in use yet */
-
-typedef int32_t st_sample_t;
-typedef uint32_t st_usample_t; /* FIXME: this naming is different from
-                                  other types */
-/* Minimum and maximum values a sample can hold. */
-#define ST_SAMPLE_MAX (st_sample_t)ST_INT_MAX(32)
-#define ST_SAMPLE_MIN (st_sample_t)ST_INT_MIN(32)
-
-
-
-/*                Conversions: Linear PCM <--> st_sample_t
- *
- *   I/O       I/O     st_sample_t  Clips?    I/O     st_sample_t  Clips? 
- *  Format   Minimum     Minimum     I O    Maximum     Maximum     I O      
- *  ------  ---------  ------------ -- --   --------  ------------ -- --  
- *  Float      -1     -1.00000000047 y y       1           1        y n         
- *  Byte      -128        -128       n n      127     127.9999999   n y   
- *  Word     -32768      -32768      n n     32767    32767.99998   n y   
- *  24bit   -8388608    -8388608     n n    8388607   8388607.996   n y   
- *  Dword  -2147483648 -2147483648   n n   2147483647 2147483647    n n   
- *
- * Conversions are as accurate as possible (with rounding).
- *
- * Rounding: halves toward +inf, all others to nearest integer.
- *
- * Clips? shows whether on not there is the possibility of a conversion
- * clipping to the minimum or maximum value when inputing from or outputing 
- * to a given type.
- *
- * Unsigned integers are converted to and from signed integers by flipping
- * the upper-most bit then treating them as signed integers.
- */
-
-/* Temporary variables to prevent multiple evaluation of macro arguments: */
-static st_sample_t st_macro_temp_sample UNUSED;
-static double st_macro_temp_double UNUSED;
-
-#define ST_SAMPLE_NEG ST_INT_MIN(32)
-#define ST_SAMPLE_TO_UNSIGNED(bits,d,clips) \
-  (uint##bits##_t)( \
-    st_macro_temp_sample=d, \
-    st_macro_temp_sample>(st_sample_t)(ST_SAMPLE_MAX-(1U<<(31-bits)))? \
-      ++(clips),ST_UINT_MAX(bits): \
-      ((uint32_t)(st_macro_temp_sample^ST_SAMPLE_NEG)+(1U<<(31-bits)))>>(32-bits))
-#define ST_SAMPLE_TO_SIGNED(bits,d,clips) \
-  (int##bits##_t)(ST_SAMPLE_TO_UNSIGNED(bits,d,clips)^ST_INT_MIN(bits))
-#define ST_SIGNED_TO_SAMPLE(bits,d)((st_sample_t)(d)<<(32-bits))
-#define ST_UNSIGNED_TO_SAMPLE(bits,d)(ST_SIGNED_TO_SAMPLE(bits,d)^ST_SAMPLE_NEG)
-
-#define ST_UNSIGNED_BYTE_TO_SAMPLE(d,clips) ST_UNSIGNED_TO_SAMPLE(8,d)
-#define ST_SIGNED_BYTE_TO_SAMPLE(d,clips) ST_SIGNED_TO_SAMPLE(8,d)
-#define ST_UNSIGNED_WORD_TO_SAMPLE(d,clips) ST_UNSIGNED_TO_SAMPLE(16,d)
-#define ST_SIGNED_WORD_TO_SAMPLE(d,clips) ST_SIGNED_TO_SAMPLE(16,d)
-#define ST_UNSIGNED_24BIT_TO_SAMPLE(d,clips) ST_UNSIGNED_TO_SAMPLE(24,d)
-#define ST_SIGNED_24BIT_TO_SAMPLE(d,clips) ST_SIGNED_TO_SAMPLE(24,d)
-#define ST_UNSIGNED_DWORD_TO_SAMPLE(d,clips) (st_sample_t)((d)^ST_SAMPLE_NEG)
-#define ST_SIGNED_DWORD_TO_SAMPLE(d,clips) (st_sample_t)(d)
-#define ST_FLOAT_DWORD_TO_SAMPLE ST_FLOAT_DDWORD_TO_SAMPLE
-#define ST_FLOAT_DDWORD_TO_SAMPLE(d,clips) (st_macro_temp_double=d,st_macro_temp_double<-1?++(clips),(-ST_SAMPLE_MAX):st_macro_temp_double>1?++(clips),ST_SAMPLE_MAX:(st_sample_t)((uint32_t)((double)(st_macro_temp_double)*ST_SAMPLE_MAX+(ST_SAMPLE_MAX+.5))-ST_SAMPLE_MAX))
-#define ST_SAMPLE_TO_UNSIGNED_BYTE(d,clips) ST_SAMPLE_TO_UNSIGNED(8,d,clips)
-#define ST_SAMPLE_TO_SIGNED_BYTE(d,clips) ST_SAMPLE_TO_SIGNED(8,d,clips)
-#define ST_SAMPLE_TO_UNSIGNED_WORD(d,clips) ST_SAMPLE_TO_UNSIGNED(16,d,clips)
-#define ST_SAMPLE_TO_SIGNED_WORD(d,clips) ST_SAMPLE_TO_SIGNED(16,d,clips)
-#define ST_SAMPLE_TO_UNSIGNED_24BIT(d,clips) ST_SAMPLE_TO_UNSIGNED(24,d,clips)
-#define ST_SAMPLE_TO_SIGNED_24BIT(d,clips) ST_SAMPLE_TO_SIGNED(24,d,clips)
-#define ST_SAMPLE_TO_UNSIGNED_DWORD(d,clips) (uint32_t)((d)^ST_SAMPLE_NEG)
-#define ST_SAMPLE_TO_SIGNED_DWORD(d,clips) (int32_t)(d)
-#define ST_SAMPLE_TO_FLOAT_DWORD ST_SAMPLE_TO_FLOAT_DDWORD
-#define ST_SAMPLE_TO_FLOAT_DDWORD(d,clips) (st_macro_temp_sample=d,st_macro_temp_sample==ST_SAMPLE_MIN?++(clips),-1.0:((double)(st_macro_temp_sample)*(1.0/ST_SAMPLE_MAX)))
-
-
-
-/* MACRO to clip a data type that is greater then st_sample_t to
- * st_sample_t's limits and increment a counter if clipping occurs..
- */
-#define ST_SAMPLE_CLIP_COUNT(samp, clips) \
-  do { \
-    if (samp > ST_SAMPLE_MAX) \
-      { samp = ST_SAMPLE_MAX; clips++; } \
-    else if (samp < ST_SAMPLE_MIN) \
-      { samp = ST_SAMPLE_MIN; clips++; } \
-  } while (0)
-
-/* Rvalue MACRO to round and clip a double to a st_sample_t,
- * and increment a counter if clipping occurs.
- */
-#define ST_ROUND_CLIP_COUNT(d, clips) \
-  ((d) < 0? (d) <= ST_SAMPLE_MIN - 0.5? ++(clips), ST_SAMPLE_MIN: (d) - 0.5 \
-        : (d) >= ST_SAMPLE_MAX + 0.5? ++(clips), ST_SAMPLE_MAX: (d) + 0.5)
-
-/* Rvalue MACRO to clip a st_sample_t to 24 bits,
- * and increment a counter if clipping occurs.
- */
-#define ST_24BIT_CLIP_COUNT(l, clips) \
-  ((l) >= ((st_sample_t)1 << 23)? ++(clips), ((st_sample_t)1 << 23) - 1 : \
-   (l) <=-((st_sample_t)1 << 23)? ++(clips),-((st_sample_t)1 << 23) + 1 : (l))
-
-
-
-typedef uint32_t st_size_t;
-/* Maximum value size type can hold. (Minimum is 0). */
-#define ST_SIZE_MAX 0xffffffff
-
-typedef int32_t st_ssize_t;
-/* Minimum and maximum value signed size type can hold. */
-#define ST_SSIZE_MAX 0x7fffffff
-#define ST_SSIZE_MIN (-ST_SSIZE_MAX - 1)
-
-typedef unsigned st_rate_t;
-/* Warning, this is a MAX value used in the library.  Each format and
- * effect may have its own limitations of rate.
- */
-#define ST_MAXRATE      (50U * 1024) /* maximum sample rate in library */
-
-typedef enum {
-  ST_ENCODING_UNKNOWN   ,
-
-  ST_ENCODING_ULAW      , /* u-law signed logs: US telephony, SPARC */
-  ST_ENCODING_ALAW      , /* A-law signed logs: non-US telephony */
-  ST_ENCODING_ADPCM     , /* G72x Compressed PCM */
-  ST_ENCODING_MS_ADPCM  , /* Microsoft Compressed PCM */
-  ST_ENCODING_IMA_ADPCM , /* IMA Compressed PCM */
-  ST_ENCODING_OKI_ADPCM , /* Dialogic/OKI Compressed PCM */
-
-  ST_ENCODING_SIZE_IS_WORD, /* FIXME: marks raw types (above) that mis-report size. st_signalinfo_t really needs a precision_in_bits item */
-
-  ST_ENCODING_UNSIGNED  , /* unsigned linear: Sound Blaster */
-  ST_ENCODING_SIGN2     , /* signed linear 2's comp: Mac */
-  ST_ENCODING_FLOAT     , /* 32-bit float */
-  ST_ENCODING_GSM       , /* GSM 6.10 33byte frame lossy compression */
-  ST_ENCODING_MP3       , /* MP3 compression */
-  ST_ENCODING_VORBIS    , /* Vorbis compression */
-  ST_ENCODING_FLAC      , /* FLAC compression */
-  ST_ENCODING_AMR_WB    , /* AMR-WB compression */
-
-  ST_ENCODINGS            /* End of list marker */
-} st_encoding_t;
-
-/* Global parameters */
-
-typedef struct  st_globalinfo
-{
-    st_bool octave_plot_effect;/* To help user choose effect & options */
-    double speed;         /* Gather up all speed changes here, then resample */
-} st_globalinfo_t;
-
-typedef enum {ST_OPTION_NO, ST_OPTION_YES, ST_OPTION_DEFAULT} st_option_t;
-
-/* Signal parameters */
-
-typedef struct st_signalinfo
-{
-    st_rate_t rate;       /* sampling rate */
-    int size;             /* compressed or uncompressed datum size */
-    st_encoding_t encoding; /* format of sample numbers */
-    unsigned channels;    /* number of sound channels */
-    double compression;   /* compression factor (where applicable) */
-
-    /* There is a delineation between these vars being tri-state and
-     * effectively boolean.  Logically the line falls between setting
-     * them up (could be done in stlib, or by the stlib client) and
-     * using them (in stlib).  Stlib's logic to set them up includes
-     * knowledge of the machine default and the format default.  (The
-     * sox client logic adds to this a layer of overridability via user
-     * options.)  The physical delineation is in the somewhat
-     * snappily-named stlib function `set_endianness_if_not_already_set'
-     * which is called at the right times (as files are openned) by the
-     * stlib core, not by the file drivers themselves.  The file drivers
-     * indicate to the stlib core if they have a preference using
-     * ST_FILE_xxx flags.
-     */
-    st_option_t reverse_bytes;    /* endiannesses... */
-    st_option_t reverse_nibbles;
-    st_option_t reverse_bits;
-} st_signalinfo_t;
-
-/* Loop parameters */
-
-typedef struct  st_loopinfo
-{
-    st_size_t    start;          /* first sample */
-    st_size_t    length;         /* length */
-    unsigned int count;          /* number of repeats, 0=forever */
-    signed char  type;           /* 0=no, 1=forward, 2=forward/back */
-} st_loopinfo_t;
-
-/* Instrument parameters */
-
-/* vague attempt at generic information for sampler-specific info */
-
-typedef struct  st_instrinfo
-{
-    char MIDInote;       /* for unity pitch playback */
-    char MIDIlow, MIDIhi;/* MIDI pitch-bend range */
-    char loopmode;       /* semantics of loop data */
-    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 */
-/* the loop behaviour, ie. single shot, bidirectional etc. */
-#define ST_LOOP_NONE          0
-#define ST_LOOP_8             32 /* 8 loops: don't know ?? */
-#define ST_LOOP_SUSTAIN_DECAY 64 /* AIFF style: one sustain & one decay loop */
-
-/*
- * File buffer info.  Holds info so that data can be read in blocks.
- */
-
-typedef struct st_fileinfo
-{
-    char          *buf;                 /* Pointer to data buffer */
-    size_t        size;                 /* Size of buffer */
-    size_t        count;                /* Count read in to buffer */
-    size_t        pos;                  /* Position in buffer */
-    unsigned char eof;                  /* Marker that EOF has been reached */
-} st_fileinfo_t;
-
-
-/*
- *  Format information for input and output files.
- */
-
-#define ST_MAX_FILE_PRIVSIZE    1000
-#define ST_MAX_EFFECT_PRIVSIZE 1000
-
-#define ST_MAX_NLOOPS           8
-
-/*
- * Handler structure for each format.
- */
-
-typedef struct st_soundstream *ft_t;
-
-typedef struct st_format {
-    const char   * const *names;
-    const char   *usage;
-    unsigned int flags;
-    int          (*startread)(ft_t ft);
-    st_size_t    (*read)(ft_t ft, st_sample_t *buf, st_size_t len);
-    int          (*stopread)(ft_t ft);
-    int          (*startwrite)(ft_t ft);
-    st_size_t    (*write)(ft_t ft, const st_sample_t *buf, st_size_t len);
-    int          (*stopwrite)(ft_t ft);
-    int          (*seek)(ft_t ft, st_size_t offset);
-} st_format_t;
-
-struct st_soundstream {
-    st_signalinfo_t signal;               /* signal specifications */
-    st_instrinfo_t  instr;                /* instrument specification */
-    st_loopinfo_t   loops[ST_MAX_NLOOPS]; /* Looping specification */
-    st_bool         seekable;             /* can seek on this file */
-    char            mode;                 /* read or write mode */
-    st_size_t       length;               /* frames in file, or 0 if unknown. */
-    st_size_t       clips;                /* increment if clipping occurs */
-    char            *filename;            /* file name */
-    char            *filetype;            /* type of file */
-    char            *comment;             /* comment string */
-    FILE            *fp;                  /* File stream pointer */
-    unsigned char   eof;                  /* Marker that EOF has been reached */
-    int             st_errno;             /* Failure error codes */
-    char            st_errstr[256];       /* Extend Failure text */
-    const st_format_t *h;                 /* format struct for this file */
-    /* The following is a portable trick to align this variable on
-     * an 8-byte boundery.  Once this is done, the buffer alloced
-     * after it should be align on an 8-byte boundery as well.
-     * This lets you cast any structure over the private area
-     * without concerns of alignment.
-     */
-    double priv1;
-    char   priv[ST_MAX_FILE_PRIVSIZE]; /* format's private data area */
-};
-
-/* file flags field */
-#define ST_FILE_LOOPS   1  /* does file format support loops? */
-#define ST_FILE_INSTR   2  /* does file format support instrument specs? */
-#define ST_FILE_SEEK    4  /* does file format support seeking? */
-#define ST_FILE_NOSTDIO 8  /* does not use stdio routines */
-#define ST_FILE_DEVICE  16 /* file is an audio device */
-#define ST_FILE_PHONY   32 /* phony file/device */
-/* These two for use by the stlib core or stlib clients: */
-#define ST_FILE_ENDIAN  64 /* is file format endian? */
-#define ST_FILE_ENDBIG  128/* if so, is it big endian? */
-/* These two for use by stlib drivers: */
-#define ST_FILE_LIT_END  (0   + 64)
-#define ST_FILE_BIG_END  (128 + 64)
-
-/* Size field */
-#define ST_SIZE_BYTE    1
-#define ST_SIZE_8BIT    1
-#define ST_SIZE_16BIT   2
-#define ST_SIZE_24BIT   3
-#define ST_SIZE_32BIT   4
-#define ST_SIZE_64BIT   8
-#define ST_INFO_SIZE_MAX     8
-
-/* declared in misc.c */
-extern const char * const st_sizes_str[];
-extern const char * const st_size_bits_str[];
-extern const char * const st_encodings_str[];
-
-#define ST_EFF_CHAN     1           /* Effect can mix channels up/down */
-#define ST_EFF_RATE     2           /* Effect can alter data rate */
-#define ST_EFF_MCHAN    4           /* Effect can handle multi-channel */
-#define ST_EFF_REPORT   8           /* Effect does not affect the audio */
-#define ST_EFF_DEPRECATED 16        /* Effect is living on borrowed time */
-#define ST_EFF_NULL     32          /* Effect does nothing */
-
-/*
- * Handler structure for each effect.
- */
-
-typedef struct st_effect *eff_t;
-
-typedef struct
-{
-    char const *name;               /* effect name */
-    char const *usage;
-    unsigned int flags;
-
-    int (*getopts)(eff_t effp, int argc, char *argv[]);
-    int (*start)(eff_t effp);
-    int (*flow)(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
-                st_size_t *isamp, st_size_t *osamp);
-    int (*drain)(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
-    int (*stop)(eff_t effp);
-    int (*kill)(eff_t effp);
-} st_effect_t;
-
-struct st_effect
-{
-    char const *name;               /* effect name */
-    struct st_globalinfo * globalinfo;/* global ST parameters */
-    struct st_signalinfo ininfo;    /* input signal specifications */
-    struct st_signalinfo outinfo;   /* output signal specifications */
-    const st_effect_t *h;           /* effects driver */
-    st_sample_t     *obuf;          /* output buffer */
-    st_size_t       odone, olen;    /* consumed, total length */
-    st_size_t       clips;   /* increment if clipping occurs */
-    /* The following is a portable trick to align this variable on
-     * an 8-byte boundary.  Once this is done, the buffer alloced
-     * after it should be align on an 8-byte boundery as well.
-     * This lets you cast any structure over the private area
-     * without concerns of alignment.
-     */
-    double priv1;
-    char priv[ST_MAX_EFFECT_PRIVSIZE]; /* private area for effect */
-};
-
-void set_endianness_if_not_already_set(ft_t ft);
-extern ft_t st_open_read(const char *path, const st_signalinfo_t *info, 
-                         const char *filetype);
-ft_t st_open_write(
-    st_bool (*overwrite_permitted)(const char *filename),
-    const char *path,
-    const st_signalinfo_t *info,
-    const char *filetype,
-    const char *comment,
-    const st_instrinfo_t *instr,
-    const st_loopinfo_t *loops);
-extern st_size_t st_read(ft_t ft, st_sample_t *buf, st_size_t len);
-extern st_size_t st_write(ft_t ft, const st_sample_t *buf, st_size_t len);
-extern int st_close(ft_t ft);
-
-#define ST_SEEK_SET 0
-extern int st_seek(ft_t ft, st_size_t offset, int whence);
-
-int st_geteffect_opt(eff_t, int, char **);
-int st_geteffect(eff_t, const char *);
-st_bool is_effect_name(char const * text);
-int st_updateeffect(eff_t, const st_signalinfo_t *in, const st_signalinfo_t *out, int);
-int st_gettype(ft_t, st_bool);
-ft_t st_initformat(void);
-char const * st_parsesamples(st_rate_t rate, const char *str, st_size_t *samples, char def);
-
-/* The following routines are unique to the trim effect.
- * st_trim_get_start can be used to find what is the start
- * of the trim operation as specified by the user.
- * st_trim_clear_start will reset what ever the user specified
- * back to 0.
- * These two can be used together to find out what the user
- * wants to trim and use a st_seek() operation instead.  After
- * st_seek()'ing, you should set the trim option to 0.
- */
-st_size_t st_trim_get_start(eff_t effp);
-void st_trim_clear_start(eff_t effp);
-
-extern char const * st_message_filename;
-
-#define ST_EOF (-1)
-#define ST_SUCCESS (0)
-
-const char *st_version(void);                   /* return version number */
-
-/* ST specific error codes.  The rest directly map from errno. */
-#define ST_EHDR 2000            /* Invalid Audio Header */
-#define ST_EFMT 2001            /* Unsupported data format */
-#define ST_ERATE 2002           /* Unsupported rate for format */
-#define ST_ENOMEM 2003          /* Can't alloc memory */
-#define ST_EPERM 2004           /* Operation not permitted */
-#define ST_ENOTSUP 2005         /* Operation not supported */
-#define ST_EINVAL 2006          /* Invalid argument */
-#define ST_EFFMT 2007           /* Unsupported file format */
-
-#endif
--- a/src/st_i.h
+++ /dev/null
@@ -1,370 +1,0 @@
-/*
- * Sound Tools Internal header
- *
- *   This file is meant for libst internal use only
- *
- * Copyright 2001-2007 Chris Bagwell and SoX Contributors
- *
- * This source code is freely redistributable and may be used for
- * any purpose.  This copyright notice must be maintained.
- * Chris Bagwell And SoX Contributors are not responsible for
- * the consequences of using this software.
- */
-
-#ifndef ST_I_H
-#define ST_I_H
-
-#include "stconfig.h"
-#include "st.h"
-#include "xmalloc.h"
-
-#include <stdarg.h>
-
-#ifdef HAVE_BYTESWAP_H
-#include <byteswap.h>
-#endif
-
-/* various gcc optimizations and portablity defines */
-#ifdef __GNUC__
-#define NORET __attribute__((noreturn))
-#else
-#define NORET
-#endif
-
-/* C language enhancements: */
-
-/* Compile-time ("static") assertion */
-/*   e.g. assert_static(sizeof(int) >= 4, int_type_too_small)    */
-#define assert_static(e,f) enum {assert_static__##f = 1/(e)}
-
-#ifdef min
-#undef min
-#endif
-#define min(a, b) ((a) <= (b) ? (a) : (b))
-
-#ifdef max
-#undef max
-#endif
-#define max(a, b) ((a) >= (b) ? (a) : (b))
-
-#define range_limit(x, lower, upper) (min(max(x, lower), upper))
-
-/* Array-length operator */
-#define array_length(a) (sizeof(a)/sizeof(a[0]))
-
-/* declared in misc.c */
-typedef struct {char const *text; int value;} enum_item;
-#define ENUM_ITEM(prefix, item) {#item, prefix##item},
-enum_item const * find_enum_text(
-    char const * text, enum_item const * enum_items);
-
-typedef enum {ST_SHORT, ST_INT, ST_FLOAT, ST_DOUBLE} st_data_t;
-typedef enum {ST_WAVE_SINE, ST_WAVE_TRIANGLE} st_wave_t;
-extern enum_item const st_wave_enum[];
-
-/* Define fseeko and ftello for platforms lacking them */
-#ifndef HAVE_FSEEKO
-#define fseeko fseek
-#define ftello ftell
-#define off_t long
-#endif
-
-/* Digitise one cycle of a wave and store it as
- * a table of samples of a specified data-type.
- */
-void st_generate_wave_table(
-    st_wave_t wave_type,
-    st_data_t data_type,
-    void * table,       /* Really of type indicated by data_type. */
-    uint32_t table_size,/* Number of points on the x-axis. */
-    double min,         /* Minimum value on the y-axis. (e.g. -1) */
-    double max,         /* Maximum value on the y-axis. (e.g. +1) */
-    double phase);      /* Phase at 1st point; 0..2pi. (e.g. pi/2 for cosine) */
-
-st_sample_t st_gcd(st_sample_t a, st_sample_t b);
-st_sample_t st_lcm(st_sample_t a, st_sample_t b);
-
-#ifndef HAVE_STRCASECMP
-int strcasecmp(const char *s1, const char *s2);
-int strncasecmp(char const * s1, char const * s2, size_t n);
-#endif
-
-#ifndef HAVE_STRDUP
-char *strdup(const char *s);
-#endif
-
-/* Read and write basic data types from "ft" stream.  Uses ft->swap for
- * possible byte swapping.
- */
-/* declared in misc.c */
-size_t st_readbuf(ft_t ft, void *buf, size_t size, st_size_t len);
-int st_skipbytes(ft_t ft, st_size_t n);
-int st_padbytes(ft_t ft, st_size_t n);
-size_t st_writebuf(ft_t ft, void const *buf, size_t size, st_size_t len);
-int st_reads(ft_t ft, char *c, st_size_t len);
-int st_writes(ft_t ft, char *c);
-int st_readb(ft_t ft, uint8_t *ub);
-int st_writeb(ft_t ft, uint8_t ub);
-int st_readw(ft_t ft, uint16_t *uw);
-int st_writew(ft_t ft, uint16_t uw);
-int st_read3(ft_t ft, uint24_t *u3);
-int st_write3(ft_t ft, uint24_t u3);
-int st_readdw(ft_t ft, uint32_t *udw);
-int st_writedw(ft_t ft, uint32_t udw);
-int st_readf(ft_t ft, float *f);
-int st_writef(ft_t ft, float f);
-int st_readdf(ft_t ft, double *d);
-int st_writedf(ft_t ft, double d);
-int st_seeki(ft_t ft, st_size_t offset, int whence);
-st_size_t st_filelength(ft_t ft);
-int st_flush(ft_t ft);
-st_size_t st_tell(ft_t ft);
-int st_eof(ft_t ft);
-int st_error(ft_t ft);
-void st_rewind(ft_t ft);
-void st_clearerr(ft_t ft);
-
-/* Utilities to read/write values endianness-independently */
-uint32_t get32_le(unsigned char **p);
-uint16_t get16_le(unsigned char **p);
-void put32_le(unsigned char **p, uint32_t val);
-void put16_le(unsigned char **p, int16_t val);
-void put32_be(unsigned char **p, int32_t val);
-void put16_be(unsigned char **p, short val);
-
-/* Utilities to byte-swap values, use libc optimized macros if possible  */
-#ifdef HAVE_BYTESWAP_H
-#define st_swapw(x) bswap_16(x)
-#define st_swapdw(x) bswap_32(x)
-#else
-#define st_swapw(uw) (((uw >> 8) | (uw << 8)) & 0xffff)
-#define st_swapdw(udw) ((udw >> 24) | ((udw >> 8) & 0xff00) | ((udw << 8) & 0xff0000) | (udw << 24))
-#endif
-float st_swapf(float f);
-uint32_t st_swap24(uint32_t udw);
-double st_swapd(double d);
-
-/* util.c */
-typedef void (*st_output_message_handler_t)(int level, const char *filename, const char *fmt, va_list ap);
-extern st_output_message_handler_t st_output_message_handler;
-extern int st_output_verbosity_level;
-void st_output_message(FILE *file, const char *filename, const char *fmt, va_list ap);
-
-void st_fail(const char *, ...);
-void st_warn(const char *, ...);
-void st_report(const char *, ...);
-void st_debug(const char *, ...);
-void st_debug_more(char const * fmt, ...);
-void st_debug_most(char const * fmt, ...);
-
-#define st_fail       st_message_filename=__FILE__,st_fail
-#define st_warn       st_message_filename=__FILE__,st_warn
-#define st_report     st_message_filename=__FILE__,st_report
-#define st_debug      st_message_filename=__FILE__,st_debug
-#define st_debug_more st_message_filename=__FILE__,st_debug_more
-#define st_debug_most st_message_filename=__FILE__,st_debug_most
-
-void st_fail_errno(ft_t, int, const char *, ...);
-
-int st_is_bigendian(void);
-int st_is_littleendian(void);
-
-#ifdef WORDS_BIGENDIAN
-#define ST_IS_BIGENDIAN 1
-#define ST_IS_LITTLEENDIAN 0
-#else
-#define ST_IS_BIGENDIAN 0
-#define ST_IS_LITTLEENDIAN 1
-#endif
-
-#ifndef M_PI
-#define M_PI    3.14159265358979323846
-#endif
-#ifndef M_PI_2
-#define M_PI_2  1.57079632679489661923  /* pi/2 */
-#endif
-
-/* The following is used at times in libst when alloc()ing buffers
- * to perform file I/O.  It can be useful to pass in similar sized
- * data to get max performance.
- */
-#define ST_BUFSIZ 8192
-
-/*=============================================================================
- * File Handlers
- *=============================================================================
- */
-
-/* Psion record header check, defined in prc.c */
-int prc_checkheader(ft_t ft, char *head);
-
-typedef const st_format_t *(*st_format_fn_t)(void);
-
-extern st_format_fn_t st_format_fns[];
-
-extern const st_format_t *st_aiff_format_fn(void);
-extern const st_format_t *st_aifc_format_fn(void);
-#ifdef HAVE_ALSA
-extern const st_format_t *st_alsa_format_fn(void);
-#endif
-extern const st_format_t *st_amr_wb_format_fn(void);
-extern const st_format_t *st_au_format_fn(void);
-extern const st_format_t *st_auto_format_fn(void);
-extern const st_format_t *st_avr_format_fn(void);
-extern const st_format_t *st_cdr_format_fn(void);
-extern const st_format_t *st_cvsd_format_fn(void);
-extern const st_format_t *st_dvms_format_fn(void);
-extern const st_format_t *st_dat_format_fn(void);
-#ifdef HAVE_LIBFLAC
-extern const st_format_t *st_flac_format_fn(void);
-#endif
-extern const st_format_t *st_gsm_format_fn(void);
-extern const st_format_t *st_hcom_format_fn(void);
-extern const st_format_t *st_ima_format_fn(void);
-extern const st_format_t *st_maud_format_fn(void);
-extern const st_format_t *st_mp3_format_fn(void);
-extern const st_format_t *st_nul_format_fn(void);
-#ifdef HAVE_OSS
-extern const st_format_t *st_ossdsp_format_fn(void);
-#endif
-extern const st_format_t *st_prc_format_fn(void);
-extern const st_format_t *st_raw_format_fn(void);
-extern const st_format_t *st_al_format_fn(void);
-extern const st_format_t *st_la_format_fn(void);
-extern const st_format_t *st_lu_format_fn(void);
-extern const st_format_t *st_s3_format_fn(void);
-extern const st_format_t *st_sb_format_fn(void);
-extern const st_format_t *st_sl_format_fn(void);
-extern const st_format_t *st_sw_format_fn(void);
-extern const st_format_t *st_u3_format_fn(void);
-extern const st_format_t *st_ub_format_fn(void);
-extern const st_format_t *st_u4_format_fn(void);
-extern const st_format_t *st_ul_format_fn(void);
-extern const st_format_t *st_uw_format_fn(void);
-extern const st_format_t *st_sf_format_fn(void);
-extern const st_format_t *st_smp_format_fn(void);
-extern const st_format_t *st_snd_format_fn(void);
-#ifdef HAVE_SNDFILE_H
-extern const st_format_t *st_sndfile_format_fn(void);
-#endif
-extern const st_format_t *st_sphere_format_fn(void);
-#ifdef HAVE_SUN_AUDIO
-extern const st_format_t *st_sun_format_fn(void);
-#endif
-extern const st_format_t *st_svx_format_fn(void);
-extern const st_format_t *st_txw_format_fn(void);
-extern const st_format_t *st_voc_format_fn(void);
-#if defined HAVE_LIBVORBISENC && defined HAVE_LIBVORBISFILE
-extern const st_format_t *st_vorbis_format_fn(void);
-#endif
-extern const st_format_t *st_vox_format_fn(void);
-extern const st_format_t *st_wav_format_fn(void);
-extern const st_format_t *st_wve_format_fn(void);
-extern const st_format_t *st_xa_format_fn(void);
-
-/* Raw I/O */
-int st_rawstartread(ft_t ft);
-st_size_t st_rawread(ft_t ft, st_sample_t *buf, st_size_t nsamp);
-int st_rawstopread(ft_t ft);
-int st_rawstartwrite(ft_t ft);
-st_size_t st_rawwrite(ft_t ft, const st_sample_t *buf, st_size_t nsamp);
-int st_rawstopwrite(ft_t ft);
-int st_rawseek(ft_t ft, st_size_t offset);
-
-/* libsndfile I/O */
-int st_sndfile_startread(ft_t ft);
-st_size_t st_sndfile_read(ft_t ft, st_sample_t *buf, st_size_t len);
-int st_sndfile_stopread(ft_t ft);
-int st_sndfile_startwrite(ft_t ft);
-st_size_t st_sndfile_write(ft_t ft, const st_sample_t *buf, st_size_t len);
-int st_sndfile_stopwrite(ft_t ft);
-int st_sndfile_seek(ft_t ft, st_size_t offset);
-
-
-/* The following functions can be used to simply return success if
- * a file handler or effect doesn't need to do anything special
- */
-int st_format_nothing(ft_t ft);
-st_size_t st_format_nothing_read_io(ft_t ft, st_sample_t *buf, st_size_t len);
-st_size_t st_format_nothing_write_io(ft_t ft, const st_sample_t *buf, st_size_t len);
-int st_format_nothing_seek(ft_t ft, st_size_t offset);
-int st_effect_nothing(eff_t effp);
-int st_effect_nothing_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, st_size_t *isamp, st_size_t *osamp);
-int st_effect_nothing_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
-int st_effect_nothing_getopts(eff_t effp, int n, char **argv UNUSED);
-
-int st_rawstart(ft_t ft, st_bool default_rate, st_bool default_channels, st_encoding_t encoding, signed char size, st_option_t rev_bits);
-#define st_rawstartread(ft) st_rawstart(ft, st_false, st_false, ST_ENCODING_UNKNOWN, -1, ST_OPTION_DEFAULT)
-#define st_rawstartwrite st_rawstartread
-#define st_rawstopread st_format_nothing
-
-/*=============================================================================
- * Effects
- *=============================================================================
- */
-
-typedef const st_effect_t *(*st_effect_fn_t)(void);
-
-extern st_effect_fn_t st_effect_fns[];
-
-extern const st_effect_t *st_allpass_effect_fn(void);
-extern const st_effect_t *st_avg_effect_fn(void);
-extern const st_effect_t *st_band_effect_fn(void);
-extern const st_effect_t *st_bandpass_effect_fn(void);
-extern const st_effect_t *st_bandreject_effect_fn(void);
-extern const st_effect_t *st_bass_effect_fn(void);
-extern const st_effect_t *st_chorus_effect_fn(void);
-extern const st_effect_t *st_compand_effect_fn(void);
-extern const st_effect_t *st_dcshift_effect_fn(void);
-extern const st_effect_t *st_deemph_effect_fn(void);
-extern const st_effect_t *st_dither_effect_fn(void);
-extern const st_effect_t *st_earwax_effect_fn(void);
-extern const st_effect_t *st_echo_effect_fn(void);
-extern const st_effect_t *st_echos_effect_fn(void);
-extern const st_effect_t *st_equalizer_effect_fn(void);
-extern const st_effect_t *st_fade_effect_fn(void);
-extern const st_effect_t *st_filter_effect_fn(void);
-extern const st_effect_t *st_flanger_effect_fn(void);
-extern const st_effect_t *st_highpass_effect_fn(void);
-extern const st_effect_t *st_highp_effect_fn(void);
-extern const st_effect_t *st_lowpass_effect_fn(void);
-extern const st_effect_t *st_lowp_effect_fn(void);
-extern const st_effect_t *st_mask_effect_fn(void);
-extern const st_effect_t *st_mcompand_effect_fn(void);
-extern const st_effect_t *st_mixer_effect_fn(void);
-extern const st_effect_t *st_noiseprof_effect_fn(void);
-extern const st_effect_t *st_noisered_effect_fn(void);
-extern const st_effect_t *st_pad_effect_fn(void);
-extern const st_effect_t *st_pan_effect_fn(void);
-extern const st_effect_t *st_phaser_effect_fn(void);
-extern const st_effect_t *st_pick_effect_fn(void);
-extern const st_effect_t *st_pitch_effect_fn(void);
-extern const st_effect_t *st_polyphase_effect_fn(void);
-#ifdef HAVE_SAMPLERATE_H
-extern const st_effect_t *st_rabbit_effect_fn(void);
-#endif
-extern const st_effect_t *st_rate_effect_fn(void);
-extern const st_effect_t *st_repeat_effect_fn(void);
-extern const st_effect_t *st_resample_effect_fn(void);
-extern const st_effect_t *st_reverb_effect_fn(void);
-extern const st_effect_t *st_reverse_effect_fn(void);
-extern const st_effect_t *st_silence_effect_fn(void);
-extern const st_effect_t *st_speed_effect_fn(void);
-extern const st_effect_t *st_stat_effect_fn(void);
-extern const st_effect_t *st_stretch_effect_fn(void);
-extern const st_effect_t *st_swap_effect_fn(void);
-extern const st_effect_t *st_synth_effect_fn(void);
-extern const st_effect_t *st_treble_effect_fn(void);
-extern const st_effect_t *st_tremolo_effect_fn(void);
-extern const st_effect_t *st_trim_effect_fn(void);
-extern const st_effect_t *st_vibro_effect_fn(void);
-extern const st_effect_t *st_vol_effect_fn(void);
-
-/* Needed in rate.c */
-int st_resample_start(eff_t effp);
-int st_resample_getopts(eff_t effp, int n, char **argv);
-int st_resample_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, st_size_t *isamp, st_size_t *osamp);
-int st_resample_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
-int st_resample_stop(eff_t effp);
-
-#endif
--- a/src/st_sample_test.c
+++ /dev/null
@@ -1,177 +1,0 @@
-#define DEBUG
-#include <assert.h>
-#include "st.h"
-
-#define TEST_UINT(bits) \
-  uint##bits = 0; \
-  sample = ST_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
-  assert(sample == ST_SAMPLE_MIN); \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == 0 && clips == 0); \
- \
-  uint##bits = 1; \
-  sample = ST_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
-  assert(sample > ST_SAMPLE_MIN && sample < 0); \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == 1 && clips == 0); \
- \
-  uint##bits = ST_INT_MAX(bits); \
-  sample = ST_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
-  assert(sample * ST_INT_MAX(bits) == ST_UNSIGNED_TO_SAMPLE(bits,1)); \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == ST_INT_MAX(bits) && clips == 0); \
- \
-  sample =ST_UNSIGNED_TO_SAMPLE(bits,1)+ST_UNSIGNED_TO_SAMPLE(bits,ST_INT_MAX(bits))/2; \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == 1 && clips == 0); \
- \
-  sample = ST_UNSIGNED_TO_SAMPLE(bits,1)+ST_UNSIGNED_TO_SAMPLE(bits,ST_INT_MAX(bits))/2-1; \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == 0 && clips == 0); \
- \
-  uint##bits = (0^ST_INT_MIN(bits)); \
-  sample = ST_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
-  assert(sample == 0); \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == (0^ST_INT_MIN(bits)) && clips == 0); \
- \
-  uint##bits = ((0^ST_INT_MIN(bits))+1); \
-  sample = ST_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
-  assert(sample > 0 && sample < ST_SAMPLE_MAX); \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == ((0^ST_INT_MIN(bits))+1) && clips == 0); \
- \
-  uint##bits = ST_UINT_MAX(bits); \
-  sample = ST_UNSIGNED_TO_SAMPLE(bits,uint##bits); \
-  assert(sample == ST_INT_MAX(bits) * ST_UNSIGNED_TO_SAMPLE(bits,((0^ST_INT_MIN(bits))+1))); \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == ST_UINT_MAX(bits) && clips == 0); \
- \
-  sample =ST_UNSIGNED_TO_SAMPLE(bits,ST_UINT_MAX(bits))+ST_UNSIGNED_TO_SAMPLE(bits,((0^ST_INT_MIN(bits))+1))/2-1; \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == ST_UINT_MAX(bits) && clips == 0); \
- \
-  sample = ST_UNSIGNED_TO_SAMPLE(bits,ST_UINT_MAX(bits))+ST_UNSIGNED_TO_SAMPLE(bits,((0^ST_INT_MIN(bits))+1))/2; \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == ST_UINT_MAX(bits) && --clips == 0); \
- \
-  sample = ST_SAMPLE_MAX; \
-  uint##bits = ST_SAMPLE_TO_UNSIGNED(bits,sample, clips); \
-  assert(uint##bits == ST_UINT_MAX(bits) && --clips == 0); \
-
-#define TEST_SINT(bits) \
-  int##bits = ST_INT_MIN(bits); \
-  sample = ST_SIGNED_TO_SAMPLE(bits,int##bits); \
-  assert(sample == ST_SAMPLE_MIN); \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && clips == 0); \
- \
-  int##bits = ST_INT_MIN(bits)+1; \
-  sample = ST_SIGNED_TO_SAMPLE(bits,int##bits); \
-  assert(sample > ST_SAMPLE_MIN && sample < 0); \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && clips == 0); \
- \
-  int##bits = ST_UINT_MAX(bits) /* i.e. -1 */; \
-  sample = ST_SIGNED_TO_SAMPLE(bits,int##bits); \
-  assert(sample * ST_INT_MAX(bits) == ST_SIGNED_TO_SAMPLE(bits,ST_INT_MIN(bits)+1)); \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && clips == 0); \
- \
-  int##bits = ST_INT_MIN(bits)+1; \
-  sample =ST_UNSIGNED_TO_SAMPLE(bits,1)+ST_UNSIGNED_TO_SAMPLE(bits,ST_INT_MAX(bits))/2; \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && clips == 0); \
- \
-  int##bits = ST_INT_MIN(bits); \
-  sample = ST_UNSIGNED_TO_SAMPLE(bits,1)+ST_UNSIGNED_TO_SAMPLE(bits,ST_INT_MAX(bits))/2-1; \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && clips == 0); \
- \
-  int##bits = 0; \
-  sample = ST_SIGNED_TO_SAMPLE(bits,int##bits); \
-  assert(sample == 0); \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && clips == 0); \
- \
-  int##bits = 1; \
-  sample = ST_SIGNED_TO_SAMPLE(bits,int##bits); \
-  assert(sample > 0 && sample < ST_SAMPLE_MAX); \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && clips == 0); \
- \
-  int##bits = ST_INT_MAX(bits); \
-  sample = ST_SIGNED_TO_SAMPLE(bits,int##bits); \
-  assert(sample == ST_INT_MAX(bits) * ST_SIGNED_TO_SAMPLE(bits,1)); \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && clips == 0); \
- \
-  sample =ST_UNSIGNED_TO_SAMPLE(bits,ST_UINT_MAX(bits))+ST_UNSIGNED_TO_SAMPLE(bits,((0^ST_INT_MIN(bits))+1))/2-1; \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && clips == 0); \
- \
-  sample =ST_UNSIGNED_TO_SAMPLE(bits,ST_UINT_MAX(bits))+ST_UNSIGNED_TO_SAMPLE(bits,((0^ST_INT_MIN(bits))+1))/2; \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && --clips == 0); \
- \
-  sample = ST_SAMPLE_MAX; \
-  int##bits##_2 = ST_SAMPLE_TO_SIGNED(bits,sample, clips); \
-  assert(int##bits##_2 == int##bits && --clips == 0);
-
-int main()
-{
-  int8_t int8;
-  int16_t int16;
-  int24_t int24;
-
-  uint8_t uint8;
-  uint16_t uint16;
-  uint24_t uint24;
-
-  int8_t int8_2;
-  int16_t int16_2;
-  int24_t int24_2;
-
-  st_sample_t sample;
-  st_size_t clips = 0;
-
-  double d;
-
-  TEST_UINT(8)
-  TEST_UINT(16)
-  TEST_UINT(24)
-
-  TEST_SINT(8)
-  TEST_SINT(16)
-  TEST_SINT(24)
-
-  d = -1.0000000001;
-  sample = ST_FLOAT_DDWORD_TO_SAMPLE(d, clips);
-  assert(sample == -ST_SAMPLE_MAX && --clips == 0);
-
-  d = -1;
-  sample = ST_FLOAT_DDWORD_TO_SAMPLE(d, clips);
-  assert(sample == -ST_SAMPLE_MAX && clips == 0);
-  d = ST_SAMPLE_TO_FLOAT_DDWORD(sample,clips);
-  assert(d == -1 && clips == 0);
-
-  --sample;
-  d = ST_SAMPLE_TO_FLOAT_DDWORD(sample,clips);
-  assert(d == -1 && --clips == 0);
-
-  d = 1;
-  sample = ST_FLOAT_DDWORD_TO_SAMPLE(d, clips);
-  assert(sample == ST_SAMPLE_MAX && clips == 0);
-  d = ST_SAMPLE_TO_FLOAT_DDWORD(sample,clips);
-  assert(d == 1 && clips == 0);
-
-  d = 1.0000000001;
-  sample = ST_FLOAT_DDWORD_TO_SAMPLE(d, clips);
-  assert(sample == ST_SAMPLE_MAX && --clips == 0);
-
-  {
-    enum {MEANT_TO_FAIL};
-    assert(MEANT_TO_FAIL);
-  }
-  return 0;
-}
--- a/src/stat.c
+++ b/src/stat.c
@@ -15,7 +15,7 @@
 
 #include <math.h>
 #include <string.h>
-#include "st_i.h"
+#include "sox_i.h"
 #include "FFT.h"
 
 /* Private data for stat effect */
@@ -27,7 +27,7 @@
   double dsum1, dsum2;          /* deltas */
   double scale;                 /* scale-factor */
   double last;                  /* previous sample */
-  st_size_t read;               /* samples processed */
+  sox_size_t read;               /* samples processed */
   int volume;
   int srms;
   int fft;
@@ -42,11 +42,11 @@
 /*
  * Process options
  */
-static int st_stat_getopts(eff_t effp, int n, char **argv)
+static int sox_stat_getopts(eff_t effp, int n, char **argv)
 {
   stat_t stat = (stat_t) effp->priv;
 
-  stat->scale = ST_SAMPLE_MAX;
+  stat->scale = SOX_SAMPLE_MAX;
   stat->volume = 0;
   stat->srms = 0;
   stat->fft = 0;
@@ -56,13 +56,13 @@
       stat->volume = 1;
     else if (!(strcmp(*argv, "-s"))) {
       if (n <= 1) {
-        st_fail("-s option: invalid argument");
-        return ST_EOF;
+        sox_fail("-s option: invalid argument");
+        return SOX_EOF;
       }
       n--, argv++;              /* Move to next argument. */
       if (!sscanf(*argv, "%lf", &stat->scale)) {
-        st_fail("-s option: invalid argument");
-        return ST_EOF;
+        sox_fail("-s option: invalid argument");
+        return SOX_EOF;
       }
     } else if (!(strcmp(*argv, "-rms")))
       stat->srms = 1;
@@ -71,18 +71,18 @@
     else if (!(strcmp(*argv, "-d")))
       stat->volume = 2;
     else {
-      st_fail("Summary effect: unknown option");
-      return ST_EOF;
+      sox_fail("Summary effect: unknown option");
+      return SOX_EOF;
     }
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
  * Prepare processing.
  */
-static int st_stat_start(eff_t effp)
+static int sox_stat_start(eff_t effp)
 {
   stat_t stat = (stat_t) effp->priv;
   int i;
@@ -109,7 +109,7 @@
     stat->re_out = (float *)xmalloc(sizeof(float) * (stat->fft_size / 2));
   }
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
@@ -129,8 +129,8 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_stat_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
-                        st_size_t *isamp, st_size_t *osamp)
+static int sox_stat_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf,
+                        sox_size_t *isamp, sox_size_t *osamp)
 {
   stat_t stat = (stat_t) effp->priv;
   int done, x, len = min(*isamp, *osamp);
@@ -137,7 +137,7 @@
   short count = 0;
 
   if (len == 0)
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 
   if (stat->read == 0)          /* 1st sample */
     stat->min = stat->max = stat->mid = stat->last = (*ibuf)/stat->scale;
@@ -144,7 +144,7 @@
 
   if (stat->fft) {
     for (x = 0; x < len; x++) {
-      stat->re_in[stat->fft_offset++] = ST_SAMPLE_TO_FLOAT_DWORD(ibuf[x], effp->clips);
+      stat->re_in[stat->fft_offset++] = SOX_SAMPLE_TO_FLOAT_DWORD(ibuf[x], effp->clips);
 
       if (stat->fft_offset >= stat->fft_size) {
         stat->fft_offset = 0;
@@ -195,13 +195,13 @@
   *isamp = *osamp = len;
   /* Process all samples */
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
  * Process tail of input samples.
  */
-static int st_stat_drain(eff_t effp, st_sample_t *obuf UNUSED, st_size_t *osamp)
+static int sox_stat_drain(eff_t effp, sox_sample_t *obuf UNUSED, sox_size_t *osamp)
 {
   stat_t stat = (stat_t) effp->priv;
 
@@ -219,7 +219,7 @@
   }
 
   *osamp = 0;
-  return ST_EOF;
+  return SOX_EOF;
 }
 
 /*
@@ -226,7 +226,7 @@
  * Do anything required when you stop reading samples.
  * Don't close input file!
  */
-static int st_stat_stop(eff_t effp)
+static int sox_stat_stop(eff_t effp)
 {
   stat_t stat = (stat_t) effp->priv;
   double amp, scale, rms = 0, freq;
@@ -259,8 +259,8 @@
 
   /* Just print the volume adjustment */
   if (stat->volume == 1 && amp > 0) {
-    fprintf(stderr, "%.3f\n", ST_SAMPLE_MAX/(amp*scale));
-    return ST_SUCCESS;
+    fprintf(stderr, "%.3f\n", SOX_SAMPLE_MAX/(amp*scale));
+    return SOX_SUCCESS;
   }
   if (stat->volume == 2)
     fprintf(stderr, "\n\n");
@@ -286,7 +286,7 @@
   fprintf(stderr, "Rough   frequency: %12d\n", (int)freq);
 
   if (amp>0)
-    fprintf(stderr, "Volume adjustment: %12.3f\n", ST_SAMPLE_MAX/(amp*scale));
+    fprintf(stderr, "Volume adjustment: %12.3f\n", SOX_SAMPLE_MAX/(amp*scale));
 
   if (stat->bin[2] == 0 && stat->bin[3] == 0)
     fprintf(stderr, "\nProbably text, not sound\n");
@@ -295,7 +295,7 @@
     x = (float)(stat->bin[0] + stat->bin[3]) / (float)(stat->bin[1] + stat->bin[2]);
 
     if (x >= 3.0) {             /* use opposite encoding */
-      if (effp->ininfo.encoding == ST_ENCODING_UNSIGNED)
+      if (effp->ininfo.encoding == SOX_ENCODING_UNSIGNED)
         fprintf(stderr,"\nTry: -t raw -b -s \n");
       else
         fprintf(stderr,"\nTry: -t raw -b -u \n");
@@ -302,7 +302,7 @@
     } else if (x <= 1.0 / 3.0)
       ;                         /* correctly decoded */
     else if (x >= 0.5 && x <= 2.0) { /* use ULAW */
-      if (effp->ininfo.encoding == ST_ENCODING_ULAW)
+      if (effp->ininfo.encoding == SOX_ENCODING_ULAW)
         fprintf(stderr,"\nTry: -t raw -b -u \n");
       else
         fprintf(stderr,"\nTry: -t raw -b -U \n");
@@ -314,23 +314,23 @@
   free(stat->re_in);
   free(stat->re_out);
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 
 }
 
-static st_effect_t st_stat_effect = {
+static sox_effect_t sox_stat_effect = {
   "stat",
   "Usage: [ -s N ] [ -rms ] [-freq] [ -v ] [ -d ]",
-  ST_EFF_MCHAN | ST_EFF_REPORT,
-  st_stat_getopts,
-  st_stat_start,
-  st_stat_flow,
-  st_stat_drain,
-  st_stat_stop,
-  st_effect_nothing
+  SOX_EFF_MCHAN | SOX_EFF_REPORT,
+  sox_stat_getopts,
+  sox_stat_start,
+  sox_stat_flow,
+  sox_stat_drain,
+  sox_stat_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_stat_effect_fn(void)
+const sox_effect_t *sox_stat_effect_fn(void)
 {
-  return &st_stat_effect;
+  return &sox_stat_effect;
 }
--- a/src/stio.c
+++ /dev/null
@@ -1,347 +1,0 @@
-#include "st_i.h"
-
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <sys/types.h> /* for fstat() */
-#include <sys/stat.h> /* for fstat() */
-
-#ifdef _MSC_VER
-/* __STDC__ is defined, so these symbols aren't created. */
-#define S_IFMT   _S_IFMT
-#define S_IFREG  _S_IFREG
-#define fstat _fstat
-#endif
-
-/* Based on zlib's minigzip: */
-#if defined(WIN32) || defined(__NT__)
-#include <fcntl.h>
-#include <io.h>
-#ifndef O_BINARY
-#define O_BINARY _O_BINARY
-#endif
-#define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
-#else
-#define SET_BINARY_MODE(file)
-#endif
-
-void set_endianness_if_not_already_set(ft_t ft)
-{
-  if (ft->signal.reverse_bytes == ST_OPTION_DEFAULT) {
-    if (ft->h->flags & ST_FILE_ENDIAN)
-      ft->signal.reverse_bytes = ST_IS_LITTLEENDIAN != !(ft->h->flags & ST_FILE_ENDBIG);
-    else
-      ft->signal.reverse_bytes = ST_OPTION_NO;
-  }
-  if (ft->signal.reverse_nibbles == ST_OPTION_DEFAULT)
-    ft->signal.reverse_nibbles = ST_OPTION_NO;
-  if (ft->signal.reverse_bits == ST_OPTION_DEFAULT)
-    ft->signal.reverse_bits = ST_OPTION_NO;
-}
-
-static int is_seekable(ft_t ft)
-{
-        struct stat st;
-
-        fstat(fileno(ft->fp), &st);
-
-        return ((st.st_mode & S_IFMT) == S_IFREG);
-}
-
-/* check that all settings have been given */
-static int st_checkformat(ft_t ft)
-{
-
-        ft->st_errno = ST_SUCCESS;
-
-        if (ft->signal.rate == 0)
-        {
-                st_fail_errno(ft,ST_EFMT,"sampling rate was not specified");
-                return ST_EOF;
-        }
-
-        if (ft->signal.size == -1)
-        {
-                st_fail_errno(ft,ST_EFMT,"data size was not specified");
-                return ST_EOF;
-        }
-
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
-        {
-                st_fail_errno(ft,ST_EFMT,"data encoding was not specified");
-                return ST_EOF;
-        }
-
-        if ((ft->signal.size <= 0) || (ft->signal.size > ST_INFO_SIZE_MAX))
-        {
-                st_fail_errno(ft,ST_EFMT,"data size %d is invalid", ft->signal.size);
-                return ST_EOF;
-        }
-
-        if (ft->signal.encoding <= 0  || ft->signal.encoding >= ST_ENCODINGS)
-        {
-                st_fail_errno(ft,ST_EFMT,"data encoding %d is invalid", ft->signal.encoding);
-                return ST_EOF;
-        }
-
-        return ST_SUCCESS;
-}
-
-ft_t st_open_read(const char *path, const st_signalinfo_t *info,
-                  const char *filetype)
-{
-    ft_t ft = (ft_t)xcalloc(sizeof(struct st_soundstream), 1);
-
-    ft->filename = xstrdup(path);
-
-    /* Let auto type do the work if user is not overriding. */
-    if (!filetype)
-        ft->filetype = xstrdup("auto");
-    else
-        ft->filetype = xstrdup(filetype);
-
-    if (st_gettype(ft, st_false) != ST_SUCCESS) {
-        st_warn("Unknown input file format for `%s':  %s",
-                ft->filename,
-                ft->st_errstr);
-        goto input_error;
-    }
-
-    ft->signal.size = -1;
-    ft->signal.encoding = ST_ENCODING_UNKNOWN;
-    ft->signal.channels = 0;
-    if (info)
-        ft->signal = *info;
-    ft->mode = 'r';
-
-    if (!(ft->h->flags & ST_FILE_NOSTDIO))
-    {
-        /* Open file handler based on input name.  Used stdin file handler
-         * if the filename is "-"
-         */
-        if (!strcmp(ft->filename, "-"))
-        {
-            SET_BINARY_MODE(stdin);
-            ft->fp = stdin;
-        }
-        else if ((ft->fp = fopen(ft->filename, "rb")) == NULL)
-        {
-            st_warn("Can't open input file `%s': %s", ft->filename,
-                    strerror(errno));
-            goto input_error;
-        }
-
-        /* See if this file is seekable or not */
-        ft->seekable = is_seekable(ft);
-    }
-
-    if (filetype)
-      set_endianness_if_not_already_set(ft);
-
-    /* Read and write starters can change their formats. */
-    if ((*ft->h->startread)(ft) != ST_SUCCESS)
-    {
-        st_warn("Failed reading `%s': %s", ft->filename, ft->st_errstr);
-        goto input_error;
-    }
-
-    /* Go a head and assume 1 channel audio if nothing is detected.
-     * This is because libst usually doesn't set this for mono file
-     * formats (for historical reasons).
-     */
-    if (ft->signal.channels == 0)
-        ft->signal.channels = 1;
-
-    if (st_checkformat(ft) )
-    {
-        st_warn("bad input format for file %s: %s", ft->filename,
-                ft->st_errstr);
-        goto input_error;
-    }
-    return ft;
-
-input_error:
-
-    free(ft->filename);
-    free(ft->filetype);
-    free(ft);
-    return NULL;
-}
-
-#if defined(DOS) || defined(WIN32)
-#define LASTCHAR '\\'
-#else
-#define LASTCHAR '/'
-#endif
-
-ft_t st_open_write(
-    st_bool (*overwrite_permitted)(const char *filename),
-    const char *path,
-    const st_signalinfo_t *info,
-    const char *filetype,
-    const char *comment,
-    const st_instrinfo_t *instr,
-    const st_loopinfo_t *loops)
-{
-    ft_t ft = (ft_t)xcalloc(sizeof(struct st_soundstream), 1);
-    int i;
-    st_bool no_filetype_given = filetype == NULL;
-
-    ft->filename = xstrdup(path);
-
-    /* Let auto effect do the work if user is not overriding. */
-    if (!filetype) {
-        char *chop;
-        int len;
-
-        len = strlen(ft->filename);
-
-        /* Use filename extension to determine audio type.
-         * Search for the last '.' appearing in the filename, same
-         * as for input files.
-         */
-        chop = ft->filename + len;
-        while (chop > ft->filename && *chop != LASTCHAR && *chop != '.')
-            chop--;
-
-        if (*chop == '.') {
-            chop++;
-            ft->filetype = xstrdup(chop);
-        }
-    } else
-        ft->filetype = xstrdup(filetype);
-
-    if (!ft->filetype || st_gettype(ft, no_filetype_given) != ST_SUCCESS)
-    {
-        st_fail("Unknown output file format for '%s':  %s",
-                ft->filename,
-                ft->st_errstr);
-        goto output_error;
-    }
-
-    ft->signal.size = -1;
-    ft->signal.encoding = ST_ENCODING_UNKNOWN;
-    ft->signal.channels = 0;
-    if (info)
-        ft->signal = *info;
-    ft->mode = 'w';
-
-    if (!(ft->h->flags & ST_FILE_NOSTDIO))
-    {
-        /* Open file handler based on output name.  Used stdout file handler
-         * if the filename is "-"
-         */
-        if (!strcmp(ft->filename, "-"))
-        {
-            SET_BINARY_MODE(stdout);
-            ft->fp = stdout;
-        }
-        else {
-          struct stat st;
-          if (!stat(ft->filename, &st) && (st.st_mode & S_IFMT) == S_IFREG &&
-              !overwrite_permitted(ft->filename)) {
-            st_fail("Permission to overwrite '%s' denied", ft->filename);
-            goto output_error;
-          }
-          if ((ft->fp = fopen(ft->filename, "wb")) == NULL) {
-            st_fail("Can't open output file '%s': %s", ft->filename,
-                    strerror(errno));
-            goto output_error;
-          }
-        }
-
-        /* stdout tends to be line-buffered.  Override this */
-        /* to be Full Buffering. */
-        if (setvbuf (ft->fp, NULL, _IOFBF, sizeof(char)*ST_BUFSIZ))
-        {
-            st_fail("Can't set write buffer");
-            goto output_error;
-        }
-
-        /* See if this file is seekable or not */
-        ft->seekable = is_seekable(ft);
-    }
-
-    ft->comment = xstrdup(comment);
-
-    if (loops)
-        for (i = 0; i < ST_MAX_NLOOPS; i++)
-            ft->loops[i] = loops[i];
-
-    /* leave SMPTE # alone since it's absolute */
-    if (instr)
-        ft->instr = *instr;
-
-    set_endianness_if_not_already_set(ft);
-
-    /* Read and write starters can change their formats. */
-    if ((*ft->h->startwrite)(ft) != ST_SUCCESS)
-    {
-        st_fail("Failed writing %s: %s", ft->filename, ft->st_errstr);
-        goto output_error;
-    }
-
-    if (st_checkformat(ft) )
-    {
-        st_fail("bad output format for file %s: %s", ft->filename,
-                ft->st_errstr);
-        goto output_error;
-    }
-
-    return ft;
-
-output_error:
-
-    free(ft->filename);
-    free(ft->filetype);
-    free(ft);
-    return NULL;
-}
-
-st_size_t st_read(ft_t f, st_sample_t * buf, st_size_t len)
-{
-  st_size_t actual = (*f->h->read)(f, buf, len);
-  return (actual > len? 0 : actual);
-}
-
-st_size_t st_write(ft_t ft, const st_sample_t *buf, st_size_t len)
-{
-    return (*ft->h->write)(ft, buf, len);
-}
-
-/* N.B. The file (if any) may already have been deleted. */
-int st_close(ft_t ft)
-{
-    int rc;
-
-    if (ft->mode == 'r')
-        rc = (*ft->h->stopread)(ft);
-    else
-        rc = (*ft->h->stopwrite)(ft);
-
-    if (!(ft->h->flags & ST_FILE_NOSTDIO))
-        fclose(ft->fp);
-    free(ft->filename);
-    free(ft->filetype);
-    /* Currently, since startread() mallocs comments, stopread
-     * is expected to also free it. */
-    if (ft->mode == 'w')
-        free(ft->comment);
-
-    return rc;
-}
-
-int st_seek(ft_t ft, st_size_t offset, int whence)       
-{       
-    /* FIXME: Implement ST_SEEK_CUR and ST_SEEK_END. */         
-    if (whence != ST_SEEK_SET)          
-        return ST_EOF; /* FIXME: return ST_EINVAL */    
-
-    /* If file is a seekable file and this handler supports seeking,    
-     * the invoke handlers function.    
-     */         
-    if (ft->seekable  && (ft->h->flags & ST_FILE_SEEK))         
-        return (*ft->h->seek)(ft, offset);      
-    else        
-        return ST_EOF; /* FIXME: return ST_EBADF */     
-}
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -19,13 +19,13 @@
  * It cannot handle different number of channels.
  * It cannot handle rate change.
  */
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
-static st_effect_t st_stretch_effect;
+static sox_effect_t sox_stretch_effect;
 
 #define DEFAULT_SLOW_SHIFT_RATIO        0.8
 #define DEFAULT_FAST_SHIFT_RATIO        1.0
@@ -35,9 +35,9 @@
 /* I'm planing to put some common fading stuff outside. 
    It's also used in pitch.c
  */
-typedef enum { st_linear_fading } st_fading_t;
+typedef enum { sox_linear_fading } sox_fading_t;
 
-#define DEFAULT_FADING st_linear_fading
+#define DEFAULT_FADING sox_linear_fading
 
 typedef enum { input_state, output_state } stretch_status_t;
 
@@ -48,7 +48,7 @@
    */
   double factor;   /* strech factor. 1.0 means copy. */
   double window;   /* window in ms */
-  st_fading_t fade;       /* type of fading */
+  sox_fading_t fade;       /* type of fading */
   double shift;    /* shift ratio wrt window. <1.0 */
   double fading;   /* fading ratio wrt window. <0.5 */
 
@@ -55,16 +55,16 @@
   /* internal stuff */
   stretch_status_t state; /* automaton status */
 
-  st_size_t size;         /* buffer size */
-  st_size_t index;        /* next available element */
-  st_sample_t *ibuf;      /* input buffer */
-  st_size_t ishift;       /* input shift */
+  sox_size_t size;         /* buffer size */
+  sox_size_t index;        /* next available element */
+  sox_sample_t *ibuf;      /* input buffer */
+  sox_size_t ishift;       /* input shift */
   
-  st_size_t oindex;       /* next evailable element */
+  sox_size_t oindex;       /* next evailable element */
   double * obuf;   /* output buffer */
-  st_size_t oshift;       /* output shift */
+  sox_size_t oshift;       /* output shift */
   
-  st_size_t fsize;        /* fading size */
+  sox_size_t fsize;        /* fading size */
   double * fbuf;   /* fading, 1.0 -> 0.0 */
   
 } *stretch_t;
@@ -72,7 +72,7 @@
 /*
  * Process options
  */
-static int st_stretch_getopts(eff_t effp, int n, char **argv) 
+static int sox_stretch_getopts(eff_t effp, int n, char **argv) 
 {
   char usage[1024];
   stretch_t stretch = (stretch_t) effp->priv; 
@@ -80,18 +80,18 @@
   /* default options */
   stretch->factor = 1.0; /* default is no change */
   stretch->window = DEFAULT_STRETCH_WINDOW;
-  stretch->fade = st_linear_fading;
+  stretch->fade = sox_linear_fading;
 
   if (n > 0 && !sscanf(argv[0], "%lf", &stretch->factor)) {
-    sprintf(usage, "%s\n\terror while parsing factor", st_stretch_effect.usage);
-    st_fail(usage);
-    return ST_EOF;
+    sprintf(usage, "%s\n\terror while parsing factor", sox_stretch_effect.usage);
+    sox_fail(usage);
+    return SOX_EOF;
   }
 
   if (n > 1 && !sscanf(argv[1], "%lf", &stretch->window)) {
-    sprintf(usage, "%s\n\terror while parsing window size", st_stretch_effect.usage);
-    st_fail(usage);
-    return ST_EOF;
+    sprintf(usage, "%s\n\terror while parsing window size", sox_stretch_effect.usage);
+    sox_fail(usage);
+    return SOX_EOF;
   }
 
   if (n > 2) {
@@ -98,12 +98,12 @@
     switch (argv[2][0]) {
     case 'l':
     case 'L':
-      stretch->fade = st_linear_fading;
+      stretch->fade = sox_linear_fading;
       break;
     default:
-      sprintf (usage, "%s\n\terror while parsing fade type", st_stretch_effect.usage);
-      st_fail(usage);
-      return ST_EOF;
+      sprintf (usage, "%s\n\terror while parsing fade type", sox_stretch_effect.usage);
+      sox_fail(usage);
+      return SOX_EOF;
     }
   }
 
@@ -112,15 +112,15 @@
     DEFAULT_FAST_SHIFT_RATIO: DEFAULT_SLOW_SHIFT_RATIO;
  
   if (n > 3 && !sscanf(argv[3], "%lf", &stretch->shift)) {
-    sprintf (usage, "%s\n\terror while parsing shift ratio", st_stretch_effect.usage);
-    st_fail(usage);
-    return ST_EOF;
+    sprintf (usage, "%s\n\terror while parsing shift ratio", sox_stretch_effect.usage);
+    sox_fail(usage);
+    return SOX_EOF;
   }
 
   if (stretch->shift > 1.0 || stretch->shift <= 0.0) {
-    sprintf(usage, "%s\n\terror with shift ratio value", st_stretch_effect.usage);
-    st_fail(usage);
-    return ST_EOF;
+    sprintf(usage, "%s\n\terror with shift ratio value", sox_stretch_effect.usage);
+    sox_fail(usage);
+    return SOX_EOF;
   }
 
   /* default fading stuff... 
@@ -133,42 +133,42 @@
     stretch->fading = 0.5;
   
   if (n > 4 && !sscanf(argv[4], "%lf", &stretch->fading)) {
-    sprintf(usage, "%s\n\terror while parsing fading ratio", st_stretch_effect.usage);
-    st_fail(usage);
-    return ST_EOF;
+    sprintf(usage, "%s\n\terror while parsing fading ratio", sox_stretch_effect.usage);
+    sox_fail(usage);
+    return SOX_EOF;
   }
 
   if (stretch->fading > 0.5 || stretch->fading < 0.0) {
-    sprintf(usage, "%s\n\terror with fading ratio value", st_stretch_effect.usage);
-    st_fail(usage);
-    return ST_EOF;
+    sprintf(usage, "%s\n\terror with fading ratio value", sox_stretch_effect.usage);
+    sox_fail(usage);
+    return SOX_EOF;
   }
   
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /*
  * Start processing
  */
-static int st_stretch_start(eff_t effp)
+static int sox_stretch_start(eff_t effp)
 {
   stretch_t stretch = (stretch_t)effp->priv;
-  st_size_t i;
+  sox_size_t i;
 
   if (stretch->factor == 1)
-    return ST_EFF_NULL;
+    return SOX_EFF_NULL;
 
   /* FIXME: not necessary. taken care by effect processing? */
   if (effp->outinfo.channels != effp->ininfo.channels) {
-    st_fail("stretch cannot handle different channels (in=%d, out=%d)"
+    sox_fail("stretch cannot handle different channels (in=%d, out=%d)"
             " use avg or pan", effp->ininfo.channels, effp->outinfo.channels);
-    return ST_EOF;
+    return SOX_EOF;
   }
 
   if (effp->outinfo.rate != effp->ininfo.rate) {
-    st_fail("stretch cannot handle different rates (in=%ld, out=%ld)"
+    sox_fail("stretch cannot handle different rates (in=%ld, out=%ld)"
             " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
-    return ST_EOF;
+    return SOX_EOF;
   }
 
   stretch->state = input_state;
@@ -176,7 +176,7 @@
   stretch->size = (int)(effp->outinfo.rate * 0.001 * stretch->window);
   /* start in the middle of an input to avoid initial fading... */
   stretch->index = stretch->size / 2;
-  stretch->ibuf = (st_sample_t *)xmalloc(stretch->size * sizeof(st_sample_t));
+  stretch->ibuf = (sox_sample_t *)xmalloc(stretch->size * sizeof(sox_sample_t));
 
   /* the shift ratio deal with the longest of ishift/oshift
      hence ishift<=size and oshift<=size. */
@@ -211,13 +211,13 @@
   } else if (stretch->fsize == 1)
     stretch->fbuf[0] = 1.0;
 
-  st_debug("start: (f=%.2f w=%.2f r=%.2f f=%.2f)"
+  sox_debug("start: (f=%.2f w=%.2f r=%.2f f=%.2f)"
            " st=%d s=%d ii=%d is=%d oi=%d os=%d fs=%d\n",
            stretch->factor, stretch->window, stretch->shift, stretch->fading,
            stretch->state, stretch->size, stretch->index, stretch->ishift,
            stretch->oindex, stretch->oshift, stretch->fsize);
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 /* accumulates input ibuf to output obuf with fading fbuf */
@@ -244,19 +244,19 @@
 /*
  * Processes flow.
  */
-static int st_stretch_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                    st_size_t *isamp, st_size_t *osamp)
+static int sox_stretch_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                    sox_size_t *isamp, sox_size_t *osamp)
 {
   stretch_t stretch = (stretch_t) effp->priv;
-  st_size_t iindex = 0, oindex = 0;
-  st_size_t i;
+  sox_size_t iindex = 0, oindex = 0;
+  sox_size_t i;
 
   while (iindex<*isamp && oindex<*osamp) {
     if (stretch->state == input_state) {
-      st_size_t tocopy = min(*isamp-iindex, 
+      sox_size_t tocopy = min(*isamp-iindex, 
                              stretch->size-stretch->index);
 
-      memcpy(stretch->ibuf + stretch->index, ibuf + iindex, tocopy * sizeof(st_sample_t));
+      memcpy(stretch->ibuf + stretch->index, ibuf + iindex, tocopy * sizeof(sox_sample_t));
       
       iindex += tocopy;
       stretch->index += tocopy;
@@ -280,7 +280,7 @@
       while (stretch->oindex < stretch->oshift && oindex < *osamp) {
         float f;
         f = stretch->obuf[stretch->oindex++];
-        ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+        SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
         obuf[oindex++] = f;
       }
 
@@ -303,7 +303,7 @@
   *isamp = iindex;
   *osamp = oindex;
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
 
@@ -311,11 +311,11 @@
  * Drain buffer at the end
  * maybe not correct ? end might be artificially faded?
  */
-static int st_stretch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int sox_stretch_drain(eff_t effp, sox_sample_t *obuf, sox_size_t *osamp)
 {
   stretch_t stretch = (stretch_t) effp->priv;
-  st_size_t i;
-  st_size_t oindex = 0;
+  sox_size_t i;
+  sox_size_t oindex = 0;
   
   if (stretch->state == input_state) {
     for (i=stretch->index; i<stretch->size; i++)
@@ -328,7 +328,7 @@
   
   while (oindex<*osamp && stretch->oindex<stretch->index) {
     float f = stretch->obuf[stretch->oindex++];
-    ST_SAMPLE_CLIP_COUNT(f, effp->clips);
+    SOX_SAMPLE_CLIP_COUNT(f, effp->clips);
     obuf[oindex++] = f;
   }
     
@@ -335,9 +335,9 @@
   *osamp = oindex;
 
   if (stretch->oindex == stretch->index)
-    return ST_EOF;
+    return SOX_EOF;
   else
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 
@@ -345,7 +345,7 @@
  * Do anything required when you stop reading samples.  
  * Don't close input file! 
  */
-static int st_stretch_stop(eff_t effp)
+static int sox_stretch_stop(eff_t effp)
 {
   stretch_t stretch = (stretch_t) effp->priv;
 
@@ -353,24 +353,24 @@
   free(stretch->obuf);
   free(stretch->fbuf);
 
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-static st_effect_t st_stretch_effect = {
+static sox_effect_t sox_stretch_effect = {
   "stretch",
   "Usage: stretch factor [window fade shift fading]\n"
   "       (expansion, frame in ms, lin/..., unit<1.0, unit<0.5)\n"
   "       (defaults: 1.0 20 lin ...)",
   0,
-  st_stretch_getopts,
-  st_stretch_start,
-  st_stretch_flow,
-  st_stretch_drain,
-  st_stretch_stop,
-  st_effect_nothing
+  sox_stretch_getopts,
+  sox_stretch_start,
+  sox_stretch_flow,
+  sox_stretch_drain,
+  sox_stretch_stop,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_stretch_effect_fn(void)
+const sox_effect_t *sox_stretch_effect_fn(void)
 {
-  return &st_stretch_effect;
+  return &sox_stretch_effect;
 }
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -15,7 +15,7 @@
  * responsible for the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #ifdef HAVE_SUN_AUDIO
 
@@ -44,10 +44,10 @@
  *      size and encoding of samples,
  *      mono/stereo/quad.
  */
-static int st_sunstartread(ft_t ft)
+static int sox_sunstartread(ft_t ft)
 {
-    st_fileinfo_t *file = (st_fileinfo_t *)ft->priv;
-    st_size_t samplesize, encoding;
+    sox_fileinfo_t *file = (sox_fileinfo_t *)ft->priv;
+    sox_size_t samplesize, encoding;
     audio_info_t audio_if;
 #ifdef __SVR4
     audio_device_t audio_dev;
@@ -62,16 +62,16 @@
     file->buf = xmalloc (file->size);
 
     if (ft->signal.rate == 0.0) ft->signal.rate = 8000;
-    if (ft->signal.size == -1) ft->signal.size = ST_SIZE_BYTE;
-    if (ft->signal.encoding == ST_ENCODING_UNKNOWN) ft->signal.encoding = ST_ENCODING_ULAW;
+    if (ft->signal.size == -1) ft->signal.size = SOX_SIZE_BYTE;
+    if (ft->signal.encoding == SOX_ENCODING_UNKNOWN) ft->signal.encoding = SOX_ENCODING_ULAW;
 
 #ifdef __SVR4
     /* Read in old values, change to what we need and then send back */
     if (ioctl(fileno(ft->fp), AUDIO_GETDEV, &audio_dev) < 0) {
-        st_fail_errno(ft,errno,"Unable to get device information.");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to get device information.");
+        return(SOX_EOF);
     }
-    st_report("Hardware detected:  %s",audio_dev.name);
+    sox_report("Hardware detected:  %s",audio_dev.name);
     if (strcmp("SUNW,am79c30",audio_dev.name) == 0)
     {
         simple_hw = 1;
@@ -81,72 +81,72 @@
     /* If simple hardware detected in force data to ulaw. */
     if (simple_hw)
     {
-        if (ft->signal.size == ST_SIZE_BYTE)
+        if (ft->signal.size == SOX_SIZE_BYTE)
         {
-            if (ft->signal.encoding != ST_ENCODING_ULAW &&
-                ft->signal.encoding != ST_ENCODING_ALAW)
+            if (ft->signal.encoding != SOX_ENCODING_ULAW &&
+                ft->signal.encoding != SOX_ENCODING_ALAW)
             {
-                st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
-                ft->signal.encoding = ST_ENCODING_ULAW;
+                sox_report("Warning: Detected simple hardware.  Forcing output to ULAW");
+                ft->signal.encoding = SOX_ENCODING_ULAW;
             }
         }
-        else if (ft->signal.size == ST_SIZE_16BIT)
+        else if (ft->signal.size == SOX_SIZE_16BIT)
         {
-            st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
-            ft->signal.size = ST_SIZE_BYTE;
-            ft->signal.encoding = ST_ENCODING_ULAW;
+            sox_report("Warning: Detected simple hardware.  Forcing output to ULAW");
+            ft->signal.size = SOX_SIZE_BYTE;
+            ft->signal.encoding = SOX_ENCODING_ULAW;
         }
     }
 
-    if (ft->signal.size == ST_SIZE_BYTE) {
+    if (ft->signal.size == SOX_SIZE_BYTE) {
         samplesize = 8;
-        if (ft->signal.encoding != ST_ENCODING_ULAW &&
-            ft->signal.encoding != ST_ENCODING_ALAW &&
-            ft->signal.encoding != ST_ENCODING_SIGN2) {
-            st_fail_errno(ft,ST_EFMT,"Sun audio driver only supports ULAW, ALAW, and signed linear for bytes.");
-                return (ST_EOF);
+        if (ft->signal.encoding != SOX_ENCODING_ULAW &&
+            ft->signal.encoding != SOX_ENCODING_ALAW &&
+            ft->signal.encoding != SOX_ENCODING_SIGN2) {
+            sox_fail_errno(ft,SOX_EFMT,"Sun audio driver only supports ULAW, ALAW, and signed linear for bytes.");
+                return (SOX_EOF);
         }
-        if ((ft->signal.encoding == ST_ENCODING_ULAW ||
-             ft->signal.encoding == ST_ENCODING_ALAW) && 
+        if ((ft->signal.encoding == SOX_ENCODING_ULAW ||
+             ft->signal.encoding == SOX_ENCODING_ALAW) && 
             ft->signal.channels == 2)
         {
-            st_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono.");
+            sox_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono.");
             ft->signal.channels = 1;
         }
     }
-    else if (ft->signal.size == ST_SIZE_16BIT) {
+    else if (ft->signal.size == SOX_SIZE_16BIT) {
         samplesize = 16;
-        if (ft->signal.encoding != ST_ENCODING_SIGN2) {
-            st_fail_errno(ft,ST_EFMT,"Sun audio driver only supports signed linear for words.");
-            return(ST_EOF);
+        if (ft->signal.encoding != SOX_ENCODING_SIGN2) {
+            sox_fail_errno(ft,SOX_EFMT,"Sun audio driver only supports signed linear for words.");
+            return(SOX_EOF);
         }
     }
     else {
-        st_fail_errno(ft,ST_EFMT,"Sun audio driver only supports bytes and words");
-        return(ST_EOF);
+        sox_fail_errno(ft,SOX_EFMT,"Sun audio driver only supports bytes and words");
+        return(SOX_EOF);
     }
 
     if (ft->signal.channels == 0) ft->signal.channels = 1;
     else if (ft->signal.channels > 1) {
-        st_report("Warning: some Sun audio devices can not play stereo");
-        st_report("at all or sometimes only with signed words.  If the");
-        st_report("sound seems sluggish then this is probably the case.");
-        st_report("Try forcing output to signed words or use the avg");
-        st_report("filter to reduce the number of channels.");
+        sox_report("Warning: some Sun audio devices can not play stereo");
+        sox_report("at all or sometimes only with signed words.  If the");
+        sox_report("sound seems sluggish then this is probably the case.");
+        sox_report("Try forcing output to signed words or use the avg");
+        sox_report("filter to reduce the number of channels.");
         ft->signal.channels = 2;
     }
 
     /* Read in old values, change to what we need and then send back */
     if (ioctl(fileno(ft->fp), AUDIO_GETINFO, &audio_if) < 0) {
-        st_fail_errno(ft,errno,"Unable to initialize /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize /dev/audio");
+        return(SOX_EOF);
     }
     audio_if.record.precision = samplesize;
     audio_if.record.channels = ft->signal.channels;
     audio_if.record.sample_rate = ft->signal.rate;
-    if (ft->signal.encoding == ST_ENCODING_ULAW)
+    if (ft->signal.encoding == SOX_ENCODING_ULAW)
         encoding = AUDIO_ENCODING_ULAW;
-    else if (ft->signal.encoding == ST_ENCODING_ALAW)
+    else if (ft->signal.encoding == SOX_ENCODING_ALAW)
         encoding = AUDIO_ENCODING_ALAW;
     else
         encoding = AUDIO_ENCODING_LINEAR;
@@ -154,20 +154,20 @@
 
     ioctl(fileno(ft->fp), AUDIO_SETINFO, &audio_if);
     if (audio_if.record.precision != samplesize) {
-        st_fail_errno(ft,errno,"Unable to initialize sample size for /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize sample size for /dev/audio");
+        return(SOX_EOF);
     }
     if (audio_if.record.channels != ft->signal.channels) {
-        st_fail_errno(ft,errno,"Unable to initialize number of channels for /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize number of channels for /dev/audio");
+        return(SOX_EOF);
     }
     if (audio_if.record.sample_rate != ft->signal.rate) {
-        st_fail_errno(ft,errno,"Unable to initialize rate for /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize rate for /dev/audio");
+        return(SOX_EOF);
     }
     if (audio_if.record.encoding != encoding) {
-        st_fail_errno(ft,errno,"Unable to initialize encoding for /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize encoding for /dev/audio");
+        return(SOX_EOF);
     }
     /* Flush any data in the buffers - its probably in the wrong format */
 #if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -178,13 +178,13 @@
     /* Change to non-buffered I/O*/
     setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * file->size);
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-static int st_sunstartwrite(ft_t ft)
+static int sox_sunstartwrite(ft_t ft)
 {
-    st_fileinfo_t *file = (st_fileinfo_t *)ft->priv;
-    st_size_t samplesize, encoding;
+    sox_fileinfo_t *file = (sox_fileinfo_t *)ft->priv;
+    sox_size_t samplesize, encoding;
     audio_info_t audio_if;
 #ifdef __SVR4
     audio_device_t audio_dev;
@@ -201,10 +201,10 @@
 #ifdef __SVR4
     /* Read in old values, change to what we need and then send back */
     if (ioctl(fileno(ft->fp), AUDIO_GETDEV, &audio_dev) < 0) {
-        st_fail_errno(ft,errno,"Unable to get device information.");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to get device information.");
+        return(SOX_EOF);
     }
-    st_report("Hardware detected:  %s",audio_dev.name);
+    sox_report("Hardware detected:  %s",audio_dev.name);
     if (strcmp("SUNW,am79c30",audio_dev.name) == 0)
     {
         simple_hw = 1;
@@ -213,58 +213,58 @@
 
     if (simple_hw)
     {
-        if (ft->signal.size == ST_SIZE_BYTE)
+        if (ft->signal.size == SOX_SIZE_BYTE)
         {
-            if (ft->signal.encoding != ST_ENCODING_ULAW &&
-                ft->signal.encoding != ST_ENCODING_ALAW)
+            if (ft->signal.encoding != SOX_ENCODING_ULAW &&
+                ft->signal.encoding != SOX_ENCODING_ALAW)
             {
-                st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
-                ft->signal.encoding = ST_ENCODING_ULAW;
+                sox_report("Warning: Detected simple hardware.  Forcing output to ULAW");
+                ft->signal.encoding = SOX_ENCODING_ULAW;
             }
         }
-        else if (ft->signal.size == ST_SIZE_16BIT)
+        else if (ft->signal.size == SOX_SIZE_16BIT)
         {
-            st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
-            ft->signal.size = ST_SIZE_BYTE;
-            ft->signal.encoding = ST_ENCODING_ULAW;
+            sox_report("Warning: Detected simple hardware.  Forcing output to ULAW");
+            ft->signal.size = SOX_SIZE_BYTE;
+            ft->signal.encoding = SOX_ENCODING_ULAW;
         }
     }
 
     if (ft->signal.rate == 0.0) ft->signal.rate = 8000;
-    if (ft->signal.size == -1) ft->signal.size = ST_SIZE_BYTE;
-    if (ft->signal.encoding == ST_ENCODING_UNKNOWN) 
-        ft->signal.encoding = ST_ENCODING_ULAW;
+    if (ft->signal.size == -1) ft->signal.size = SOX_SIZE_BYTE;
+    if (ft->signal.encoding == SOX_ENCODING_UNKNOWN) 
+        ft->signal.encoding = SOX_ENCODING_ULAW;
 
-    if (ft->signal.size == ST_SIZE_BYTE) 
+    if (ft->signal.size == SOX_SIZE_BYTE) 
     {
         samplesize = 8;
-        if (ft->signal.encoding != ST_ENCODING_ULAW &&
-            ft->signal.encoding != ST_ENCODING_ALAW &&
-            ft->signal.encoding != ST_ENCODING_SIGN2) {
-            st_report("Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
-            st_report("Forcing to ULAW");
-            ft->signal.encoding = ST_ENCODING_ULAW;
+        if (ft->signal.encoding != SOX_ENCODING_ULAW &&
+            ft->signal.encoding != SOX_ENCODING_ALAW &&
+            ft->signal.encoding != SOX_ENCODING_SIGN2) {
+            sox_report("Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
+            sox_report("Forcing to ULAW");
+            ft->signal.encoding = SOX_ENCODING_ULAW;
         }
-        if ((ft->signal.encoding == ST_ENCODING_ULAW ||
-             ft->signal.encoding == ST_ENCODING_ALAW) && 
+        if ((ft->signal.encoding == SOX_ENCODING_ULAW ||
+             ft->signal.encoding == SOX_ENCODING_ALAW) && 
             ft->signal.channels == 2)
         {
-            st_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono.");
+            sox_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono.");
             ft->signal.channels = 1;
         }
 
     }
-    else if (ft->signal.size == ST_SIZE_16BIT) {
+    else if (ft->signal.size == SOX_SIZE_16BIT) {
         samplesize = 16;
-        if (ft->signal.encoding != ST_ENCODING_SIGN2) {
-            st_report("Sun Audio driver only supports Signed Linear for words.");
-            st_report("Forcing to Signed Linear");
-            ft->signal.encoding = ST_ENCODING_SIGN2;
+        if (ft->signal.encoding != SOX_ENCODING_SIGN2) {
+            sox_report("Sun Audio driver only supports Signed Linear for words.");
+            sox_report("Forcing to Signed Linear");
+            ft->signal.encoding = SOX_ENCODING_SIGN2;
         }
     }
     else {
-        st_report("Sun Audio driver only supports bytes and words");
-        ft->signal.size = ST_SIZE_16BIT;
+        sox_report("Sun Audio driver only supports bytes and words");
+        ft->signal.size = SOX_SIZE_16BIT;
         samplesize = 16;
     }
 
@@ -273,15 +273,15 @@
 
     /* Read in old values, change to what we need and then send back */
     if (ioctl(fileno(ft->fp), AUDIO_GETINFO, &audio_if) < 0) {
-        st_fail_errno(ft,errno,"Unable to initialize /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize /dev/audio");
+        return(SOX_EOF);
     }
     audio_if.play.precision = samplesize;
     audio_if.play.channels = ft->signal.channels;
     audio_if.play.sample_rate = ft->signal.rate;
-    if (ft->signal.encoding == ST_ENCODING_ULAW)
+    if (ft->signal.encoding == SOX_ENCODING_ULAW)
         encoding = AUDIO_ENCODING_ULAW;
-    else if (ft->signal.encoding == ST_ENCODING_ALAW)
+    else if (ft->signal.encoding == SOX_ENCODING_ALAW)
         encoding = AUDIO_ENCODING_ALAW;
     else
         encoding = AUDIO_ENCODING_LINEAR;
@@ -289,25 +289,25 @@
 
     ioctl(fileno(ft->fp), AUDIO_SETINFO, &audio_if);
     if (audio_if.play.precision != samplesize) {
-        st_fail_errno(ft,errno,"Unable to initialize sample size for /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize sample size for /dev/audio");
+        return(SOX_EOF);
     }
     if (audio_if.play.channels != ft->signal.channels) {
-        st_fail_errno(ft,errno,"Unable to initialize number of channels for /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize number of channels for /dev/audio");
+        return(SOX_EOF);
     }
     if (audio_if.play.sample_rate != ft->signal.rate) {
-        st_fail_errno(ft,errno,"Unable to initialize rate for /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize rate for /dev/audio");
+        return(SOX_EOF);
     }
     if (audio_if.play.encoding != encoding) {
-        st_fail_errno(ft,errno,"Unable to initialize encoding for /dev/audio");
-        return(ST_EOF);
+        sox_fail_errno(ft,errno,"Unable to initialize encoding for /dev/audio");
+        return(SOX_EOF);
     }
     /* Change to non-buffered I/O */
     setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * file->size);
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /* Sun /dev/audio player */
@@ -316,22 +316,22 @@
   NULL
 };
 
-static st_format_t st_sun_format = {
+static sox_format_t sox_sun_format = {
   sunnames,
   NULL,
-  ST_FILE_DEVICE,
-  st_sunstartread,
-  st_rawread,
-  st_rawstopread,
-  st_sunstartwrite,
-  st_rawwrite,
-  st_rawstopwrite,
-  st_format_nothing_seek
+  SOX_FILE_DEVICE,
+  sox_sunstartread,
+  sox_rawread,
+  sox_rawstopread,
+  sox_sunstartwrite,
+  sox_rawwrite,
+  sox_rawstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_sun_format_fn(void)
+const sox_format_t *sox_sun_format_fn(void)
 {
-    return &st_sun_format;
+    return &sox_sun_format;
 }
 
 #endif
--- a/src/swap.c
+++ b/src/swap.c
@@ -11,9 +11,9 @@
  */
 
 
-#include "st_i.h"
+#include "sox_i.h"
 
-static st_effect_t st_swap_effect;
+static sox_effect_t sox_swap_effect;
 
 typedef struct swapstuff {
     int         order[4];
@@ -26,7 +26,7 @@
  * Don't do initialization now.
  * The 'info' fields are not yet filled in.
  */
-static int st_swap_getopts(eff_t effp, int n, char **argv) 
+static int sox_swap_getopts(eff_t effp, int n, char **argv) 
 {
     swap_t swap = (swap_t) effp->priv;
 
@@ -36,8 +36,8 @@
         swap->def_opts = 0;
         if (n != 2 && n != 4)
         {
-            st_fail(st_swap_effect.usage);
-            return (ST_EOF);
+            sox_fail(sox_swap_effect.usage);
+            return (SOX_EOF);
         }
         else if (n == 2)
         {
@@ -55,7 +55,7 @@
     else
         swap->def_opts = 1;
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /*
@@ -62,7 +62,7 @@
  * Prepare processing.
  * Do all initializations.
  */
-static int st_swap_start(eff_t effp)
+static int sox_swap_start(eff_t effp)
 {
     swap_t swap = (swap_t) effp->priv;
     int i;
@@ -69,8 +69,8 @@
 
     if (effp->outinfo.channels == 1)
     {
-        st_fail("Can't swap channels on mono data.");
-        return (ST_EOF);
+        sox_fail("Can't swap channels on mono data.");
+        return (SOX_EOF);
     }
 
     if (effp->outinfo.channels == 2)
@@ -83,12 +83,12 @@
 
         if (swap->order[2] || swap->order[3])
         {
-            st_fail("invalid swap channel options used");
+            sox_fail("invalid swap channel options used");
         }
         if (swap->order[0] != 1 && swap->order[0] != 2)
-            st_fail("invalid swap channel options used");
+            sox_fail("invalid swap channel options used");
         if (swap->order[1] != 1 && swap->order[1] != 2)
-            st_fail("invalid swap channel options used");
+            sox_fail("invalid swap channel options used");
 
         /* Convert to array offsets */
         swap->order[0]--;
@@ -106,13 +106,13 @@
         }
 
         if (swap->order[0] < 1 || swap->order[0] > 4)
-            st_fail("invalid swap channel options used");
+            sox_fail("invalid swap channel options used");
         if (swap->order[1] < 1 || swap->order[1] > 4)
-            st_fail("invalid swap channel options used");
+            sox_fail("invalid swap channel options used");
         if (swap->order[2] < 1 || swap->order[2] > 4)
-            st_fail("invalid swap channel options used");
+            sox_fail("invalid swap channel options used");
         if (swap->order[3] < 1 || swap->order[3] > 4)
-            st_fail("invalid swap channel options used");
+            sox_fail("invalid swap channel options used");
 
         /* Convert to array offsets */
         swap->order[0]--;
@@ -124,9 +124,9 @@
 
     for (i = 0; i < (int)effp->outinfo.channels; ++i)
       if (swap->order[i] != i)
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
 
-    return ST_EFF_NULL;
+    return SOX_EFF_NULL;
 }
 
 /*
@@ -133,8 +133,8 @@
  * Processed signed long samples from ibuf to obuf.
  * Return number of samples processed.
  */
-static int st_swap_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                 st_size_t *isamp, st_size_t *osamp)
+static int sox_swap_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                 sox_size_t *isamp, sox_size_t *osamp)
 {
     swap_t swap = (swap_t) effp->priv;
     int len, done;
@@ -180,22 +180,22 @@
         
         break;
     }
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-static st_effect_t st_swap_effect = {
+static sox_effect_t sox_swap_effect = {
   "swap",
   "Usage: swap [1 2 | 1 2 3 4]",
-  ST_EFF_MCHAN,
-  st_swap_getopts,
-  st_swap_start,
-  st_swap_flow,
-  st_effect_nothing_drain,
-  st_effect_nothing,
-  st_effect_nothing  
+  SOX_EFF_MCHAN,
+  sox_swap_getopts,
+  sox_swap_start,
+  sox_swap_flow,
+  sox_effect_nothing_drain,
+  sox_effect_nothing,
+  sox_effect_nothing  
 };
 
-const st_effect_t *st_swap_effect_fn(void)
+const sox_effect_t *sox_swap_effect_fn(void)
 {
-    return &st_swap_effect;
+    return &sox_swap_effect;
 }
--- a/src/synth.c
+++ b/src/synth.c
@@ -16,7 +16,7 @@
 #include <ctype.h>
 #include "synth.h"
 
-static st_effect_t st_synth_effect;
+static sox_effect_t sox_synth_effect;
 
 #define PCOUNT 5
 
@@ -168,10 +168,10 @@
     double par[MAXCHAN][5];
 
     /* internal stuff */
-    st_sample_t max;
-    st_size_t samples_done;
+    sox_sample_t max;
+    sox_size_t samples_done;
     int rate;
-    st_size_t length; /* length in number of samples */
+    sox_size_t length; /* length in number of samples */
     double h[MAXCHAN]; /* store values necessary for  creation */
     PinkNoise pinkn[MAXCHAN];
 } *synth_t;
@@ -237,7 +237,7 @@
  * Don't do initialization now.
  * The 'info' fields are not yet filled in.
  */
-int st_synth_getopts(eff_t effp, int n, char **argv) 
+int sox_synth_getopts(eff_t effp, int n, char **argv) 
 {
     int argn;
     char *hlp;
@@ -264,12 +264,12 @@
 
     argn=0;
     if ( n<0){
-        st_fail(st_synth_effect.usage);
-        return(ST_EOF);
+        sox_fail(sox_synth_effect.usage);
+        return(SOX_EOF);
     }
     if(n==0){
         /* no arg, use default*/
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
     }
     
 
@@ -278,10 +278,10 @@
         synth->length_str = (char *)xmalloc(strlen(argv[argn])+1);
         strcpy(synth->length_str,argv[argn]);
         /* Do a dummy parse of to see if it will fail */
-        if (st_parsesamples(0, synth->length_str, &synth->length, 't') == NULL)
+        if (sox_parsesamples(0, synth->length_str, &synth->length, 't') == NULL)
         {
-            st_fail(st_synth_effect.usage);
-            return (ST_EOF);
+            sox_fail(sox_synth_effect.usage);
+            return (SOX_EOF);
         }
         argn++;
     }
@@ -290,8 +290,8 @@
     for (c = 0; c < MAXCHAN && n > argn; c++) {
       enum_item const * p = find_enum_text(argv[argn], synth_type);
       if (p == NULL) {
-        st_fail("no type given");
-        return ST_EOF;
+        sox_fail("no type given");
+        return SOX_EOF;
       }
       synth->type[c] = p->value;
       if (++argn == n) break;
@@ -307,19 +307,19 @@
       if (isdigit((int)argv[argn][0]) || argv[argn][0] == '%') {
         synth->freq2[c] = synth->freq[c] = StringToFreq(argv[argn], &hlp);
         if (synth->freq[c] < 0) {
-          st_fail("invalid freq");
-          return ST_EOF;
+          sox_fail("invalid freq");
+          return SOX_EOF;
         }
         if (*hlp == '-') { /* freq2 given? */
           char * hlp2;
           synth->freq2[c] = StringToFreq(hlp + 1, &hlp2);
           if (synth->freq2[c] < 0) {
-            st_fail("invalid freq2");
-            return ST_EOF;
+            sox_fail("invalid freq2");
+            return SOX_EOF;
           }
           if (synth->length_str == NULL) {
-            st_fail("length must be given when using freq2");
-            return ST_EOF;
+            sox_fail("length must be given when using freq2");
+            return SOX_EOF;
           }
         }
         if (++argn == n) break;
@@ -328,13 +328,13 @@
       /* read rest of parameters */
       for (i = 0; argn < n && isdigit((int)argv[argn][0]); ++i, ++argn) {
         if (i == PCOUNT) {
-          st_fail("too many parameters");
-          return ST_EOF;
+          sox_fail("too many parameters");
+          return SOX_EOF;
         }
         synth->par[c][i] = strtod(argv[argn], &hlp);
         if (hlp == argv[argn]) {
-          st_fail("parameter error");
-          return ST_EOF;
+          sox_fail("parameter error");
+          return SOX_EOF;
         }
       }
       if (argn == n) break;
@@ -357,7 +357,7 @@
         parmcopy(synth,1,3);
     }
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 
@@ -365,7 +365,7 @@
  * Prepare processing.
  * Do all initializations.
  */
-int st_synth_start(eff_t effp)
+int sox_synth_start(eff_t effp)
 {
     int i;
     int c;
@@ -372,15 +372,15 @@
     synth_t synth = (synth_t) effp->priv;
     int shift_for_max = (4 - min(effp->outinfo.size, 4)) << 3;
 
-    synth->max = (ST_SAMPLE_MAX >> shift_for_max) << shift_for_max;
+    synth->max = (SOX_SAMPLE_MAX >> shift_for_max) << shift_for_max;
 
     if (synth->length_str)
     {
-        if (st_parsesamples(effp->ininfo.rate, synth->length_str,
+        if (sox_parsesamples(effp->ininfo.rate, synth->length_str,
                             &synth->length, 't') == NULL)
         {
-            st_fail(st_synth_effect.usage);
-            return(ST_EOF);
+            sox_fail(sox_synth_effect.usage);
+            return(SOX_EOF);
         }
     }
 
@@ -464,21 +464,21 @@
                 break;
         }
 
-        st_debug("type=%i, mix=%i, length=%u, f1=%g, f2=%g",
+        sox_debug("type=%i, mix=%i, length=%u, f1=%g, f2=%g",
                 synth->type[c], synth->mix[c], 
                 synth->length, synth->freq[c], synth->freq2[c]);
-        st_debug("p0=%g, p1=%g, p2=%g, p3=%g, p4=%g",
+        sox_debug("p0=%g, p1=%g, p2=%g, p3=%g, p4=%g",
                 synth->par[c][0], synth->par[c][1],
                 synth->par[c][2], synth->par[c][3], synth->par[c][4]);
     }
-    st_debug("inchan=%i, rate=%i", (int)effp->ininfo.channels,synth->rate);
-    return (ST_SUCCESS);
+    sox_debug("inchan=%i, rate=%i", (int)effp->ininfo.channels,synth->rate);
+    return (SOX_SUCCESS);
 }
 
 
 
-static st_sample_t do_synth(st_sample_t iv, synth_t synth, int c){
-    st_sample_t ov=iv;
+static sox_sample_t do_synth(sox_sample_t iv, synth_t synth, int c){
+    sox_sample_t ov=iv;
     double r=0.0; /* -1 .. +1 */
     double f;
     double om;
@@ -617,7 +617,7 @@
             r=synth->h[c];
             break;
         default:
-            st_warn("synth: internal error 1");
+            sox_warn("synth: internal error 1");
             break;
     }
 
@@ -637,13 +637,13 @@
             ov = iv/2 + r*synth->max/2;
             break;
         case SYNTH_AMOD:
-            ov = (st_sample_t)(0.5*(r+1.0)*(double)iv);
+            ov = (sox_sample_t)(0.5*(r+1.0)*(double)iv);
             break;
         case SYNTH_FMOD:
             ov = iv * r ;
             break;
         default:
-            st_fail("synth: internal error 2");
+            sox_fail("synth: internal error 2");
             break;
     }
 
@@ -655,8 +655,8 @@
 /*
  * Processed signed long samples from ibuf to obuf.
  */
-int st_synth_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                  st_size_t *isamp, st_size_t *osamp)
+int sox_synth_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                  sox_size_t *isamp, sox_size_t *osamp)
 {
     synth_t synth = (synth_t) effp->priv;
     int len; /* number of input samples */
@@ -663,16 +663,16 @@
     int done = 0;
     int c;
     int chan=effp->ininfo.channels;
-    int result = ST_SUCCESS;
+    int result = SOX_SUCCESS;
 
     if(chan > MAXCHAN ){
-        st_fail("synth: can not operate with more than %d channels",MAXCHAN);
-        return(ST_EOF);
+        sox_fail("synth: can not operate with more than %d channels",MAXCHAN);
+        return(SOX_EOF);
     }
 
     len = ((*isamp > *osamp) ? *osamp : *isamp) / chan;
 
-    while (done < len && result == ST_SUCCESS)
+    while (done < len && result == SOX_SUCCESS)
     {
         for(c=0;c<chan;c++){
             /* each channel is independent, but the algorithm is the same */
@@ -685,7 +685,7 @@
         synth->samples_done++;
         if (synth->length > 0 && synth->samples_done == synth->length)
         {
-            result = ST_EOF;
+            result = SOX_EOF;
         }
     }
     *isamp = *osamp = done * chan;
@@ -692,21 +692,21 @@
     return result;
 }
 
-static st_effect_t st_synth_effect = {
+static sox_effect_t sox_synth_effect = {
   "synth",
   "Usage: synth [len] {[type] [combine] [freq[-freq2]] [off] [ph] [p1] [p2] [p3]}",
-  ST_EFF_MCHAN,
-  st_synth_getopts,
-  st_synth_start,
-  st_synth_flow,
-  st_effect_nothing_drain,
-  st_effect_nothing,
-  st_effect_nothing
+  SOX_EFF_MCHAN,
+  sox_synth_getopts,
+  sox_synth_start,
+  sox_synth_flow,
+  sox_effect_nothing_drain,
+  sox_effect_nothing,
+  sox_effect_nothing
 };
 
-const st_effect_t *st_synth_effect_fn(void)
+const sox_effect_t *sox_synth_effect_fn(void)
 {
-    return &st_synth_effect;
+    return &sox_synth_effect;
 }
 /*-------------------------------------------------------------- end of file */
 
--- a/src/synth.h
+++ b/src/synth.h
@@ -1,4 +1,4 @@
-#include "st_i.h"
-int st_synth_getopts(eff_t, int, char * *);
-int st_synth_start(eff_t);
-int st_synth_flow(eff_t, st_sample_t const *, st_sample_t *, st_size_t *, st_size_t *);
+#include "sox_i.h"
+int sox_synth_getopts(eff_t, int, char * *);
+int sox_synth_start(eff_t);
+int sox_synth_flow(eff_t, sox_sample_t const *, sox_sample_t *, sox_size_t *, sox_size_t *);
--- a/src/tremolo.c
+++ b/src/tremolo.c
@@ -29,20 +29,20 @@
       sscanf(argv[0], "%lf %c", &speed, &dummy) != 1 || speed < 0 ||
       (n > 1 && sscanf(argv[1], "%lf %c", &depth, &dummy) != 1) ||
       depth <= 0 || depth > 100) {
-    st_fail(effp->h->usage);
-    return ST_EOF;
+    sox_fail(effp->h->usage);
+    return SOX_EOF;
   }
   synth_args[2] = argv[0];
   sprintf(offset, "%g", 100 - depth / 2);
   synth_args[3] = offset;
-  return st_synth_getopts(effp, array_length(synth_args), synth_args);
+  return sox_synth_getopts(effp, array_length(synth_args), synth_args);
 }
 
-st_effect_t const * st_tremolo_effect_fn(void)
+sox_effect_t const * sox_tremolo_effect_fn(void)
 {
-  static st_effect_t driver = {
-    "tremolo", "Usage: tremolo speed_Hz [depth_percent];", ST_EFF_MCHAN,
-    getopts, st_synth_start, st_synth_flow, 0, 0, 0,
+  static sox_effect_t driver = {
+    "tremolo", "Usage: tremolo speed_Hz [depth_percent];", SOX_EFF_MCHAN,
+    getopts, sox_synth_start, sox_synth_flow, 0, 0, 0,
   };
   return &driver;
 }
--- a/src/trim.c
+++ b/src/trim.c
@@ -11,10 +11,10 @@
  * Sound Tools skeleton effect file.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <string.h>
 
-static st_effect_t st_trim_effect;
+static sox_effect_t sox_trim_effect;
 
 /* Time resolutin one millisecond */
 #define TIMERES 1000
@@ -26,18 +26,18 @@
     char *length_str;
 
     /* options converted to values */
-    st_size_t start;
-    st_size_t length;
+    sox_size_t start;
+    sox_size_t length;
 
     /* internal stuff */
-    st_size_t index;
-    st_size_t trimmed;
+    sox_size_t index;
+    sox_size_t trimmed;
 } * trim_t;
 
 /*
  * Process options
  */
-static int st_trim_getopts(eff_t effp, int n, char **argv) 
+static int sox_trim_getopts(eff_t effp, int n, char **argv) 
 {
     trim_t trim = (trim_t) effp->priv;
 
@@ -49,42 +49,42 @@
             trim->length_str = (char *)xmalloc(strlen(argv[1])+1);
             strcpy(trim->length_str,argv[1]);
             /* Do a dummy parse to see if it will fail */
-            if (st_parsesamples(0, trim->length_str, &trim->length, 't') == NULL)
+            if (sox_parsesamples(0, trim->length_str, &trim->length, 't') == NULL)
             {
-                st_fail(st_trim_effect.usage);
-                return(ST_EOF);
+                sox_fail(sox_trim_effect.usage);
+                return(SOX_EOF);
             }
         case 1:
             trim->start_str = (char *)xmalloc(strlen(argv[0])+1);
             strcpy(trim->start_str,argv[0]);
             /* Do a dummy parse to see if it will fail */
-            if (st_parsesamples(0, trim->start_str, &trim->start, 't') == NULL)
+            if (sox_parsesamples(0, trim->start_str, &trim->start, 't') == NULL)
             {
-                st_fail(st_trim_effect.usage);
-                return(ST_EOF);
+                sox_fail(sox_trim_effect.usage);
+                return(SOX_EOF);
             }
             break;
         default:
-            st_fail(st_trim_effect.usage);
-            return ST_EOF;
+            sox_fail(sox_trim_effect.usage);
+            return SOX_EOF;
             break;
 
     }
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /*
  * Start processing
  */
-static int st_trim_start(eff_t effp)
+static int sox_trim_start(eff_t effp)
 {
     trim_t trim = (trim_t) effp->priv;
 
-    if (st_parsesamples(effp->ininfo.rate, trim->start_str,
+    if (sox_parsesamples(effp->ininfo.rate, trim->start_str,
                         &trim->start, 't') == NULL)
     {
-        st_fail(st_trim_effect.usage);
-        return(ST_EOF);
+        sox_fail(sox_trim_effect.usage);
+        return(SOX_EOF);
     }
     /* Account for # of channels */
     trim->start *= effp->ininfo.channels;
@@ -91,11 +91,11 @@
 
     if (trim->length_str)
     {
-        if (st_parsesamples(effp->ininfo.rate, trim->length_str,
+        if (sox_parsesamples(effp->ininfo.rate, trim->length_str,
                     &trim->length, 't') == NULL)
         {
-            st_fail(st_trim_effect.usage);
-            return(ST_EOF);
+            sox_fail(sox_trim_effect.usage);
+            return(SOX_EOF);
         }
     }
     else
@@ -107,7 +107,7 @@
     trim->index = 0;
     trim->trimmed = 0;
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /*
@@ -116,8 +116,8 @@
  * Place in buf[].
  * Return number of samples read.
  */
-static int st_trim_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                 st_size_t *isamp, st_size_t *osamp)
+static int sox_trim_flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                 sox_size_t *isamp, sox_size_t *osamp)
 {
     int finished = 0;
     int start_trim = 0;
@@ -140,7 +140,7 @@
             *osamp = 0;
             *isamp = done;
             trim->index += done;
-            return (ST_SUCCESS);
+            return (SOX_SUCCESS);
         } else {
             start_trim = 1;
             /* We've read at least "start" samples.  Now find
@@ -164,19 +164,19 @@
         trim->trimmed += done;
     }
 
-    memcpy(obuf, ibuf+offset, done * sizeof(st_sample_t));
+    memcpy(obuf, ibuf+offset, done * sizeof(sox_sample_t));
 
     *osamp = done;
     *isamp = offset + done;
     trim->index += done;
 
-    /* return ST_EOF when nothing consumed and we detect
+    /* return SOX_EOF when nothing consumed and we detect
      * we are finished.
      */
     if (finished && !done)
-        return (ST_EOF);
+        return (SOX_EOF);
     else
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 static int delete(eff_t effp)
@@ -186,34 +186,34 @@
     free(trim->start_str);
     free(trim->length_str);
 
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-st_size_t st_trim_get_start(eff_t effp)          
+sox_size_t sox_trim_get_start(eff_t effp)          
 {        
     trim_t trim = (trim_t)effp->priv;    
     return trim->start;          
 }        
 
-void st_trim_clear_start(eff_t effp)     
+void sox_trim_clear_start(eff_t effp)     
 {        
     trim_t trim = (trim_t)effp->priv;    
     trim->start = 0;     
 }
 
-static st_effect_t st_trim_effect = {
+static sox_effect_t sox_trim_effect = {
   "trim",
   "Usage: trim start [length]",
-  ST_EFF_MCHAN,
-  st_trim_getopts,
-  st_trim_start,
-  st_trim_flow,
-  st_effect_nothing_drain,
-  st_effect_nothing,
+  SOX_EFF_MCHAN,
+  sox_trim_getopts,
+  sox_trim_start,
+  sox_trim_flow,
+  sox_effect_nothing_drain,
+  sox_effect_nothing,
   delete
 };
 
-const st_effect_t *st_trim_effect_fn(void)
+const sox_effect_t *sox_trim_effect_fn(void)
 {
-    return &st_trim_effect;
+    return &sox_trim_effect;
 }
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -41,11 +41,11 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "st_i.h"
+#include "sox_i.h"
 
 /* Private data for TX16 file */
 typedef struct txwstuff {
-        st_size_t rest;                 /* bytes remaining in sample file */
+        sox_size_t rest;                 /* bytes remaining in sample file */
 } *txw_t;
 
 struct WaveHeader_ {
@@ -64,8 +64,8 @@
 static const unsigned char magic2[4] = {0, 0x52, 0x00, 0x52};
 
 /* SJB: dangerous static variables */
-static st_size_t tx16w_len=0;
-static st_size_t writedone=0;
+static sox_size_t tx16w_len=0;
+static sox_size_t writedone=0;
 
 /*
  * Do anything required before you start reading samples.
@@ -74,13 +74,13 @@
  *      size and encoding of samples,
  *      mono/stereo/quad.
  */
-static int st_txwstartread(ft_t ft)
+static int sox_txwstartread(ft_t ft)
 {
     int c;
     char filetype[7];
     char format;
     char sample_rate;
-    st_size_t num_samp_bytes = 0;
+    sox_size_t num_samp_bytes = 0;
     char gunk[8];
     int blewIt;
     uint32_t trash;
@@ -89,45 +89,45 @@
     /* If you need to seek around the input file. */
     if (! ft->seekable)
     {
-        st_fail_errno(ft,ST_EOF,"txw input file must be a file, not a pipe");
-        return(ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"txw input file must be a file, not a pipe");
+        return(SOX_EOF);
     }
 
     /* This is dumb but portable, just count the bytes til EOF */
-    while (st_readb(ft, (unsigned char *)&trash) != ST_EOF)
+    while (sox_readb(ft, (unsigned char *)&trash) != SOX_EOF)
         num_samp_bytes++; 
     num_samp_bytes -= 32;         /* calculate num samples by sub header size */
-    st_seeki(ft, 0, 0);           /* rewind file */
+    sox_seeki(ft, 0, 0);           /* rewind file */
     sk->rest = num_samp_bytes;    /* set how many sample bytes to read */
 
     /* first 6 bytes are file type ID LM8953 */
-    st_readb(ft, (unsigned char *)&filetype[0]);
-    st_readb(ft, (unsigned char *)&filetype[1]);
-    st_readb(ft, (unsigned char *)&filetype[2]);
-    st_readb(ft, (unsigned char *)&filetype[3]);
-    st_readb(ft, (unsigned char *)&filetype[4]);
-    st_readb(ft, (unsigned char *)&filetype[5]);
+    sox_readb(ft, (unsigned char *)&filetype[0]);
+    sox_readb(ft, (unsigned char *)&filetype[1]);
+    sox_readb(ft, (unsigned char *)&filetype[2]);
+    sox_readb(ft, (unsigned char *)&filetype[3]);
+    sox_readb(ft, (unsigned char *)&filetype[4]);
+    sox_readb(ft, (unsigned char *)&filetype[5]);
     filetype[6] = '\0';
     for( c = 16; c > 0 ; c-- )    /* Discard next 16 bytes */
-        st_readb(ft, (unsigned char *)&trash);
-    st_readb(ft, (unsigned char *)&format);
-    st_readb(ft, (unsigned char *)&sample_rate);
+        sox_readb(ft, (unsigned char *)&trash);
+    sox_readb(ft, (unsigned char *)&format);
+    sox_readb(ft, (unsigned char *)&sample_rate);
     /*
      * save next 8 bytes - if sample rate is 0, then we need
      *  to look at gunk[2] and gunk[5] to get real rate
      */
     for( c = 0; c < 8; c++ )
-        st_readb(ft, (unsigned char *)&(gunk[c]));
+        sox_readb(ft, (unsigned char *)&(gunk[c]));
     /*
      * We should now be pointing at start of raw sample data in file 
      */
 
     /* Check to make sure we got a good filetype ID from file */
-    st_debug("Found header filetype %s",filetype);
+    sox_debug("Found header filetype %s",filetype);
     if(strcmp(filetype,"LM8953"))
     {
-        st_fail_errno(ft,ST_EHDR,"Invalid filetype ID in input file header, != LM8953");
-        return(ST_EOF);
+        sox_fail_errno(ft,SOX_EHDR,"Invalid filetype ID in input file header, != LM8953");
+        return(SOX_EOF);
     }
     /*
      * Set up the sample rate as indicated by the header
@@ -166,30 +166,30 @@
                     break;
             }
             if ( blewIt ) {
-                st_debug("Invalid sample rate identifier found %d", (int)sample_rate);
+                sox_debug("Invalid sample rate identifier found %d", (int)sample_rate);
                 ft->signal.rate = 33333;
             }
     }
-    st_debug("Sample rate = %ld",ft->signal.rate);
+    sox_debug("Sample rate = %ld",ft->signal.rate);
 
     ft->signal.channels = 1 ; /* not sure about stereo sample data yet ??? */
-    ft->signal.size = ST_SIZE_16BIT; /* this is close enough */
-    ft->signal.encoding = ST_ENCODING_SIGN2;
+    ft->signal.size = SOX_SIZE_16BIT; /* this is close enough */
+    ft->signal.encoding = SOX_ENCODING_SIGN2;
 
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
 }
 
 /*
  * Read up to len samples from file.
- * Convert to st_sample_ts.
+ * Convert to sox_sample_ts.
  * Place in buf[].
  * Return number of samples read.
  */
 
-static st_size_t st_txwread(ft_t ft, st_sample_t *buf, st_size_t len)
+static sox_size_t sox_txwread(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
     txw_t sk = (txw_t) ft->priv;
-    st_size_t done = 0;
+    sox_size_t done = 0;
     unsigned char uc1,uc2,uc3;
     unsigned short s1,s2;
 
@@ -211,24 +211,24 @@
      * two unsigned short samples. 
      * TCC 3.0 appeared to do unwanted things, so we really specify
      *  exactly what we want to happen.
-     * Convert unsigned short to st_sample_t then shift up the result
+     * Convert unsigned short to sox_sample_t then shift up the result
      *  so that the 12-bit sample lives in the most significant
-     *  12-bits of the st_sample_t.
+     *  12-bits of the sox_sample_t.
      * This gets our two samples into the internal format which we
      * deposit into the given buffer and adjust our counts respectivly.
      */
     for(done = 0; done < len; ) {
         if(sk->rest < 3) break; /* Finished reading from file? */
-        st_readb(ft, &uc1);
-        st_readb(ft, &uc2);
-        st_readb(ft, &uc3);
+        sox_readb(ft, &uc1);
+        sox_readb(ft, &uc2);
+        sox_readb(ft, &uc3);
         sk->rest -= 3; /* adjust remaining for bytes we just read */
         s1 = (unsigned short) (uc1 << 4) | (((uc2 >> 4) & 017));
         s2 = (unsigned short) (uc3 << 4) | (( uc2 & 017 ));
-        *buf = (st_sample_t) s1;
+        *buf = (sox_sample_t) s1;
         *buf = (*buf << 20);
         buf++; /* sample one is done */
-        *buf = (st_sample_t) s2;
+        *buf = (sox_sample_t) s2;
         *buf = (*buf << 20);
         buf++; /* sample two is done */
         done += 2; /* adjust converted & stored sample count */
@@ -236,40 +236,40 @@
     return done;
 }
 
-static int st_txwstartwrite(ft_t ft)
+static int sox_txwstartwrite(ft_t ft)
 {
     struct WaveHeader_ WH;
 
-    st_debug("tx16w selected output");
+    sox_debug("tx16w selected output");
 
     memset(&WH, 0, sizeof(struct WaveHeader_));
 
     if (ft->signal.channels != 1)
-        st_report("tx16w is overriding output format to 1 channel.");
+        sox_report("tx16w is overriding output format to 1 channel.");
     ft->signal.channels = 1 ; /* not sure about stereo sample data yet ??? */
-    if (ft->signal.size != ST_SIZE_16BIT || ft->signal.encoding != ST_ENCODING_SIGN2)
-        st_report("tx16w is overriding output format to size Signed Word format.");
-    ft->signal.size = ST_SIZE_16BIT; /* this is close enough */
-    ft->signal.encoding = ST_ENCODING_SIGN2;
+    if (ft->signal.size != SOX_SIZE_16BIT || ft->signal.encoding != SOX_ENCODING_SIGN2)
+        sox_report("tx16w is overriding output format to size Signed Word format.");
+    ft->signal.size = SOX_SIZE_16BIT; /* this is close enough */
+    ft->signal.encoding = SOX_ENCODING_SIGN2;
 
     /* If you have to seek around the output file */
     if (! ft->seekable)
     {
-        st_fail_errno(ft,ST_EOF,"Output .txw file must be a file, not a pipe");
-        return(ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"Output .txw file must be a file, not a pipe");
+        return(SOX_EOF);
     }
 
     /* dummy numbers, just for place holder, real header is written
        at end of processing, since byte count is needed */
 
-    st_writebuf(ft, &WH, 1, 32);
+    sox_writebuf(ft, &WH, 1, 32);
     writedone = 32;
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
 }
 
-static st_size_t st_txwwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static sox_size_t sox_txwwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
-    st_size_t i;
+    sox_size_t i;
     unsigned int w1,w2;
 
     tx16w_len += len;
@@ -282,15 +282,15 @@
         else {
             w2 =  *buf++ >> 20;
         }
-        st_writeb(ft, (w1 >> 4) & 0xFF);
-        st_writeb(ft, (((w1 & 0x0F) << 4) | (w2 & 0x0F)) & 0xFF);
-        st_writeb(ft, (w2 >> 4) & 0xFF);
+        sox_writeb(ft, (w1 >> 4) & 0xFF);
+        sox_writeb(ft, (((w1 & 0x0F) << 4) | (w2 & 0x0F)) & 0xFF);
+        sox_writeb(ft, (w2 >> 4) & 0xFF);
         writedone += 3;
     }
     return(len);
 }
 
-static int st_txwstopwrite(ft_t ft)
+static int sox_txwstopwrite(ft_t ft)
 {
     struct WaveHeader_ WH;
     int AttackLength, LoopLength, i;
@@ -299,7 +299,7 @@
     /* If file header needs fixing up, for example it needs the */
     /* the number of samples in a field, seek back and write them here. */
 
-    st_debug("tx16w:output finished");
+    sox_debug("tx16w:output finished");
 
     memset(&WH, 0, sizeof(struct WaveHeader_));
     strncpy(WH.filetype,"LM8953",6);
@@ -317,7 +317,7 @@
     else                            WH.sample_rate = 2;
 
     if (tx16w_len >= TXMAXLEN) {
-        st_warn("Sound too large for TX16W. Truncating, Loop Off");
+        sox_warn("Sound too large for TX16W. Truncating, Loop Off");
         AttackLength       = TXMAXLEN/2;
         LoopLength         = TXMAXLEN/2;
     }
@@ -337,9 +337,9 @@
         AttackLength                       = 0x40;
         LoopLength                         = 0x40;
         for(i=tx16w_len;i<0x80;i++) {
-            st_writeb(ft, 0);
-            st_writeb(ft, 0);
-            st_writeb(ft, 0);
+            sox_writeb(ft, 0);
+            sox_writeb(ft, 0);
+            sox_writeb(ft, 0);
             writedone += 3;
         }
     }
@@ -347,7 +347,7 @@
     /* Fill up to 256 byte blocks; the TX16W seems to like that */
 
     while ((writedone % 0x100) != 0) {
-        st_writeb(ft, 0);
+        sox_writeb(ft, 0);
         writedone++;
     }
 
@@ -361,10 +361,10 @@
     WH.rpt_length[2] = (0x01 & (LoopLength >> 16)) +
         magic2[WH.sample_rate];
 
-    st_rewind(ft);
-    st_writebuf(ft, &WH, 1, 32);
+    sox_rewind(ft);
+    sox_writebuf(ft, &WH, 1, 32);
 
-    return(ST_SUCCESS);
+    return(SOX_SUCCESS);
 }
 
 /* Yamaha TX16W and SY99 waves */
@@ -373,20 +373,20 @@
   NULL
 };
 
-static st_format_t st_txw_format = {
+static sox_format_t sox_txw_format = {
    txwnames,
    NULL,
    0,
-   st_txwstartread,
-   st_txwread,
-   st_format_nothing,
-   st_txwstartwrite,
-   st_txwwrite,
-   st_txwstopwrite,
-   st_format_nothing_seek
+   sox_txwstartread,
+   sox_txwread,
+   sox_format_nothing,
+   sox_txwstartwrite,
+   sox_txwwrite,
+   sox_txwstopwrite,
+   sox_format_nothing_seek
 };
 
-const st_format_t *st_txw_format_fn(void)
+const sox_format_t *sox_txw_format_fn(void)
 {
-    return &st_txw_format;
+    return &sox_txw_format;
 }
--- a/src/util.c
+++ b/src/util.c
@@ -15,16 +15,16 @@
  * the consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <stddef.h>
 #include <string.h>
 #include <ctype.h>
 #include <stdarg.h>
 
-st_output_message_handler_t st_output_message_handler = NULL;
-int st_output_verbosity_level = 2;
+sox_output_message_handler_t sox_output_message_handler = NULL;
+int sox_output_verbosity_level = 2;
 
-void st_output_message(FILE *file, const char *filename, const char *fmt, va_list ap)
+void sox_output_message(FILE *file, const char *filename, const char *fmt, va_list ap)
 {
   char buffer[10];
   char const * drivername;
@@ -59,76 +59,76 @@
  * the message.  Using the filename for this purpose is only an
  * approximation, but it saves a lot of work. ;)
  */
-char const * st_message_filename = 0;
+char const * sox_message_filename = 0;
 
 
 
-static void st_emit_message(int level, char const *fmt, va_list ap)
+static void sox_emit_message(int level, char const *fmt, va_list ap)
 {
-  if (st_output_message_handler != NULL)
-    (*st_output_message_handler)(level, st_message_filename, fmt, ap);
+  if (sox_output_message_handler != NULL)
+    (*sox_output_message_handler)(level, sox_message_filename, fmt, ap);
 }
 
 
 
-#undef st_fail
-#undef st_warn
-#undef st_report
-#undef st_debug
-#undef st_debug_more
-#undef st_debug_most
+#undef sox_fail
+#undef sox_warn
+#undef sox_report
+#undef sox_debug
+#undef sox_debug_more
+#undef sox_debug_most
 
-#define ST_MESSAGE_FUNCTION(name,level) \
+#define SOX_MESSAGE_FUNCTION(name,level) \
 void name(char const * fmt, ...) \
 { \
   va_list args; \
 \
   va_start(args, fmt); \
-  st_emit_message(level, fmt, args); \
+  sox_emit_message(level, fmt, args); \
   va_end(args); \
 }
 
-ST_MESSAGE_FUNCTION(st_fail  , 1)
-ST_MESSAGE_FUNCTION(st_warn  , 2)
-ST_MESSAGE_FUNCTION(st_report, 3)
-ST_MESSAGE_FUNCTION(st_debug , 4)
-ST_MESSAGE_FUNCTION(st_debug_more , 5)
-ST_MESSAGE_FUNCTION(st_debug_most , 6)
+SOX_MESSAGE_FUNCTION(sox_fail  , 1)
+SOX_MESSAGE_FUNCTION(sox_warn  , 2)
+SOX_MESSAGE_FUNCTION(sox_report, 3)
+SOX_MESSAGE_FUNCTION(sox_debug , 4)
+SOX_MESSAGE_FUNCTION(sox_debug_more , 5)
+SOX_MESSAGE_FUNCTION(sox_debug_most , 6)
 
-#undef ST_MESSAGE_FUNCTION
+#undef SOX_MESSAGE_FUNCTION
 
-void st_fail_errno(ft_t ft, int st_errno, const char *fmt, ...)
+void sox_fail_errno(ft_t ft, int sox_errno, const char *fmt, ...)
 {
         va_list args;
 
-        ft->st_errno = st_errno;
+        ft->sox_errno = sox_errno;
 
         va_start(args, fmt);
 #ifdef _MSC_VER
-        vsprintf(ft->st_errstr, fmt, args);
+        vsprintf(ft->sox_errstr, fmt, args);
 #else
-        vsnprintf(ft->st_errstr, sizeof(ft->st_errstr), fmt, args);
+        vsnprintf(ft->sox_errstr, sizeof(ft->sox_errstr), fmt, args);
 #endif
         va_end(args);
-        ft->st_errstr[255] = '\0';
+        ft->sox_errstr[255] = '\0';
 }
 
 /*
  * Check that we have a known format suffix string.
  */
-int st_gettype(ft_t formp, st_bool is_file_extension)
+int sox_gettype(ft_t formp, sox_bool is_file_extension)
 {
     const char * const *list;
     int i;
-    const st_format_t *f;
+    const sox_format_t *f;
 
     if (!formp->filetype) {
-        st_fail_errno(formp, ST_EFMT, "Filetype was not specified");
-        return ST_EFMT;
+        sox_fail_errno(formp, SOX_EFMT, "Filetype was not specified");
+        return SOX_EFMT;
     }
-    for (i = 0; st_format_fns[i]; i++) {
-        f = st_format_fns[i]();
-        if (is_file_extension && (f->flags & ST_FILE_DEVICE))
+    for (i = 0; sox_format_fns[i]; i++) {
+        f = sox_format_fns[i]();
+        if (is_file_extension && (f->flags & SOX_FILE_DEVICE))
           continue; /* don't match device names in real file names */
         for (list = f->names; *list; list++) {
             const char *s1 = *list, *s2 = formp->filetype;
@@ -139,11 +139,11 @@
             continue;
         /* Found it! */
         formp->h = f;
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
     }
-    st_fail_errno(formp, ST_EFMT, "File type `%s' is not known",
+    sox_fail_errno(formp, SOX_EFMT, "File type `%s' is not known",
                   formp->filetype);
-    return ST_EFMT;
+    return SOX_EFMT;
 }
 
 /*
@@ -152,13 +152,13 @@
  * Returns -1 on error else it turns the total number of arguments
  * that should be passed to this effect's getopt() function.
  */
-int st_geteffect_opt(eff_t effp, int argc, char **argv)
+int sox_geteffect_opt(eff_t effp, int argc, char **argv)
 {
     int i, optind;
 
-    for (i = 0; st_effect_fns[i]; i++)
+    for (i = 0; sox_effect_fns[i]; i++)
     {
-        const st_effect_t *e = st_effect_fns[i]();
+        const sox_effect_t *e = sox_effect_fns[i]();
 
         if (e && e->name && strcasecmp(e->name, argv[0]) == 0) {
           effp->name = e->name;
@@ -165,9 +165,9 @@
           effp->h = e;
           for (optind = 1; optind < argc; optind++)
           {
-              for (i = 0; st_effect_fns[i]; i++)
+              for (i = 0; sox_effect_fns[i]; i++)
               {
-                  const st_effect_t *e = st_effect_fns[i]();
+                  const sox_effect_t *e = sox_effect_fns[i]();
                   if (e && e->name && strcasecmp(e->name, argv[optind]) == 0)
                     return (optind - 1);
               }
@@ -181,7 +181,7 @@
         }
     }
 
-    return (ST_EOF);
+    return (SOX_EOF);
 }
 
 /*
@@ -190,53 +190,53 @@
  * Returns -1 on on failure.
  */
 
-int st_geteffect(eff_t effp, const char *effect_name)
+int sox_geteffect(eff_t effp, const char *effect_name)
 {
     int i;
 
-    for(i = 0; st_effect_fns[i]; i++) {
-        const st_effect_t *e = st_effect_fns[i]();
+    for(i = 0; sox_effect_fns[i]; i++) {
+        const sox_effect_t *e = sox_effect_fns[i]();
 
         if (e && e->name && strcasecmp(e->name, effect_name) == 0) {
           effp->name = e->name;
           effp->h = e;
-          return ST_SUCCESS;
+          return SOX_SUCCESS;
         }
     }
 
-    return (ST_EOF);
+    return (SOX_EOF);
 }
 
 /*
  * Check if we have a known effect name.
  */
-st_bool is_effect_name(char const * text)
+sox_bool is_effect_name(char const * text)
 {
     int i;
 
-    for(i = 0; st_effect_fns[i]; i++) {
-        const st_effect_t *e = st_effect_fns[i]();
+    for(i = 0; sox_effect_fns[i]; i++) {
+        const sox_effect_t *e = sox_effect_fns[i]();
 
         if (e && e->name && strcasecmp(e->name, text) == 0)
-          return st_true;
+          return sox_true;
     }
 
-    return st_false;
+    return sox_false;
 }
 
 /*
  * Copy input and output signal info into effect structures.
- * Must pass in a bitmask containing info of wheither ST_EFF_CHAN
- * or ST_EFF_RATE has been used previously on this effect stream.
+ * Must pass in a bitmask containing info of wheither SOX_EFF_CHAN
+ * or SOX_EFF_RATE has been used previously on this effect stream.
  * If not running multiple effects then just pass in a value of 0.
  *
- * Return value is the same mask plus addition of ST_EFF_CHAN or
- * ST_EFF_RATE if it was used in this effect.  That make this
+ * Return value is the same mask plus addition of SOX_EFF_CHAN or
+ * SOX_EFF_RATE if it was used in this effect.  That make this
  * return value can be passed back into this function in future
  * calls.
  */
 
-int st_updateeffect(eff_t effp, const st_signalinfo_t *in, const st_signalinfo_t *out, 
+int sox_updateeffect(eff_t effp, const sox_signalinfo_t *in, const sox_signalinfo_t *out, 
                     int effect_mask)
 {
     effp->ininfo = *in;
@@ -245,17 +245,17 @@
 
     if (in->channels != out->channels)
     {
-        /* Only effects with ST_EFF_CHAN flag can actually handle
+        /* Only effects with SOX_EFF_CHAN flag can actually handle
          * outputing a different number of channels then the input.
          */
-        if (!(effp->h->flags & ST_EFF_CHAN))
+        if (!(effp->h->flags & SOX_EFF_CHAN))
         {
-            /* If this effect is being ran before a ST_EFF_CHAN effect
+            /* If this effect is being ran before a SOX_EFF_CHAN effect
              * then effect's output is the same as the input file. Else its
              * input contains same number of channels as the output
              * file.
              */
-            if (effect_mask & ST_EFF_CHAN)
+            if (effect_mask & SOX_EFF_CHAN)
                 effp->ininfo.channels = out->channels;
             else
                 effp->outinfo.channels = in->channels;
@@ -265,12 +265,12 @@
 
     if (in->rate != out->rate)
     {
-        /* Only the ST_EFF_RATE effect can handle an input that
+        /* Only the SOX_EFF_RATE effect can handle an input that
          * is a different sample rate then the output.
          */
-        if (!(effp->h->flags & ST_EFF_RATE))
+        if (!(effp->h->flags & SOX_EFF_RATE))
         {
-            if (effect_mask & ST_EFF_RATE)
+            if (effect_mask & SOX_EFF_RATE)
                 effp->ininfo.rate = out->rate;
             else
                 effp->outinfo.rate = in->rate;
@@ -277,16 +277,16 @@
         }
     }
 
-    if (effp->h->flags & ST_EFF_CHAN)
-        effect_mask |= ST_EFF_CHAN;
-    if (effp->h->flags & ST_EFF_RATE)
-        effect_mask |= ST_EFF_RATE;
+    if (effp->h->flags & SOX_EFF_CHAN)
+        effect_mask |= SOX_EFF_CHAN;
+    if (effp->h->flags & SOX_EFF_RATE)
+        effect_mask |= SOX_EFF_RATE;
 
     return effect_mask;
 }
 
 /*
- * st_parsesamples
+ * sox_parsesamples
  *
  * Parse a string for # of samples.  If string ends with a 's'
  * then the string is interpreted as a user calculated # of samples.
@@ -296,7 +296,7 @@
  * # of samples.
  * Returns NULL on error, pointer to next char to parse otherwise.
  */
-char const * st_parsesamples(st_rate_t rate, const char *str, st_size_t *samples, char def)
+char const * sox_parsesamples(sox_rate_t rate, const char *str, sox_size_t *samples, char def)
 {
     int found_samples = 0, found_time = 0;
     int time = 0;
@@ -304,7 +304,7 @@
     float frac = 0;
     char const * end;
     char const * pos;
-    st_bool found_colon, found_dot;
+    sox_bool found_colon, found_dot;
 
     for (end = str; *end && strchr("0123456789:.ts", *end); ++end);
     if (end == str)
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -29,20 +29,20 @@
       sscanf(argv[0], "%lf %c", &speed, &dummy) != 1 || speed < 0 ||
       (n > 1 && sscanf(argv[1], "%lf %c", &depth, &dummy) != 1) ||
       depth <= 0 || depth > 1) {
-    st_fail(effp->h->usage);
-    return ST_EOF;
+    sox_fail(effp->h->usage);
+    return SOX_EOF;
   }
   synth_args[2] = argv[0];
   sprintf(offset, "%g", 100 - 50 * depth);
   synth_args[3] = offset;
-  return st_synth_getopts(effp, array_length(synth_args), synth_args);
+  return sox_synth_getopts(effp, array_length(synth_args), synth_args);
 }
 
-st_effect_t const * st_vibro_effect_fn(void)
+sox_effect_t const * sox_vibro_effect_fn(void)
 {
-  static st_effect_t driver = {
-    "vibro", "Usage: vibro speed [depth]", ST_EFF_MCHAN,
-    getopts, st_synth_start, st_synth_flow, 0, 0, 0,
+  static sox_effect_t driver = {
+    "vibro", "Usage: vibro speed [depth]", SOX_EFF_MCHAN,
+    getopts, sox_synth_start, sox_synth_flow, 0, 0, 0,
   };
   return &driver;
 }
--- a/src/voc.c
+++ b/src/voc.c
@@ -20,7 +20,7 @@
  * For sox-12-17 by Annonymous (see notes ANN)
  * Added comments and notes for each procedure.
  * Fixed so this now works with pipes, input does not have to
- * be seekable anymore (in st_vocstartread() )
+ * be seekable anymore (in sox_vocstartread() )
  * Added support for uLAW and aLaw (aLaw not tested).
  * Fixed support of multi-part VOC files, and files with
  * block 9 but no audio in the block....
@@ -157,7 +157,7 @@
 
 ------------------------------------------------------------------------*/
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "g711.h"
 #include <string.h>
 
@@ -202,16 +202,16 @@
 static void blockstart(ft_t);
 
 /* Conversion macros (from raw.c) */
-#define ST_ALAW_BYTE_TO_SAMPLE(d) ((st_sample_t)(st_alaw2linear16(d)) << 16)
-#define ST_ULAW_BYTE_TO_SAMPLE(d) ((st_sample_t)(st_ulaw2linear16(d)) << 16)
+#define SOX_ALAW_BYTE_TO_SAMPLE(d) ((sox_sample_t)(sox_alaw2linear16(d)) << 16)
+#define SOX_ULAW_BYTE_TO_SAMPLE(d) ((sox_sample_t)(sox_ulaw2linear16(d)) << 16)
 
 /* public VOC functions for SOX */
 /*-----------------------------------------------------------------
- * st_vocstartread() -- start reading a VOC file
+ * sox_vocstartread() -- start reading a VOC file
  *-----------------------------------------------------------------*/
-static int st_vocstartread(ft_t ft)
+static int sox_vocstartread(ft_t ft)
 {
-        int rtn = ST_SUCCESS;
+        int rtn = SOX_SUCCESS;
         char header[20];
         vs_t v = (vs_t) ft->priv;
         unsigned short sbseek;
@@ -219,25 +219,25 @@
         int ii;  /* for getting rid of lseek */
         unsigned char uc;
 
-        if (st_readbuf(ft, header, 1, 20) != 20)
+        if (sox_readbuf(ft, header, 1, 20) != 20)
         {
-                st_fail_errno(ft,ST_EHDR,"unexpected EOF in VOC header");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"unexpected EOF in VOC header");
+                return(SOX_EOF);
         }
         if (strncmp(header, "Creative Voice File\032", 19))
         {
-                st_fail_errno(ft,ST_EHDR,"VOC file header incorrect");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"VOC file header incorrect");
+                return(SOX_EOF);
         }
 
         /* read the offset to data, from start of file */
         /* after this read we have read 20 bytes of header + 2 */
-        st_readw(ft, &sbseek);
+        sox_readw(ft, &sbseek);
 
         /* ANN:  read to skip the header, instead of lseek */
         /* this should allow use with pipes.... */
         for (ii=22; ii<sbseek; ii++)
-            st_readb(ft, &uc);
+            sox_readb(ft, &uc);
 
         v->rate = -1;
         v->rest = 0;
@@ -253,8 +253,8 @@
         /* get rate of data */
         if (v->rate == -1)
         {
-                st_fail_errno(ft,ST_EOF,"Input .voc file had no sound!");
-                return(ST_EOF);
+                sox_fail_errno(ft,SOX_EOF,"Input .voc file had no sound!");
+                return(SOX_EOF);
         }
 
         /* setup word length of data */
@@ -263,36 +263,36 @@
         /* ANN:  Check VOC format and map to the proper ST format value */
         switch (v->format) {
         case VOC_FMT_LIN8U:      /*     0    8 bit unsigned linear PCM */
-            ft->signal.encoding = ST_ENCODING_UNSIGNED;
+            ft->signal.encoding = SOX_ENCODING_UNSIGNED;
             break;
         case VOC_FMT_CRLADPCM4:  /*     1    Creative 8-bit to 4-bit ADPCM */
-            st_fail ("Unsupported VOC format CRLADPCM4 %d", v->format);
-            rtn=ST_EOF;
+            sox_fail ("Unsupported VOC format CRLADPCM4 %d", v->format);
+            rtn=SOX_EOF;
             break;
         case VOC_FMT_CRLADPCM3:  /*     2    Creative 8-bit to 3-bit ADPCM */
-            st_fail ("Unsupported VOC format CRLADPCM3 %d", v->format);
-            rtn=ST_EOF;
+            sox_fail ("Unsupported VOC format CRLADPCM3 %d", v->format);
+            rtn=SOX_EOF;
             break;
         case VOC_FMT_CRLADPCM2:  /*     3    Creative 8-bit to 2-bit ADPCM */
-            st_fail ("Unsupported VOC format CRLADPCM2 %d", v->format);
-            rtn=ST_EOF;
+            sox_fail ("Unsupported VOC format CRLADPCM2 %d", v->format);
+            rtn=SOX_EOF;
             break;
         case VOC_FMT_LIN16:      /*     4    16-bit signed PCM */
-            ft->signal.encoding = ST_ENCODING_SIGN2;
+            ft->signal.encoding = SOX_ENCODING_SIGN2;
             break;
         case VOC_FMT_ALAW:       /*     6    CCITT a-Law 8-bit PCM */
-            ft->signal.encoding = ST_ENCODING_ALAW;
+            ft->signal.encoding = SOX_ENCODING_ALAW;
             break;
         case VOC_FMT_MU255:      /*     7    CCITT u-Law 8-bit PCM */
-            ft->signal.encoding = ST_ENCODING_ULAW;
+            ft->signal.encoding = SOX_ENCODING_ULAW;
             break;
         case VOC_FMT_CRLADPCM4A: /*0x200    Creative 16-bit to 4-bit ADPCM */
-            st_fail ("Unsupported VOC format CRLADPCM4A %d", v->format);
-            rtn=ST_EOF;
+            sox_fail ("Unsupported VOC format CRLADPCM4A %d", v->format);
+            rtn=SOX_EOF;
             break;
         default:
-            st_fail ("Unknown VOC format %d", v->format);
-            rtn=ST_EOF;
+            sox_fail ("Unknown VOC format %d", v->format);
+            rtn=SOX_EOF;
             break;
         }
 
@@ -300,18 +300,18 @@
         if (ft->signal.channels == 0)
                 ft->signal.channels = v->channels;
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*-----------------------------------------------------------------
- * st_vocread() -- read data from a VOC file
+ * sox_vocread() -- read data from a VOC file
  * ANN:  Major changes here to support multi-part files and files
  *       that do not have audio in block 9's.
  *-----------------------------------------------------------------*/
-static st_size_t st_vocread(ft_t ft, st_sample_t *buf, st_size_t len)
+static sox_size_t sox_vocread(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
         vs_t v = (vs_t) ft->priv;
-        st_size_t done = 0;
+        sox_size_t done = 0;
         int rc = 0;
         int16_t sw;
         unsigned char  uc;
@@ -360,9 +360,9 @@
 
                 /* Read the data in the file */
                 switch(v->size) {
-                case ST_SIZE_BYTE:
-                    if (st_readb(ft, &uc) == ST_EOF) {
-                        st_warn("VOC input: short file");
+                case SOX_SIZE_BYTE:
+                    if (sox_readb(ft, &uc) == SOX_EOF) {
+                        sox_warn("VOC input: short file");
                         v->rest = 0;
                         return done;
                     }
@@ -369,22 +369,22 @@
                     /* IF uLaw,alaw, expand to linear, else convert??? */
                     /* ANN:  added uLaw and aLaw support */
                     if (v->format == VOC_FMT_MU255) {
-                        *buf++ =  ST_ULAW_BYTE_TO_SAMPLE(uc);
+                        *buf++ =  SOX_ULAW_BYTE_TO_SAMPLE(uc);
                     } else if (v->format == VOC_FMT_ALAW) {
-                        *buf++ =  ST_ALAW_BYTE_TO_SAMPLE(uc);
+                        *buf++ =  SOX_ALAW_BYTE_TO_SAMPLE(uc);
                     } else {
-                        *buf++ = ST_UNSIGNED_BYTE_TO_SAMPLE(uc,);
+                        *buf++ = SOX_UNSIGNED_BYTE_TO_SAMPLE(uc,);
                     }
                     break;
-                case ST_SIZE_16BIT:
-                    st_readw(ft, (unsigned short *)&sw);
-                    if (st_eof(ft))
+                case SOX_SIZE_16BIT:
+                    sox_readw(ft, (unsigned short *)&sw);
+                    if (sox_eof(ft))
                         {
-                            st_warn("VOC input: short file");
+                            sox_warn("VOC input: short file");
                             v->rest = 0;
                             return done;
                         }
-                    *buf++ = ST_SIGNED_WORD_TO_SAMPLE(sw,);
+                    *buf++ = SOX_SIGNED_WORD_TO_SAMPLE(sw,);
                     v->rest--; /* Processed 2 bytes so update */
                     break;
                 }
@@ -409,44 +409,44 @@
  * which will work with the oldest software (eg. an 8-bit mono sample
  * will be able to be played with a really old SB VOC player.)
  */
-static int st_vocstartwrite(ft_t ft)
+static int sox_vocstartwrite(ft_t ft)
 {
         vs_t v = (vs_t) ft->priv;
 
         if (! ft->seekable)
         {
-                st_fail_errno(ft,ST_EOF,
+                sox_fail_errno(ft,SOX_EOF,
                               "Output .voc file must be a file, not a pipe");
-                return(ST_EOF);
+                return(SOX_EOF);
         }
 
         v->samples = 0;
 
         /* File format name and a ^Z (aborts printing under DOS) */
-        st_writes(ft, "Creative Voice File\032");
-        st_writew(ft, 26);                      /* size of header */
-        st_writew(ft, 0x10a);              /* major/minor version number */
-        st_writew(ft, 0x1129);          /* checksum of version number */
+        sox_writes(ft, "Creative Voice File\032");
+        sox_writew(ft, 26);                      /* size of header */
+        sox_writew(ft, 0x10a);              /* major/minor version number */
+        sox_writew(ft, 0x1129);          /* checksum of version number */
 
-        if (ft->signal.size == ST_SIZE_BYTE)
-          ft->signal.encoding = ST_ENCODING_UNSIGNED;
+        if (ft->signal.size == SOX_SIZE_BYTE)
+          ft->signal.encoding = SOX_ENCODING_UNSIGNED;
         else
-          ft->signal.encoding = ST_ENCODING_SIGN2;
+          ft->signal.encoding = SOX_ENCODING_SIGN2;
         if (ft->signal.channels == 0)
                 ft->signal.channels = 1;
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*-----------------------------------------------------------------
- * st_vocwrite() -- write a VOC file
+ * sox_vocwrite() -- write a VOC file
  *-----------------------------------------------------------------*/
-static st_size_t st_vocwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static sox_size_t sox_vocwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
         vs_t v = (vs_t) ft->priv;
         unsigned char uc;
         int16_t sw;
-        st_size_t done = 0;
+        sox_size_t done = 0;
 
         if (v->samples == 0) {
           /* No silence packing yet. */
@@ -455,12 +455,12 @@
         }
         v->samples += len;
         while(done < len) {
-          if (ft->signal.size == ST_SIZE_BYTE) {
-            uc = ST_SAMPLE_TO_UNSIGNED_BYTE(*buf++, ft->clips);
-            st_writeb(ft, uc);
+          if (ft->signal.size == SOX_SIZE_BYTE) {
+            uc = SOX_SAMPLE_TO_UNSIGNED_BYTE(*buf++, ft->clips);
+            sox_writeb(ft, uc);
           } else {
-            sw = (int) ST_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips);
-            st_writew(ft,sw);
+            sw = (int) SOX_SAMPLE_TO_SIGNED_WORD(*buf++, ft->clips);
+            sox_writew(ft,sw);
           }
           done++;
         }
@@ -474,36 +474,36 @@
 static void blockstop(ft_t ft)
 {
         vs_t v = (vs_t) ft->priv;
-        st_sample_t datum;
+        sox_sample_t datum;
 
-        st_writeb(ft, 0);                     /* End of file block code */
-        st_seeki(ft, v->blockseek, 0);         /* seek back to block length */
-        st_seeki(ft, 1, 1);                    /* seek forward one */
+        sox_writeb(ft, 0);                     /* End of file block code */
+        sox_seeki(ft, v->blockseek, 0);         /* seek back to block length */
+        sox_seeki(ft, 1, 1);                    /* seek forward one */
         if (v->silent) {
-                st_writew(ft, v->samples);
+                sox_writew(ft, v->samples);
         } else {
-          if (ft->signal.size == ST_SIZE_BYTE) {
+          if (ft->signal.size == SOX_SIZE_BYTE) {
             if (ft->signal.channels > 1) {
-              st_seeki(ft, 8, 1); /* forward 7 + 1 for new block header */
+              sox_seeki(ft, 8, 1); /* forward 7 + 1 for new block header */
             }
           }
                 v->samples += 2;                /* adjustment: SBDK pp. 3-5 */
                 datum = (v->samples * ft->signal.size) & 0xff;
-                st_writeb(ft, (int)datum);       /* low byte of length */
+                sox_writeb(ft, (int)datum);       /* low byte of length */
                 datum = ((v->samples * ft->signal.size) >> 8) & 0xff;
-                st_writeb(ft, (int)datum);  /* middle byte of length */
+                sox_writeb(ft, (int)datum);  /* middle byte of length */
                 datum = ((v->samples  * ft->signal.size)>> 16) & 0xff;
-                st_writeb(ft, (int)datum); /* high byte of length */
+                sox_writeb(ft, (int)datum); /* high byte of length */
         }
 }
 
 /*-----------------------------------------------------------------
- * st_vocstopwrite() -- stop writing a VOC file
+ * sox_vocstopwrite() -- stop writing a VOC file
  *-----------------------------------------------------------------*/
-static int st_vocstopwrite(ft_t ft)
+static int sox_vocstopwrite(ft_t ft)
 {
         blockstop(ft);
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
 /*-----------------------------------------------------------------
@@ -529,30 +529,30 @@
         while (v->rest == 0) {
                 /* IF EOF, return EOF
                  * ANN:  was returning SUCCESS */
-                if (st_eof(ft))
-                        return ST_EOF;
+                if (sox_eof(ft))
+                        return SOX_EOF;
 
-                if (st_readb(ft, &block) == ST_EOF)
-                        return ST_EOF;
+                if (sox_readb(ft, &block) == SOX_EOF)
+                        return SOX_EOF;
 
                 /* IF TERM block (end of file), return EOF */
                 if (block == VOC_TERM)
-                        return ST_EOF;
+                        return SOX_EOF;
 
                 /* IF EOF after reading block type, return EOF
                  * ANN:  was returning SUCCESS */
-                if (st_eof(ft))
-                        return ST_EOF;
+                if (sox_eof(ft))
+                        return SOX_EOF;
                 /*
                  * Size is an 24-bit value.  Currently there is no util
                  * func to read this so do it this cross-platform way
                  *
                  */
-                st_readb(ft, &uc);
+                sox_readb(ft, &uc);
                 sblen = uc;
-                st_readb(ft, &uc);
+                sox_readb(ft, &uc);
                 sblen |= ((uint32_t) uc) << 8;
-                st_readb(ft, &uc);
+                sox_readb(ft, &uc);
                 sblen |= ((uint32_t) uc) << 16;
 
                 /* Based on VOC block type, process the block */
@@ -559,88 +559,88 @@
                 /* audio may be in one or multiple blocks */
                 switch(block) {
                 case VOC_DATA:
-                        st_readb(ft, &uc);
+                        sox_readb(ft, &uc);
                         /* When DATA block preceeded by an EXTENDED     */
                         /* block, the DATA blocks rate value is invalid */
                         if (!v->extended) {
                           if (uc == 0)
                           {
-                            st_fail_errno(ft,ST_EFMT,
+                            sox_fail_errno(ft,SOX_EFMT,
                               "File %s: Sample rate is zero?");
-                            return(ST_EOF);
+                            return(SOX_EOF);
                           }
                           if ((v->rate != -1) && (uc != v->rate))
                           {
-                            st_fail_errno(ft,ST_EFMT,
+                            sox_fail_errno(ft,SOX_EFMT,
                               "File %s: sample rate codes differ: %d != %d",
                                  ft->filename,v->rate, uc);
-                            return(ST_EOF);
+                            return(SOX_EOF);
                           }
                           v->rate = uc;
                           ft->signal.rate = 1000000.0/(256 - v->rate);
                           v->channels = 1;
                         }
-                        st_readb(ft, &uc);
+                        sox_readb(ft, &uc);
                         if (uc != 0)
                         {
-                          st_fail_errno(ft,ST_EFMT,
+                          sox_fail_errno(ft,SOX_EFMT,
                             "File %s: only interpret 8-bit data!",
                                ft->filename);
-                          return(ST_EOF);
+                          return(SOX_EOF);
                         }
                         v->extended = 0;
                         v->rest = sblen - 2;
-                        v->size = ST_SIZE_BYTE;
-                        return (ST_SUCCESS);
+                        v->size = SOX_SIZE_BYTE;
+                        return (SOX_SUCCESS);
                 case VOC_DATA_16:
-                        st_readdw(ft, &new_rate_32);
+                        sox_readdw(ft, &new_rate_32);
                         if (new_rate_32 == 0)
                         {
-                            st_fail_errno(ft,ST_EFMT,
+                            sox_fail_errno(ft,SOX_EFMT,
                               "File %s: Sample rate is zero?",ft->filename);
-                            return(ST_EOF);
+                            return(SOX_EOF);
                         }
                         if ((v->rate != -1) && ((long)new_rate_32 != v->rate))
                         {
-                            st_fail_errno(ft,ST_EFMT,
+                            sox_fail_errno(ft,SOX_EFMT,
                               "File %s: sample rate codes differ: %d != %d",
                                 ft->filename, v->rate, new_rate_32);
-                            return(ST_EOF);
+                            return(SOX_EOF);
                         }
                         v->rate = new_rate_32;
                         ft->signal.rate = new_rate_32;
-                        st_readb(ft, &uc);
+                        sox_readb(ft, &uc);
                         switch (uc)
                         {
-                            case 8:     v->size = ST_SIZE_BYTE; break;
-                            case 16:    v->size = ST_SIZE_16BIT; break;
+                            case 8:     v->size = SOX_SIZE_BYTE; break;
+                            case 16:    v->size = SOX_SIZE_16BIT; break;
                             default:
-                                st_fail_errno(ft,ST_EFMT,
+                                sox_fail_errno(ft,SOX_EFMT,
                                               "Don't understand size %d", uc);
-                                return(ST_EOF);
+                                return(SOX_EOF);
                         }
-                        st_readb(ft, &(v->channels));
-                        st_readw(ft, &(v->format));  /* ANN: added format */
-                        st_readb(ft, (unsigned char *)&trash); /* notused */
-                        st_readb(ft, (unsigned char *)&trash); /* notused */
-                        st_readb(ft, (unsigned char *)&trash); /* notused */
-                        st_readb(ft, (unsigned char *)&trash); /* notused */
+                        sox_readb(ft, &(v->channels));
+                        sox_readw(ft, &(v->format));  /* ANN: added format */
+                        sox_readb(ft, (unsigned char *)&trash); /* notused */
+                        sox_readb(ft, (unsigned char *)&trash); /* notused */
+                        sox_readb(ft, (unsigned char *)&trash); /* notused */
+                        sox_readb(ft, (unsigned char *)&trash); /* notused */
                         v->rest = sblen - 12;
-                        return (ST_SUCCESS);
+                        return (SOX_SUCCESS);
                 case VOC_CONT:
                         v->rest = sblen;
-                        return (ST_SUCCESS);
+                        return (SOX_SUCCESS);
                 case VOC_SILENCE:
                         {
                         unsigned short period;
 
-                        st_readw(ft, &period);
-                        st_readb(ft, &uc);
+                        sox_readw(ft, &period);
+                        sox_readb(ft, &uc);
                         if (uc == 0)
                         {
-                                st_fail_errno(ft,ST_EFMT,
+                                sox_fail_errno(ft,SOX_EFMT,
                                   "File %s: Silence sample rate is zero");
-                                return(ST_EOF);
+                                return(SOX_EOF);
                         }
                         /*
                          * Some silence-packed files have gratuitously
@@ -653,11 +653,11 @@
                                 v->rate = uc;
                         v->rest = period;
                         v->silent = 1;
-                        return (ST_SUCCESS);
+                        return (SOX_SUCCESS);
                         }
                 case VOC_MARKER:
-                        st_readb(ft, &uc);
-                        st_readb(ft, &uc);
+                        sox_readb(ft, &uc);
+                        sox_readb(ft, &uc);
                         /* Falling! Falling! */
                 case VOC_TEXT:
                         { 
@@ -672,7 +672,7 @@
 
                           while (i--)
                           {
-                            st_readb(ft, (unsigned char *)&c);
+                            sox_readb(ft, (unsigned char *)&c);
                             /* FIXME: this needs to be tested but I couldn't
                              * find a voc file with a VOC_TEXT chunk :(
                             if (c != '\0' && c != '\r')
@@ -680,7 +680,7 @@
                             if (len && (c == '\0' || c == '\r' ||
                                 i == 0 || len == sizeof(line_buf) - 1))
                             {
-                              st_report("%s", line_buf);
+                              sox_report("%s", line_buf);
                               line_buf[len] = '\0';
                               len = 0;
                             }
@@ -690,9 +690,9 @@
                         continue;       /* get next block */
                 case VOC_LOOP:
                 case VOC_LOOPEND:
-                        st_debug("File %s: skipping repeat loop");
+                        sox_debug("File %s: skipping repeat loop");
                         for(i = 0; i < sblen; i++)
-                            st_readb(ft, (unsigned char *)&trash);
+                            sox_readb(ft, (unsigned char *)&trash);
                         break;
                 case VOC_EXTENDED:
                         /* An Extended block is followed by a data block */
@@ -700,30 +700,30 @@
                         /* value from the extended block and not the     */
                         /* data block.                                   */
                         v->extended = 1;
-                        st_readw(ft, &new_rate_16);
+                        sox_readw(ft, &new_rate_16);
                         if (new_rate_16 == 0)
                         {
-                           st_fail_errno(ft,ST_EFMT,
+                           sox_fail_errno(ft,SOX_EFMT,
                              "File %s: Sample rate is zero?");
-                           return(ST_EOF);
+                           return(SOX_EOF);
                         }
                         if ((v->rate != -1) && (new_rate_16 != v->rate))
                         {
-                           st_fail_errno(ft,ST_EFMT,
+                           sox_fail_errno(ft,SOX_EFMT,
                              "File %s: sample rate codes differ: %d != %d",
                                         ft->filename, v->rate, new_rate_16);
-                           return(ST_EOF);
+                           return(SOX_EOF);
                         }
                         v->rate = new_rate_16;
-                        st_readb(ft, &uc);
+                        sox_readb(ft, &uc);
                         if (uc != 0)
                         {
-                                st_fail_errno(ft,ST_EFMT,
+                                sox_fail_errno(ft,SOX_EFMT,
                                   "File %s: only interpret 8-bit data!",
                                         ft->filename);
-                                return(ST_EOF);
+                                return(SOX_EOF);
                         }
-                        st_readb(ft, &uc);
+                        sox_readb(ft, &uc);
                         if (uc)
                                 ft->signal.channels = 2;  /* Stereo */
                         /* Needed number of channels before finishing
@@ -735,13 +735,13 @@
                         /* can be grabed.                               */
                         continue;
                 default:
-                        st_debug("File %s: skipping unknown block code %d",
+                        sox_debug("File %s: skipping unknown block code %d",
                                 ft->filename, block);
                         for(i = 0; i < sblen; i++)
-                            st_readb(ft, (unsigned char *)&trash);
+                            sox_readb(ft, (unsigned char *)&trash);
                 }
         }
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
 }
 
 /*-----------------------------------------------------------------
@@ -751,14 +751,14 @@
 {
         vs_t v = (vs_t) ft->priv;
 
-        v->blockseek = st_tell(ft);
+        v->blockseek = sox_tell(ft);
         if (v->silent) {
-                st_writeb(ft, VOC_SILENCE);     /* Silence block code */
-                st_writeb(ft, 0);               /* Period length */
-                st_writeb(ft, 0);               /* Period length */
-                st_writeb(ft, v->rate);         /* Rate code */
+                sox_writeb(ft, VOC_SILENCE);     /* Silence block code */
+                sox_writeb(ft, 0);               /* Period length */
+                sox_writeb(ft, 0);               /* Period length */
+                sox_writeb(ft, v->rate);         /* Rate code */
         } else {
-          if (ft->signal.size == ST_SIZE_BYTE) {
+          if (ft->signal.size == SOX_SIZE_BYTE) {
             /* 8-bit sample section.  By always setting the correct     */
             /* rate value in the DATA block (even when its preceeded    */
             /* by an EXTENDED block) old software can still play stereo */
@@ -766,36 +766,36 @@
             /* Prehaps the rate should be doubled though to make up for */
             /* double amount of samples for a given time????            */
             if (ft->signal.channels > 1) {
-              st_writeb(ft, VOC_EXTENDED);      /* Voice Extended block code */
-              st_writeb(ft, 4);                /* block length = 4 */
-              st_writeb(ft, 0);                /* block length = 4 */
-              st_writeb(ft, 0);                /* block length = 4 */
+              sox_writeb(ft, VOC_EXTENDED);      /* Voice Extended block code */
+              sox_writeb(ft, 4);                /* block length = 4 */
+              sox_writeb(ft, 0);                /* block length = 4 */
+              sox_writeb(ft, 0);                /* block length = 4 */
                   v->rate = 65536 - (256000000.0/(2*(float)ft->signal.rate));
-              st_writew(ft,v->rate);    /* Rate code */
-              st_writeb(ft, 0);         /* File is not packed */
-              st_writeb(ft, 1);         /* samples are in stereo */
+              sox_writew(ft,v->rate);    /* Rate code */
+              sox_writeb(ft, 0);         /* File is not packed */
+              sox_writeb(ft, 1);         /* samples are in stereo */
             }
-            st_writeb(ft, VOC_DATA);    /* Voice Data block code */
-            st_writeb(ft, 0);           /* block length (for now) */
-            st_writeb(ft, 0);           /* block length (for now) */
-            st_writeb(ft, 0);           /* block length (for now) */
+            sox_writeb(ft, VOC_DATA);    /* Voice Data block code */
+            sox_writeb(ft, 0);           /* block length (for now) */
+            sox_writeb(ft, 0);           /* block length (for now) */
+            sox_writeb(ft, 0);           /* block length (for now) */
             v->rate = 256 - (1000000.0/(float)ft->signal.rate);
-            st_writeb(ft, (int) v->rate);/* Rate code */
-            st_writeb(ft, 0);           /* 8-bit raw data */
+            sox_writeb(ft, (int) v->rate);/* Rate code */
+            sox_writeb(ft, 0);           /* 8-bit raw data */
         } else {
-            st_writeb(ft, VOC_DATA_16); /* Voice Data block code */
-            st_writeb(ft, 0);           /* block length (for now) */
-            st_writeb(ft, 0);           /* block length (for now) */
-            st_writeb(ft, 0);           /* block length (for now) */
+            sox_writeb(ft, VOC_DATA_16); /* Voice Data block code */
+            sox_writeb(ft, 0);           /* block length (for now) */
+            sox_writeb(ft, 0);           /* block length (for now) */
+            sox_writeb(ft, 0);           /* block length (for now) */
             v->rate = ft->signal.rate;
-            st_writedw(ft, v->rate);    /* Rate code */
-            st_writeb(ft, 16);          /* Sample Size */
-            st_writeb(ft, ft->signal.channels);   /* Sample Size */
-            st_writew(ft, 0x0004);      /* Encoding */
-            st_writeb(ft, 0);           /* Unused */
-            st_writeb(ft, 0);           /* Unused */
-            st_writeb(ft, 0);           /* Unused */
-            st_writeb(ft, 0);           /* Unused */
+            sox_writedw(ft, v->rate);    /* Rate code */
+            sox_writeb(ft, 16);          /* Sample Size */
+            sox_writeb(ft, ft->signal.channels);   /* Sample Size */
+            sox_writew(ft, 0x0004);      /* Encoding */
+            sox_writeb(ft, 0);           /* Unused */
+            sox_writeb(ft, 0);           /* Unused */
+            sox_writeb(ft, 0);           /* Unused */
+            sox_writeb(ft, 0);           /* Unused */
           }
         }
 }
@@ -806,20 +806,20 @@
   NULL
 };
 
-static st_format_t st_voc_format = {
+static sox_format_t sox_voc_format = {
   vocnames,
   NULL,
-  ST_FILE_LIT_END,
-  st_vocstartread,
-  st_vocread,
-  st_format_nothing,
-  st_vocstartwrite,
-  st_vocwrite,
-  st_vocstopwrite,
-  st_format_nothing_seek
+  SOX_FILE_LIT_END,
+  sox_vocstartread,
+  sox_vocread,
+  sox_format_nothing,
+  sox_vocstartwrite,
+  sox_vocwrite,
+  sox_vocstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_voc_format_fn(void)
+const sox_format_t *sox_voc_format_fn(void)
 {
-    return &st_voc_format;
+    return &sox_voc_format;
 }
--- a/src/vol.c
+++ b/src/vol.c
@@ -13,7 +13,7 @@
   "\tThe peak limiter has a gain much less than 1 (e.g. 0.05 or 0.02) and is\n" \
   "\tonly used on peaks (to prevent clipping); default is no limiter."
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <math.h>   /* exp(), sqrt() */
 
@@ -22,7 +22,7 @@
 typedef struct {
     double gain; /* amplitude gain. */
     
-    st_bool uselimiter;
+    sox_bool uselimiter;
     double limiterthreshhold;
     double limitergain;
     int limited; /* number of limited values to report. */
@@ -49,11 +49,11 @@
   unsigned have_type;
 
   vol->gain = 1;       /* Default is no change. */
-  vol->uselimiter = st_false; /* Default is no limiter. */
+  vol->uselimiter = sox_false; /* Default is no limiter. */
   
   if (!n || (have_type = sscanf(argv[0], "%lf %10s %c", &vol->gain, string, &dummy) - 1) > 1) {
-    st_fail(effp->h->usage);
-    return ST_EOF;
+    sox_fail(effp->h->usage);
+    return SOX_EOF;
   }
   ++argv, --n;
 
@@ -66,8 +66,8 @@
   if (have_type) {
     enum_item const * p = find_enum_text(q, vol_types);
     if (!p) {
-      st_fail(effp->h->usage);
-      return ST_EOF;
+      sox_fail(effp->h->usage);
+      return SOX_EOF;
     }
     switch (p->value) {
       case VOL_dB: vol->gain = exp(vol->gain*LOG_10_20); break;
@@ -79,21 +79,21 @@
 
   if (n) {
     if (fabs(vol->gain) < 1 || sscanf(*argv, "%lf %c", &vol->limitergain, &dummy) != 1 || vol->limitergain <= 0 || vol->limitergain >= 1) {
-      st_fail(effp->h->usage);
-      return ST_EOF;                  
+      sox_fail(effp->h->usage);
+      return SOX_EOF;                  
     }
     
-    vol->uselimiter = st_true;
+    vol->uselimiter = sox_true;
     /* The following equation is derived so that there is no 
      * discontinuity in output amplitudes */
-    /* and a ST_SAMPLE_MAX input always maps to a ST_SAMPLE_MAX output 
+    /* and a SOX_SAMPLE_MAX input always maps to a SOX_SAMPLE_MAX output 
      * when the limiter is activated. */
     /* (NOTE: There **WILL** be a discontinuity in the slope 
      * of the output amplitudes when using the limiter.) */
-    vol->limiterthreshhold = ST_SAMPLE_MAX * (1.0 - vol->limitergain) / (fabs(vol->gain) - vol->limitergain);
+    vol->limiterthreshhold = SOX_SAMPLE_MAX * (1.0 - vol->limitergain) / (fabs(vol->gain) - vol->limitergain);
   }
-  st_debug("mult=%g limit=%g", vol->gain, vol->limitergain);
-  return ST_SUCCESS;
+  sox_debug("mult=%g limit=%g", vol->gain, vol->limitergain);
+  return SOX_SUCCESS;
 }
 
 /*
@@ -104,37 +104,37 @@
     vol_t vol = (vol_t) effp->priv;
     
     if (vol->gain == 1)
-      return ST_EFF_NULL;
+      return SOX_EFF_NULL;
 
     if (effp->outinfo.channels != effp->ininfo.channels) {
-        st_fail("vol cannot handle different channels (in %d, out %d)"
+        sox_fail("vol cannot handle different channels (in %d, out %d)"
              " use avg or pan", effp->ininfo.channels, effp->outinfo.channels);
-        return ST_EOF;
+        return SOX_EOF;
     }
 
     if (effp->outinfo.rate != effp->ininfo.rate) {
-        st_fail("vol cannot handle different rates (in %ld, out %ld)"
+        sox_fail("vol cannot handle different rates (in %ld, out %ld)"
              " use resample", effp->ininfo.rate, effp->outinfo.rate);
-        return ST_EOF;
+        return SOX_EOF;
     }
 
     vol->limited = 0;
     vol->totalprocessed = 0;
 
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
  * Process data.
  */
-static int flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf, 
-                st_size_t *isamp, st_size_t *osamp)
+static int flow(eff_t effp, const sox_sample_t *ibuf, sox_sample_t *obuf, 
+                sox_size_t *isamp, sox_size_t *osamp)
 {
     vol_t vol = (vol_t) effp->priv;
     register double gain = vol->gain;
     register double limiterthreshhold = vol->limiterthreshhold;
     register double sample;
-    register st_size_t len;
+    register sox_size_t len;
     
     len = min(*osamp, *isamp);
 
@@ -151,24 +151,24 @@
                 
                 if (sample > limiterthreshhold)
                 {
-                        sample =  (ST_SAMPLE_MAX - vol->limitergain * (ST_SAMPLE_MAX - sample));
+                        sample =  (SOX_SAMPLE_MAX - vol->limitergain * (SOX_SAMPLE_MAX - sample));
                         vol->limited++;
                 }
                 else if (sample < -limiterthreshhold)
                 {
-                        sample = -(ST_SAMPLE_MAX - vol->limitergain * (ST_SAMPLE_MAX + sample));
+                        sample = -(SOX_SAMPLE_MAX - vol->limitergain * (SOX_SAMPLE_MAX + sample));
                         /* FIXME: MIN is (-MAX)-1 so need to make sure we
                          * don't go over that.  Probably could do this
                          * check inside the above equation but I didn't
                          * think it thru.
                          */
-                        if (sample < ST_SAMPLE_MIN)
-                            sample = ST_SAMPLE_MIN;
+                        if (sample < SOX_SAMPLE_MIN)
+                            sample = SOX_SAMPLE_MIN;
                         vol->limited++;
                 } else
                         sample = gain * sample;
 
-                ST_SAMPLE_CLIP_COUNT(sample, effp->clips);
+                SOX_SAMPLE_CLIP_COUNT(sample, effp->clips);
                *obuf++ = sample;
             }
     }
@@ -178,11 +178,11 @@
         for (;len>0; len--)
         {
                 sample = gain * *ibuf++;
-                ST_SAMPLE_CLIP_COUNT(sample, effp->clips);
+                SOX_SAMPLE_CLIP_COUNT(sample, effp->clips);
                 *obuf++ = sample;
         }
     }
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 static int stop(eff_t effp)
@@ -189,16 +189,16 @@
 {
   vol_t vol = (vol_t) effp->priv;
   if (vol->limited) {
-    st_warn("limited %d values (%d percent).", 
+    sox_warn("limited %d values (%d percent).", 
          vol->limited, (int) (vol->limited * 100.0 / vol->totalprocessed));
   }
-  return ST_SUCCESS;
+  return SOX_SUCCESS;
 }
 
-st_effect_t const * st_vol_effect_fn(void)
+sox_effect_t const * sox_vol_effect_fn(void)
 {
-  static st_effect_t driver = {
-    "vol", vol_usage, ST_EFF_MCHAN, getopts, start, flow, 0, stop, 0
+  static sox_effect_t driver = {
+    "vol", vol_usage, SOX_EFF_MCHAN, getopts, start, flow, 0, stop, 0
   };
   return &driver;
 }
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -19,7 +19,7 @@
  * TODO: When reading in comments, it doesn't understand how to read
  * more then one comment and doesn't know how to parse KEY=value.
  */
-#include "st_i.h"
+#include "sox_i.h"
 
 #if defined HAVE_LIBVORBISENC && defined HAVE_LIBVORBISFILE
 #include <stdio.h>
@@ -89,7 +89,7 @@
  *      size and encoding of samples,
  *      mono/stereo/quad.
  */
-static int st_vorbisstartread(ft_t ft)
+static int sox_vorbisstartread(ft_t ft)
 {
         vorbis_t vb = (vorbis_t) ft->priv;
         vorbis_info *vi;
@@ -110,9 +110,9 @@
         /* Init the decoder */
         if (ov_open_callbacks((void *)ft->fp,vb->vf,NULL,0,callbacks) < 0)
         {
-                st_fail_errno(ft,ST_EHDR,
+                sox_fail_errno(ft,SOX_EHDR,
                               "Input not an Ogg Vorbis audio stream");
-                return (ST_EOF);
+                return (SOX_EOF);
         }
 
         /* Get info about the Ogg Vorbis stream */
@@ -121,8 +121,8 @@
 
         /* Record audio info */
         ft->signal.rate = vi->rate;
-        ft->signal.size = ST_SIZE_16BIT;
-        ft->signal.encoding = ST_ENCODING_VORBIS;
+        ft->signal.size = SOX_SIZE_16BIT;
+        ft->signal.encoding = SOX_ENCODING_VORBIS;
         ft->signal.channels = vi->channels;
 
         /* ov_pcm_total doesn't work on non-seekable files so
@@ -168,7 +168,7 @@
         vb->eof = 0;
         vb->current_section = -1;
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 
@@ -191,7 +191,7 @@
                 if (num_read == 0)
                         return (BUF_EOF);
                 else if (num_read == OV_HOLE)
-                        st_warn("Warning: hole in stream; probably harmless");
+                        sox_warn("Warning: hole in stream; probably harmless");
                 else if (num_read < 0)
                         return (BUF_ERROR);
                 else
@@ -210,12 +210,12 @@
  * Return number of samples read.
  */
 
-static st_size_t st_vorbisread(ft_t ft, st_sample_t *buf, st_size_t len)
+static sox_size_t sox_vorbisread(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
         vorbis_t vb = (vorbis_t) ft->priv;
-        st_size_t i;
+        sox_size_t i;
         int ret;
-        st_sample_t l;
+        sox_sample_t l;
 
 
         for(i = 0; i < len; i++) {
@@ -245,7 +245,7 @@
  * Do anything required when you stop reading samples.
  * Don't close input file!
  */
-static int st_vorbisstopread(ft_t ft)
+static int sox_vorbisstopread(ft_t ft)
 {
         vorbis_t vb = (vorbis_t) ft->priv;
 
@@ -252,7 +252,7 @@
         free(vb->buf);
         ov_clear(vb->vf);
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /* Write a page of ogg data to a file.  Taken directly from encode.c in
@@ -260,8 +260,8 @@
 static int oe_write_page(ogg_page *page, ft_t ft)
 {
         int written;
-        written = st_writebuf(ft, page->header,1,page->header_len);
-        written += st_writebuf(ft, page->body,1,page->body_len);
+        written = sox_writebuf(ft, page->header,1,page->header_len);
+        written += sox_writebuf(ft, page->body,1,page->body_len);
 
         return written;
 }
@@ -329,7 +329,7 @@
         return HEADER_OK;
 }
 
-static int st_vorbisstartwrite(ft_t ft)
+static int sox_vorbisstartwrite(ft_t ft)
 {
         vorbis_t vb = (vorbis_t) ft->priv;
         vorbis_enc_t *ve;
@@ -336,8 +336,8 @@
         long rate;
         double quality = 3; /* Default compression quality gives ~112kbps */
 
-        ft->signal.size = ST_SIZE_16BIT;
-        ft->signal.encoding = ST_ENCODING_VORBIS;
+        ft->signal.size = SOX_SIZE_16BIT;
+        ft->signal.encoding = SOX_ENCODING_VORBIS;
 
         /* Allocate memory for all of the structures */
         ve = vb->vorbis_enc_data = (vorbis_enc_t *)xmalloc(sizeof(vorbis_enc_t));
@@ -347,7 +347,7 @@
         /* TODO */
         rate = ft->signal.rate;
         if (rate)
-            st_fail_errno(ft, ST_EHDR, "Error setting up Ogg Vorbis encorder - make sure you've specied a sane rate and number of channels");
+            sox_fail_errno(ft, SOX_EHDR, "Error setting up Ogg Vorbis encorder - make sure you've specied a sane rate and number of channels");
 
         /* Use encoding to average bit rate of VBR as specified by the -C option */
         if (ft->signal.compression != HUGE_VAL)
@@ -354,9 +354,9 @@
         {
             if (ft->signal.compression < -1 || ft->signal.compression > 10)
             {
-                st_fail_errno(ft,ST_EINVAL,
+                sox_fail_errno(ft,SOX_EINVAL,
                               "Vorbis compression quality nust be between -1 and 10");
-                return ST_EOF;
+                return SOX_EOF;
             }
             quality = ft->signal.compression;
         }
@@ -369,21 +369,21 @@
 
         if (write_vorbis_header(ft, ve) == HEADER_ERROR)
         {
-            st_fail_errno(ft,ST_EHDR,
+            sox_fail_errno(ft,SOX_EHDR,
                           "Error writing header for Ogg Vorbis audio stream");
-            return (ST_EOF);
+            return (SOX_EOF);
         }
 
-        return(ST_SUCCESS);
+        return(SOX_SUCCESS);
 }
 
-static st_size_t st_vorbiswrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static sox_size_t sox_vorbiswrite(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
         vorbis_t vb = (vorbis_t) ft->priv;
         vorbis_enc_t *ve = vb->vorbis_enc_data;
-        st_size_t samples = len / ft->signal.channels;
+        sox_size_t samples = len / ft->signal.channels;
         float **buffer = vorbis_analysis_buffer(&ve->vd, samples);
-        st_size_t i, j;
+        sox_size_t i, j;
         int ret;
         int eos = 0;
 
@@ -391,7 +391,7 @@
         for (i = 0; i < samples; i++)
                 for (j = 0; j < ft->signal.channels; j++)
                         buffer[j][i] = buf[i*ft->signal.channels + j]
-                                / ((float)ST_SAMPLE_MAX);
+                                / ((float)SOX_SAMPLE_MAX);
 
         vorbis_analysis_wrote(&ve->vd, samples);
 
@@ -417,7 +417,7 @@
 
                         ret = oe_write_page(&ve->og, ft);
                         if(!ret)
-                            return (ST_EOF);
+                            return (SOX_EOF);
 
                         if(ogg_page_eos(&ve->og))
                             eos = 1;
@@ -428,13 +428,13 @@
         return (len);
 }
 
-static int st_vorbisstopwrite(ft_t ft)
+static int sox_vorbisstopwrite(ft_t ft)
 {
         vorbis_t vb = (vorbis_t) ft->priv;
         vorbis_enc_t *ve = vb->vorbis_enc_data;
 
         /* Close out the remaining data */
-        st_vorbiswrite(ft, NULL, 0);
+        sox_vorbiswrite(ft, NULL, 0);
 
         ogg_stream_clear(&ve->os);
         vorbis_block_clear(&ve->vb);
@@ -441,7 +441,7 @@
         vorbis_dsp_clear(&ve->vd);
         vorbis_info_clear(&ve->vi);
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 static const char *vorbisnames[] = {
@@ -450,21 +450,21 @@
   NULL
 };
 
-static st_format_t st_vorbis_format = {
+static sox_format_t sox_vorbis_format = {
   vorbisnames,
   NULL,
   0,
-  st_vorbisstartread,
-  st_vorbisread,
-  st_vorbisstopread,
-  st_vorbisstartwrite,
-  st_vorbiswrite,
-  st_vorbisstopwrite,
-  st_format_nothing_seek
+  sox_vorbisstartread,
+  sox_vorbisread,
+  sox_vorbisstopread,
+  sox_vorbisstartwrite,
+  sox_vorbiswrite,
+  sox_vorbisstopwrite,
+  sox_format_nothing_seek
 };
 
-const st_format_t *st_vorbis_format_fn(void)
+const sox_format_t *sox_vorbis_format_fn(void)
 {
-    return &st_vorbis_format;
+    return &sox_vorbis_format;
 }
 #endif
--- a/src/vox.c
+++ b/src/vox.c
@@ -10,7 +10,7 @@
  * consequences of using this software.
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "adpcms.h"
 
 /* .vox doesn't need any private state over and above adpcm_io_t, so
@@ -18,38 +18,38 @@
 
 static int vox_start(ft_t ft)
 {
-  return st_adpcm_oki_start(ft, (adpcm_io_t)ft->priv);
+  return sox_adpcm_oki_start(ft, (adpcm_io_t)ft->priv);
 }
 
 static int ima_start(ft_t ft)
 {
-  return st_adpcm_ima_start(ft, (adpcm_io_t)ft->priv);
+  return sox_adpcm_ima_start(ft, (adpcm_io_t)ft->priv);
 }
 
-static st_size_t read(ft_t ft, st_sample_t *buffer, st_size_t len)
+static sox_size_t read(ft_t ft, sox_sample_t *buffer, sox_size_t len)
 {
-  return st_adpcm_read(ft, (adpcm_io_t)ft->priv, buffer, len);
+  return sox_adpcm_read(ft, (adpcm_io_t)ft->priv, buffer, len);
 }
 
 static int stopread(ft_t ft)
 {
-  return st_adpcm_stopread(ft, (adpcm_io_t)ft->priv);
+  return sox_adpcm_stopread(ft, (adpcm_io_t)ft->priv);
 }
 
-static st_size_t write(ft_t ft, const st_sample_t *buffer, st_size_t length)
+static sox_size_t write(ft_t ft, const sox_sample_t *buffer, sox_size_t length)
 {
-  return st_adpcm_write(ft, (adpcm_io_t)ft->priv, buffer, length);
+  return sox_adpcm_write(ft, (adpcm_io_t)ft->priv, buffer, length);
 }
 
 static int stopwrite(ft_t ft)
 {
-  return st_adpcm_stopwrite(ft, (adpcm_io_t)ft->priv);
+  return sox_adpcm_stopwrite(ft, (adpcm_io_t)ft->priv);
 }
 
-const st_format_t *st_vox_format_fn(void)
+const sox_format_t *sox_vox_format_fn(void)
 {
   static char const * names[] = {"vox", NULL};
-  static st_format_t driver = {
+  static sox_format_t driver = {
     names, NULL, 0,
     vox_start,
     read,
@@ -57,15 +57,15 @@
     vox_start,
     write,
     stopwrite,
-    st_format_nothing_seek
+    sox_format_nothing_seek
   };
   return &driver;
 }
 
-const st_format_t *st_ima_format_fn(void)
+const sox_format_t *sox_ima_format_fn(void)
 {
   static char const * names[] = {"ima", NULL};
-  static st_format_t driver = {
+  static sox_format_t driver = {
     names, NULL, 0,
     ima_start,
     read,
@@ -73,7 +73,7 @@
     ima_start,
     write,
     stopwrite,
-    st_format_nothing_seek
+    sox_format_nothing_seek
   };
   return &driver;
 }
--- a/src/wav.c
+++ b/src/wav.c
@@ -19,7 +19,7 @@
 #include <unistd.h>             /* For SEEK_* defines if not found in stdio */
 #endif
 
-#include "st_i.h"
+#include "sox_i.h"
 #include "wav.h"
 #include "ima_rw.h"
 #include "adpcm.h"
@@ -30,17 +30,17 @@
 #endif
 
 /* To allow padding to samplesPerBlock. Works, but currently never true. */
-static st_size_t pad_nsamps = st_false;
+static sox_size_t pad_nsamps = sox_false;
 
 /* Private data for .wav file */
 typedef struct wavstuff {
-    st_size_t      numSamples;     /* samples/channel reading: starts at total count and decremented  */
+    sox_size_t      numSamples;     /* samples/channel reading: starts at total count and decremented  */
                                    /* writing: starts at 0 and counts samples written */
-    st_size_t      dataLength;     /* needed for ADPCM writing */
+    sox_size_t      dataLength;     /* needed for ADPCM writing */
     unsigned short formatTag;      /* What type of encoding file is using */
     unsigned short samplesPerBlock;
     unsigned short blockAlign;
-    st_size_t dataStart;  /* need to for seeking */
+    sox_size_t dataStart;  /* need to for seeking */
     int found_cooledit;   
 
     /* following used by *ADPCM wav files */
@@ -57,7 +57,7 @@
     gsm            gsmhandle;
     gsm_signal     *gsmsample;
     int            gsmindex;
-    st_size_t      gsmbytecount;    /* counts bytes written to data block */
+    sox_size_t      gsmbytecount;    /* counts bytes written to data block */
 } *wav_t;
 
 static char *wav_format_str(unsigned wFormatTag);
@@ -81,7 +81,7 @@
     int samplesThisBlock;
 
     /* Pull in the packet and check the header */
-    bytesRead = st_readbuf(ft, wav->packet, 1, wav->blockAlign);
+    bytesRead = sox_readbuf(ft, wav->packet, 1, wav->blockAlign);
     samplesThisBlock = wav->samplesPerBlock;
     if (bytesRead < wav->blockAlign) 
     { 
@@ -91,7 +91,7 @@
         samplesThisBlock = ImaSamplesIn(0, ft->signal.channels, bytesRead, 0);
         if (samplesThisBlock == 0) 
         {
-            st_warn("Premature EOF on .wav input file");
+            sox_warn("Premature EOF on .wav input file");
             return 0;
         }
     }
@@ -122,7 +122,7 @@
     const char *errmsg;
 
     /* Pull in the packet and check the header */
-    bytesRead = st_readbuf(ft, wav->packet, 1, wav->blockAlign);
+    bytesRead = sox_readbuf(ft, wav->packet, 1, wav->blockAlign);
     samplesThisBlock = wav->samplesPerBlock;
     if (bytesRead < wav->blockAlign) 
     {
@@ -132,7 +132,7 @@
         samplesThisBlock = AdpcmSamplesIn(0, ft->signal.channels, bytesRead, 0);
         if (samplesThisBlock == 0) 
         {
-            st_warn("Premature EOF on .wav input file");
+            sox_warn("Premature EOF on .wav input file");
             return 0;
         }
     }
@@ -140,7 +140,7 @@
     errmsg = AdpcmBlockExpandI(ft->signal.channels, wav->nCoefs, wav->iCoefs, wav->packet, wav->samples, samplesThisBlock);
 
     if (errmsg)
-        st_warn((char*)errmsg);
+        sox_warn((char*)errmsg);
 
     return samplesThisBlock;
 }
@@ -168,10 +168,10 @@
             ImaBlockMashI(chans, wav->samples, wav->samplesPerBlock, wav->state, wav->packet, 9);
         }
         /* write the compressed packet */
-        if (st_writebuf(ft, wav->packet, wav->blockAlign, 1) != 1)
+        if (sox_writebuf(ft, wav->packet, wav->blockAlign, 1) != 1)
         {
-            st_fail_errno(ft,ST_EOF,"write error");
-            return (ST_EOF);
+            sox_fail_errno(ft,SOX_EOF,"write error");
+            return (SOX_EOF);
         }
         /* update lengths and samplePtr */
         wav->dataLength += wav->blockAlign;
@@ -181,7 +181,7 @@
           wav->numSamples += ct/chans;
         wav->samplePtr = wav->samples;
     }
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /****************************************************************************/
@@ -196,18 +196,18 @@
     wav->gsmhandle=gsm_create();
     if (!wav->gsmhandle)
     {
-        st_fail_errno(ft,ST_EOF,"cannot create GSM object");
-        return (ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"cannot create GSM object");
+        return (SOX_EOF);
     }
         
     if(gsm_option(wav->gsmhandle,GSM_OPT_WAV49,&valueP) == -1){
-        st_fail_errno(ft,ST_EOF,"error setting gsm_option for WAV49 format. Recompile gsm library with -DWAV49 option and relink sox");
-        return (ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"error setting gsm_option for WAV49 format. Recompile gsm library with -DWAV49 option and relink sox");
+        return (SOX_EOF);
     }
 
     wav->gsmsample=(gsm_signal*)xmalloc(sizeof(gsm_signal)*160*2);
     wav->gsmindex=0;
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
 /*destroy the gsm object and free the buffer */
@@ -218,7 +218,7 @@
     free(wav->gsmsample);
 }
 
-static st_size_t wavgsmread(ft_t ft, st_sample_t *buf, st_size_t len)
+static sox_size_t wavgsmread(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
     wav_t       wav = (wav_t) ft->priv;
     size_t done=0;
@@ -225,37 +225,37 @@
     int bytes;
     gsm_byte    frame[65];
 
-    ft->st_errno = ST_SUCCESS;
+    ft->sox_errno = SOX_SUCCESS;
 
   /* copy out any samples left from the last call */
     while(wav->gsmindex && (wav->gsmindex<160*2) && (done < len))
-        buf[done++]=ST_SIGNED_WORD_TO_SAMPLE(wav->gsmsample[wav->gsmindex++],);
+        buf[done++]=SOX_SIGNED_WORD_TO_SAMPLE(wav->gsmsample[wav->gsmindex++],);
 
   /* read and decode loop, possibly leaving some samples in wav->gsmsample */
     while (done < len) {
         wav->gsmindex=0;
-        bytes = st_readbuf(ft, frame, 1, 65);   
+        bytes = sox_readbuf(ft, frame, 1, 65);   
         if (bytes <=0)
             return done;
         if (bytes<65) {
-            st_warn("invalid wav gsm frame size: %d bytes",bytes);
+            sox_warn("invalid wav gsm frame size: %d bytes",bytes);
             return done;
         }
         /* decode the long 33 byte half */
         if(gsm_decode(wav->gsmhandle,frame, wav->gsmsample)<0)
         {
-            st_fail_errno(ft,ST_EOF,"error during gsm decode");
+            sox_fail_errno(ft,SOX_EOF,"error during gsm decode");
             return 0;
         }
         /* decode the short 32 byte half */
         if(gsm_decode(wav->gsmhandle,frame+33, wav->gsmsample+160)<0)
         {
-            st_fail_errno(ft,ST_EOF,"error during gsm decode");
+            sox_fail_errno(ft,SOX_EOF,"error during gsm decode");
             return 0;
         }
 
         while ((wav->gsmindex <160*2) && (done < len)){
-            buf[done++]=ST_SIGNED_WORD_TO_SAMPLE(wav->gsmsample[(wav->gsmindex)++],);
+            buf[done++]=SOX_SIGNED_WORD_TO_SAMPLE(wav->gsmsample[(wav->gsmindex)++],);
         }
     }
 
@@ -275,29 +275,29 @@
     gsm_encode(wav->gsmhandle, wav->gsmsample, frame);
     /*encode the odd half long (33 byte) frame */
     gsm_encode(wav->gsmhandle, wav->gsmsample+160, frame+32);
-    if (st_writebuf(ft, frame, 1, 65) != 65)
+    if (sox_writebuf(ft, frame, 1, 65) != 65)
     {
-        st_fail_errno(ft,ST_EOF,"write error");
-        return (ST_EOF);
+        sox_fail_errno(ft,SOX_EOF,"write error");
+        return (SOX_EOF);
     }
     wav->gsmbytecount += 65;
 
     wav->gsmindex = 0;
-    return (ST_SUCCESS);
+    return (SOX_SUCCESS);
 }
 
-static st_size_t wavgsmwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
+static sox_size_t wavgsmwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len)
 {
     wav_t wav = (wav_t) ft->priv;
     size_t done = 0;
     int rc;
 
-    ft->st_errno = ST_SUCCESS;
+    ft->sox_errno = SOX_SUCCESS;
 
     while (done < len) {
         while ((wav->gsmindex < 160*2) && (done < len))
             wav->gsmsample[(wav->gsmindex)++] = 
-                ST_SAMPLE_TO_SIGNED_WORD(buf[done++], ft->clips);
+                SOX_SAMPLE_TO_SIGNED_WORD(buf[done++], ft->clips);
 
         if (wav->gsmindex < 160*2)
             break;
@@ -314,7 +314,7 @@
 {
     wav_t       wav = (wav_t) ft->priv;
 
-    ft->st_errno = ST_SUCCESS;
+    ft->sox_errno = SOX_SUCCESS;
 
     if (wav->gsmindex)
         wavgsmflush(ft);
@@ -321,8 +321,8 @@
 
     /* Add a pad byte if amount of written bytes is not even. */
     if (wav->gsmbytecount && wav->gsmbytecount % 2){
-        if(st_writeb(ft, 0))
-            st_fail_errno(ft,ST_EOF,"write error");
+        if(sox_writeb(ft, 0))
+            sox_fail_errno(ft,SOX_EOF,"write error");
         else
             wav->gsmbytecount += 1;
     }
@@ -333,23 +333,23 @@
 /****************************************************************************/
 /* General Sox WAV file code                                                */
 /****************************************************************************/
-static int findChunk(ft_t ft, const char *Label, st_size_t *len)
+static int findChunk(ft_t ft, const char *Label, sox_size_t *len)
 {
     char magic[5];
     for (;;)
     {
-        if (st_reads(ft, magic, 4) == ST_EOF)
+        if (sox_reads(ft, magic, 4) == SOX_EOF)
         {
-            st_fail_errno(ft, ST_EHDR, "WAVE file has missing %s chunk", 
+            sox_fail_errno(ft, SOX_EHDR, "WAVE file has missing %s chunk", 
                           Label);
-            return ST_EOF;
+            return SOX_EOF;
         }
-        st_debug("WAV Chunk %s", magic);
-        if (st_readdw(ft, len) == ST_EOF)
+        sox_debug("WAV Chunk %s", magic);
+        if (sox_readdw(ft, len) == SOX_EOF)
         {
-            st_fail_errno(ft, ST_EHDR, "WAVE file %s chunk is too short", 
+            sox_fail_errno(ft, SOX_EHDR, "WAVE file %s chunk is too short", 
                           magic);
-            return ST_EOF;
+            return SOX_EOF;
         }
 
         if (strncmp(Label, magic, 4) == 0)
@@ -356,14 +356,14 @@
             break; /* Found the given chunk */
 
         /* skip to next chunk */
-        if (*len == 0 || st_seeki(ft, *len, SEEK_CUR) != ST_SUCCESS)
+        if (*len == 0 || sox_seeki(ft, *len, SEEK_CUR) != SOX_SUCCESS)
         {
-            st_fail_errno(ft,ST_EHDR, 
+            sox_fail_errno(ft,SOX_EHDR, 
                           "WAV chunk appears to have invalid size %d.", *len);
-            return ST_EOF;
+            return SOX_EOF;
         }
     }
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /*
@@ -373,7 +373,7 @@
  *      size and encoding of samples, 
  *      mono/stereo/quad.
  */
-static int st_wavstartread(ft_t ft) 
+static int sox_wavstartread(ft_t ft) 
 {
     wav_t       wav = (wav_t) ft->priv;
     char        magic[5];
@@ -390,55 +390,55 @@
     uint16_t wExtSize = 0;    /* extended field for non-PCM */
 
     uint32_t      dwDataLength;    /* length of sound data in bytes */
-    st_size_t    bytesPerBlock = 0;
+    sox_size_t    bytesPerBlock = 0;
     int    bytespersample;          /* bytes per sample (per channel */
     char text[256];
     uint32_t      dwLoopPos;
 
-        ft->st_errno = ST_SUCCESS;
+        ft->sox_errno = SOX_SUCCESS;
 
-    if (st_reads(ft, magic, 4) == ST_EOF || (strncmp("RIFF", magic, 4) != 0 &&
+    if (sox_reads(ft, magic, 4) == SOX_EOF || (strncmp("RIFF", magic, 4) != 0 &&
                                              strncmp("RIFX", magic, 4) != 0))
     {
-        st_fail_errno(ft,ST_EHDR,"WAVE: RIFF header not found");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"WAVE: RIFF header not found");
+        return SOX_EOF;
     }
 
     /* RIFX is a Big-endian RIFF */
     if (strncmp("RIFX", magic, 4) == 0) 
     {
-        st_debug("Found RIFX header, swapping bytes");
-        ft->signal.reverse_bytes = ST_IS_LITTLEENDIAN;
+        sox_debug("Found RIFX header, swapping bytes");
+        ft->signal.reverse_bytes = SOX_IS_LITTLEENDIAN;
     }
 
-    st_readdw(ft, &dwRiffLength);
+    sox_readdw(ft, &dwRiffLength);
 
-    if (st_reads(ft, magic, 4) == ST_EOF || strncmp("WAVE", magic, 4))
+    if (sox_reads(ft, magic, 4) == SOX_EOF || strncmp("WAVE", magic, 4))
     {
-        st_fail_errno(ft,ST_EHDR,"WAVE header not found");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"WAVE header not found");
+        return SOX_EOF;
     }
 
     /* Now look for the format chunk */
-    if (findChunk(ft, "fmt ", &len) == ST_EOF)
+    if (findChunk(ft, "fmt ", &len) == SOX_EOF)
     {
-        st_fail_errno(ft,ST_EHDR,"WAVE chunk fmt not found");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"WAVE chunk fmt not found");
+        return SOX_EOF;
     }
     wFmtSize = len;
     
     if (wFmtSize < 16)
     {
-        st_fail_errno(ft,ST_EHDR,"WAVE file fmt chunk is too short");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"WAVE file fmt chunk is too short");
+        return SOX_EOF;
     }
 
-    st_readw(ft, &(wav->formatTag));
-    st_readw(ft, &wChannels);
-    st_readdw(ft, &dwSamplesPerSecond);
-    st_readdw(ft, &dwAvgBytesPerSec);   /* Average bytes/second */
-    st_readw(ft, &(wav->blockAlign));   /* Block align */
-    st_readw(ft, &wBitsPerSample);      /* bits per sample per channel */
+    sox_readw(ft, &(wav->formatTag));
+    sox_readw(ft, &wChannels);
+    sox_readdw(ft, &dwSamplesPerSecond);
+    sox_readdw(ft, &dwAvgBytesPerSec);   /* Average bytes/second */
+    sox_readw(ft, &(wav->blockAlign));   /* Block align */
+    sox_readw(ft, &wBitsPerSample);      /* bits per sample per channel */
     len -= 16;
 
     if (wav->formatTag == WAVE_FORMAT_EXTENSIBLE)
@@ -452,25 +452,25 @@
 
       if (wFmtSize < 18)
       {
-        st_fail_errno(ft,ST_EHDR,"WAVE file fmt chunk is too short");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"WAVE file fmt chunk is too short");
+        return SOX_EOF;
       }
-      st_readw(ft, &extensionSize);
+      sox_readw(ft, &extensionSize);
       len -= 2;
       if (extensionSize < 22)
       {
-        st_fail_errno(ft,ST_EHDR,"WAVE file fmt chunk is too short");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"WAVE file fmt chunk is too short");
+        return SOX_EOF;
       }
-      st_readw(ft, &numberOfValidBits);
-      st_readdw(ft, &speakerPositionMask);
-      st_readw(ft, &subFormatTag);
-      for (i = 0; i < 14; ++i) st_readb(ft, &dummyByte);
+      sox_readw(ft, &numberOfValidBits);
+      sox_readdw(ft, &speakerPositionMask);
+      sox_readw(ft, &subFormatTag);
+      for (i = 0; i < 14; ++i) sox_readb(ft, &dummyByte);
       len -= 22;
       if (numberOfValidBits != wBitsPerSample)
       {
-        st_fail_errno(ft,ST_EHDR,"WAVE file fmt with padded samples is not supported yet");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"WAVE file fmt with padded samples is not supported yet");
+        return SOX_EOF;
       }
       wav->formatTag = subFormatTag;
     }
@@ -478,17 +478,17 @@
     switch (wav->formatTag)
     {
     case WAVE_FORMAT_UNKNOWN:
-        st_fail_errno(ft,ST_EHDR,"WAVE file is in unsupported Microsoft Official Unknown format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"WAVE file is in unsupported Microsoft Official Unknown format.");
+        return SOX_EOF;
         
     case WAVE_FORMAT_PCM:
         /* Default (-1) depends on sample size.  Set that later on. */
-        if (ft->signal.encoding != ST_ENCODING_UNKNOWN && ft->signal.encoding != ST_ENCODING_UNSIGNED &&
-            ft->signal.encoding != ST_ENCODING_SIGN2)
-            st_report("User options overriding encoding read in .wav header");
+        if (ft->signal.encoding != SOX_ENCODING_UNKNOWN && ft->signal.encoding != SOX_ENCODING_UNSIGNED &&
+            ft->signal.encoding != SOX_ENCODING_SIGN2)
+            sox_report("User options overriding encoding read in .wav header");
 
         /* Needed by rawread() functions */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
@@ -495,27 +495,27 @@
         break;
         
     case WAVE_FORMAT_IMA_ADPCM:
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_IMA_ADPCM)
-            ft->signal.encoding = ST_ENCODING_IMA_ADPCM;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN || ft->signal.encoding == SOX_ENCODING_IMA_ADPCM)
+            ft->signal.encoding = SOX_ENCODING_IMA_ADPCM;
         else
-            st_report("User options overriding encoding read in .wav header");
+            sox_report("User options overriding encoding read in .wav header");
         break;
 
     case WAVE_FORMAT_ADPCM:
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_ADPCM)
-            ft->signal.encoding = ST_ENCODING_ADPCM;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN || ft->signal.encoding == SOX_ENCODING_ADPCM)
+            ft->signal.encoding = SOX_ENCODING_ADPCM;
         else
-            st_report("User options overriding encoding read in .wav header");
+            sox_report("User options overriding encoding read in .wav header");
         break;
 
     case WAVE_FORMAT_IEEE_FLOAT:
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_FLOAT)
-            ft->signal.encoding = ST_ENCODING_FLOAT;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN || ft->signal.encoding == SOX_ENCODING_FLOAT)
+            ft->signal.encoding = SOX_ENCODING_FLOAT;
         else
-            st_report("User options overriding encoding read in .wav header");
+            sox_report("User options overriding encoding read in .wav header");
 
         /* Needed by rawread() functions */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
@@ -522,13 +522,13 @@
         break;
         
     case WAVE_FORMAT_ALAW:
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_ALAW)
-            ft->signal.encoding = ST_ENCODING_ALAW;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN || ft->signal.encoding == SOX_ENCODING_ALAW)
+            ft->signal.encoding = SOX_ENCODING_ALAW;
         else
-            st_report("User options overriding encoding read in .wav header");
+            sox_report("User options overriding encoding read in .wav header");
 
         /* Needed by rawread() functions */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
@@ -535,13 +535,13 @@
         break;
         
     case WAVE_FORMAT_MULAW:
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_ULAW)
-            ft->signal.encoding = ST_ENCODING_ULAW;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN || ft->signal.encoding == SOX_ENCODING_ULAW)
+            ft->signal.encoding = SOX_ENCODING_ULAW;
         else
-            st_report("User options overriding encoding read in .wav header");
+            sox_report("User options overriding encoding read in .wav header");
 
         /* Needed by rawread() functions */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
@@ -548,49 +548,49 @@
         break;
         
     case WAVE_FORMAT_OKI_ADPCM:
-        st_fail_errno(ft,ST_EHDR,"Sorry, this WAV file is in OKI ADPCM format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"Sorry, this WAV file is in OKI ADPCM format.");
+        return SOX_EOF;
     case WAVE_FORMAT_DIGISTD:
-        st_fail_errno(ft,ST_EHDR,"Sorry, this WAV file is in Digistd format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"Sorry, this WAV file is in Digistd format.");
+        return SOX_EOF;
     case WAVE_FORMAT_DIGIFIX:
-        st_fail_errno(ft,ST_EHDR,"Sorry, this WAV file is in Digifix format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"Sorry, this WAV file is in Digifix format.");
+        return SOX_EOF;
     case WAVE_FORMAT_DOLBY_AC2:
-        st_fail_errno(ft,ST_EHDR,"Sorry, this WAV file is in Dolby AC2 format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EHDR,"Sorry, this WAV file is in Dolby AC2 format.");
+        return SOX_EOF;
     case WAVE_FORMAT_GSM610:
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN || ft->signal.encoding == ST_ENCODING_GSM )
-            ft->signal.encoding = ST_ENCODING_GSM;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN || ft->signal.encoding == SOX_ENCODING_GSM )
+            ft->signal.encoding = SOX_ENCODING_GSM;
         else
-            st_report("User options overriding encoding read in .wav header");
+            sox_report("User options overriding encoding read in .wav header");
         break;
     case WAVE_FORMAT_ROCKWELL_ADPCM:
-        st_fail_errno(ft,ST_EOF,"Sorry, this WAV file is in Rockwell ADPCM format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"Sorry, this WAV file is in Rockwell ADPCM format.");
+        return SOX_EOF;
     case WAVE_FORMAT_ROCKWELL_DIGITALK:
-        st_fail_errno(ft,ST_EOF,"Sorry, this WAV file is in Rockwell DIGITALK format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"Sorry, this WAV file is in Rockwell DIGITALK format.");
+        return SOX_EOF;
     case WAVE_FORMAT_G721_ADPCM:
-        st_fail_errno(ft,ST_EOF,"Sorry, this WAV file is in G.721 ADPCM format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"Sorry, this WAV file is in G.721 ADPCM format.");
+        return SOX_EOF;
     case WAVE_FORMAT_G728_CELP:
-        st_fail_errno(ft,ST_EOF,"Sorry, this WAV file is in G.728 CELP format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"Sorry, this WAV file is in G.728 CELP format.");
+        return SOX_EOF;
     case WAVE_FORMAT_MPEG:
-        st_fail_errno(ft,ST_EOF,"Sorry, this WAV file is in MPEG format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"Sorry, this WAV file is in MPEG format.");
+        return SOX_EOF;
     case WAVE_FORMAT_MPEGLAYER3:
-        st_fail_errno(ft,ST_EOF,"Sorry, this WAV file is in MPEG Layer 3 format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"Sorry, this WAV file is in MPEG Layer 3 format.");
+        return SOX_EOF;
     case WAVE_FORMAT_G726_ADPCM:
-        st_fail_errno(ft,ST_EOF,"Sorry, this WAV file is in G.726 ADPCM format.");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"Sorry, this WAV file is in G.726 ADPCM format.");
+        return SOX_EOF;
     case WAVE_FORMAT_G722_ADPCM:
-        st_fail_errno(ft,ST_EOF,"Sorry, this WAV file is in G.722 ADPCM format.");
-        return ST_EOF;
-    default:    st_fail_errno(ft,ST_EOF,"WAV file has unknown format type of %x",wav->formatTag);
-                return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"Sorry, this WAV file is in G.722 ADPCM format.");
+        return SOX_EOF;
+    default:    sox_fail_errno(ft,SOX_EOF,"WAV file has unknown format type of %x",wav->formatTag);
+                return SOX_EOF;
     }
 
     /* User options take precedence */
@@ -597,12 +597,12 @@
     if (ft->signal.channels == 0 || ft->signal.channels == wChannels)
         ft->signal.channels = wChannels;
     else
-        st_report("User options overriding channels read in .wav header");
+        sox_report("User options overriding channels read in .wav header");
 
     if (ft->signal.rate == 0 || ft->signal.rate == dwSamplesPerSecond)
         ft->signal.rate = dwSamplesPerSecond;
     else
-        st_report("User options overriding rate read in .wav header");
+        sox_report("User options overriding rate read in .wav header");
     
 
     wav->iCoefs = NULL;
@@ -616,17 +616,17 @@
         wav->formatTag != WAVE_FORMAT_ALAW &&
         wav->formatTag != WAVE_FORMAT_MULAW) {
         if (len >= 2) {
-            st_readw(ft, &wExtSize);
+            sox_readw(ft, &wExtSize);
             len -= 2;
         } else {
-            st_warn("wave header missing FmtExt chunk");
+            sox_warn("wave header missing FmtExt chunk");
         }
     }
 
     if (wExtSize > len)
     {
-        st_fail_errno(ft,ST_EOF,"wave header error: wExtSize inconsistent with wFmtLen");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"wave header error: wExtSize inconsistent with wFmtLen");
+        return SOX_EOF;
     }
 
     switch (wav->formatTag)
@@ -634,30 +634,30 @@
     case WAVE_FORMAT_ADPCM:
         if (wExtSize < 4)
         {
-            st_fail_errno(ft,ST_EOF,"format[%s]: expects wExtSize >= %d",
+            sox_fail_errno(ft,SOX_EOF,"format[%s]: expects wExtSize >= %d",
                         wav_format_str(wav->formatTag), 4);
-            return ST_EOF;
+            return SOX_EOF;
         }
 
         if (wBitsPerSample != 4)
         {
-            st_fail_errno(ft,ST_EOF,"Can only handle 4-bit MS ADPCM in wav files");
-            return ST_EOF;
+            sox_fail_errno(ft,SOX_EOF,"Can only handle 4-bit MS ADPCM in wav files");
+            return SOX_EOF;
         }
 
-        st_readw(ft, &(wav->samplesPerBlock));
+        sox_readw(ft, &(wav->samplesPerBlock));
         bytesPerBlock = AdpcmBytesPerBlock(ft->signal.channels, wav->samplesPerBlock);
         if (bytesPerBlock > wav->blockAlign)
         {
-            st_fail_errno(ft,ST_EOF,"format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
+            sox_fail_errno(ft,SOX_EOF,"format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
                 wav_format_str(wav->formatTag), wav->samplesPerBlock, wav->blockAlign);
-            return ST_EOF;
+            return SOX_EOF;
         }
 
-        st_readw(ft, &(wav->nCoefs));
+        sox_readw(ft, &(wav->nCoefs));
         if (wav->nCoefs < 7 || wav->nCoefs > 0x100) {
-            st_fail_errno(ft,ST_EOF,"ADPCM file nCoefs (%.4hx) makes no sense", wav->nCoefs);
-            return ST_EOF;
+            sox_fail_errno(ft,SOX_EOF,"ADPCM file nCoefs (%.4hx) makes no sense", wav->nCoefs);
+            return SOX_EOF;
         }
         wav->packet = (unsigned char *)xmalloc(wav->blockAlign);
 
@@ -665,8 +665,8 @@
 
         if (wExtSize < 4 + 4*wav->nCoefs)
         {
-            st_fail_errno(ft,ST_EOF,"wave header error: wExtSize(%d) too small for nCoefs(%d)", wExtSize, wav->nCoefs);
-            return ST_EOF;
+            sox_fail_errno(ft,SOX_EOF,"wave header error: wExtSize(%d) too small for nCoefs(%d)", wExtSize, wav->nCoefs);
+            return SOX_EOF;
         }
 
         wav->samples = (short *)xmalloc(wChannels*wav->samplesPerBlock*sizeof(short));
@@ -676,38 +676,38 @@
         {
             int i, errct=0;
             for (i=0; len>=2 && i < 2*wav->nCoefs; i++) {
-                st_readw(ft, (unsigned short *)&(wav->iCoefs[i]));
+                sox_readw(ft, (unsigned short *)&(wav->iCoefs[i]));
                 len -= 2;
                 if (i<14) errct += (wav->iCoefs[i] != iCoef[i/2][i%2]);
-                /* st_debug("iCoefs[%2d] %4d",i,wav->iCoefs[i]); */
+                /* sox_debug("iCoefs[%2d] %4d",i,wav->iCoefs[i]); */
             }
-            if (errct) st_warn("base iCoefs differ in %d/14 positions",errct);
+            if (errct) sox_warn("base iCoefs differ in %d/14 positions",errct);
         }
 
-        bytespersample = ST_SIZE_16BIT;  /* AFTER de-compression */
+        bytespersample = SOX_SIZE_16BIT;  /* AFTER de-compression */
         break;
 
     case WAVE_FORMAT_IMA_ADPCM:
         if (wExtSize < 2)
         {
-            st_fail_errno(ft,ST_EOF,"format[%s]: expects wExtSize >= %d",
+            sox_fail_errno(ft,SOX_EOF,"format[%s]: expects wExtSize >= %d",
                     wav_format_str(wav->formatTag), 2);
-            return ST_EOF;
+            return SOX_EOF;
         }
 
         if (wBitsPerSample != 4)
         {
-            st_fail_errno(ft,ST_EOF,"Can only handle 4-bit IMA ADPCM in wav files");
-            return ST_EOF;
+            sox_fail_errno(ft,SOX_EOF,"Can only handle 4-bit IMA ADPCM in wav files");
+            return SOX_EOF;
         }
 
-        st_readw(ft, &(wav->samplesPerBlock));
+        sox_readw(ft, &(wav->samplesPerBlock));
         bytesPerBlock = ImaBytesPerBlock(ft->signal.channels, wav->samplesPerBlock);
         if (bytesPerBlock > wav->blockAlign || wav->samplesPerBlock%8 != 1)
         {
-            st_fail_errno(ft,ST_EOF,"format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
+            sox_fail_errno(ft,SOX_EOF,"format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
                 wav_format_str(wav->formatTag), wav->samplesPerBlock, wav->blockAlign);
-            return ST_EOF;
+            return SOX_EOF;
         }
 
         wav->packet = (unsigned char *)xmalloc(wav->blockAlign);
@@ -715,7 +715,7 @@
 
         wav->samples = (short *)xmalloc(wChannels*wav->samplesPerBlock*sizeof(short));
 
-        bytespersample = ST_SIZE_16BIT;  /* AFTER de-compression */
+        bytespersample = SOX_SIZE_16BIT;  /* AFTER de-compression */
         break;
 
     /* GSM formats have extended fmt chunk.  Check for those cases. */
@@ -722,25 +722,25 @@
     case WAVE_FORMAT_GSM610:
         if (wExtSize < 2)
         {
-            st_fail_errno(ft,ST_EOF,"format[%s]: expects wExtSize >= %d",
+            sox_fail_errno(ft,SOX_EOF,"format[%s]: expects wExtSize >= %d",
                     wav_format_str(wav->formatTag), 2);
-            return ST_EOF;
+            return SOX_EOF;
         }
-        st_readw(ft, &wav->samplesPerBlock);
+        sox_readw(ft, &wav->samplesPerBlock);
         bytesPerBlock = 65;
         if (wav->blockAlign != 65)
         {
-            st_fail_errno(ft,ST_EOF,"format[%s]: expects blockAlign(%d) = %d",
+            sox_fail_errno(ft,SOX_EOF,"format[%s]: expects blockAlign(%d) = %d",
                     wav_format_str(wav->formatTag), wav->blockAlign, 65);
-            return ST_EOF;
+            return SOX_EOF;
         }
         if (wav->samplesPerBlock != 320)
         {
-            st_fail_errno(ft,ST_EOF,"format[%s]: expects samplesPerBlock(%d) = %d",
+            sox_fail_errno(ft,SOX_EOF,"format[%s]: expects samplesPerBlock(%d) = %d",
                     wav_format_str(wav->formatTag), wav->samplesPerBlock, 320);
-            return ST_EOF;
+            return SOX_EOF;
         }
-        bytespersample = ST_SIZE_16BIT;  /* AFTER de-compression */
+        bytespersample = SOX_SIZE_16BIT;  /* AFTER de-compression */
         len -= 2;
         break;
 
@@ -752,72 +752,72 @@
     switch (bytespersample)
     {
         
-    case ST_SIZE_BYTE:
+    case SOX_SIZE_BYTE:
         /* User options take precedence */
-        if (ft->signal.size == -1 || ft->signal.size == ST_SIZE_BYTE)
-            ft->signal.size = ST_SIZE_BYTE;
+        if (ft->signal.size == -1 || ft->signal.size == SOX_SIZE_BYTE)
+            ft->signal.size = SOX_SIZE_BYTE;
         else
-            st_warn("User options overriding size read in .wav header");
+            sox_warn("User options overriding size read in .wav header");
 
         /* Now we have enough information to set default encodings. */
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
-            ft->signal.encoding = ST_ENCODING_UNSIGNED;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN)
+            ft->signal.encoding = SOX_ENCODING_UNSIGNED;
         break;
         
-    case ST_SIZE_16BIT:
-        if (ft->signal.size == -1 || ft->signal.size == ST_SIZE_16BIT)
-            ft->signal.size = ST_SIZE_16BIT;
+    case SOX_SIZE_16BIT:
+        if (ft->signal.size == -1 || ft->signal.size == SOX_SIZE_16BIT)
+            ft->signal.size = SOX_SIZE_16BIT;
         else
-            st_warn("User options overriding size read in .wav header");
+            sox_warn("User options overriding size read in .wav header");
 
         /* Now we have enough information to set default encodings. */
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
-            ft->signal.encoding = ST_ENCODING_SIGN2;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN)
+            ft->signal.encoding = SOX_ENCODING_SIGN2;
         break;
         
-    case ST_SIZE_24BIT:
-        if (ft->signal.size == -1 || ft->signal.size == ST_SIZE_24BIT)
-            ft->signal.size = ST_SIZE_24BIT;
+    case SOX_SIZE_24BIT:
+        if (ft->signal.size == -1 || ft->signal.size == SOX_SIZE_24BIT)
+            ft->signal.size = SOX_SIZE_24BIT;
         else
-            st_warn("User options overriding size read in .wav header");
+            sox_warn("User options overriding size read in .wav header");
 
         /* Now we have enough information to set default encodings. */
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
-            ft->signal.encoding = ST_ENCODING_SIGN2;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN)
+            ft->signal.encoding = SOX_ENCODING_SIGN2;
         break;
         
-    case ST_SIZE_32BIT:
-        if (ft->signal.size == -1 || ft->signal.size == ST_SIZE_32BIT)
-            ft->signal.size = ST_SIZE_32BIT;
+    case SOX_SIZE_32BIT:
+        if (ft->signal.size == -1 || ft->signal.size == SOX_SIZE_32BIT)
+            ft->signal.size = SOX_SIZE_32BIT;
         else
-            st_warn("User options overriding size read in .wav header");
+            sox_warn("User options overriding size read in .wav header");
 
         /* Now we have enough information to set default encodings. */
-        if (ft->signal.encoding == ST_ENCODING_UNKNOWN)
-            ft->signal.encoding = ST_ENCODING_SIGN2;
+        if (ft->signal.encoding == SOX_ENCODING_UNKNOWN)
+            ft->signal.encoding = SOX_ENCODING_SIGN2;
         break;
         
     default:
-        st_fail_errno(ft,ST_EOF,"Sorry, don't understand .wav size");
-        return ST_EOF;
+        sox_fail_errno(ft,SOX_EOF,"Sorry, don't understand .wav size");
+        return SOX_EOF;
     }
 
     /* Skip anything left over from fmt chunk */
-    st_seeki(ft, len, SEEK_CUR);
+    sox_seeki(ft, len, SEEK_CUR);
 
     /* for non-PCM formats, there's a 'fact' chunk before
      * the upcoming 'data' chunk */
 
     /* Now look for the wave data chunk */
-    if (findChunk(ft, "data", &len) == ST_EOF)
+    if (findChunk(ft, "data", &len) == SOX_EOF)
     {
-        st_fail_errno(ft, ST_EOF, "Could not find data chunk.");
-        return ST_EOF;
+        sox_fail_errno(ft, SOX_EOF, "Could not find data chunk.");
+        return SOX_EOF;
     }
     dwDataLength = len;
 
     /* Data starts here */
-    wav->dataStart = st_tell(ft);
+    wav->dataStart = sox_tell(ft);
 
     switch (wav->formatTag)
     {
@@ -826,7 +826,7 @@
         wav->numSamples = 
             AdpcmSamplesIn(dwDataLength, ft->signal.channels, 
                            wav->blockAlign, wav->samplesPerBlock);
-        /*st_debug("datalen %d, numSamples %d",dwDataLength, wav->numSamples);*/
+        /*sox_debug("datalen %d, numSamples %d",dwDataLength, wav->numSamples);*/
         wav->blockSamplesRemaining = 0;        /* Samples left in buffer */
         ft->length = wav->numSamples*ft->signal.channels;
         break;
@@ -837,7 +837,7 @@
         wav->numSamples = 
             ImaSamplesIn(dwDataLength, ft->signal.channels, 
                          wav->blockAlign, wav->samplesPerBlock);
-        /*st_debug("datalen %d, numSamples %d",dwDataLength, wav->numSamples);*/
+        /*sox_debug("datalen %d, numSamples %d",dwDataLength, wav->numSamples);*/
         wav->blockSamplesRemaining = 0;        /* Samples left in buffer */
         initImaTable();
         ft->length = wav->numSamples*ft->signal.channels;
@@ -854,10 +854,10 @@
         ft->length = wav->numSamples*ft->signal.channels;
     }
 
-    st_debug("Reading Wave file: %s format, %d channel%s, %d samp/sec",
+    sox_debug("Reading Wave file: %s format, %d channel%s, %d samp/sec",
            wav_format_str(wav->formatTag), ft->signal.channels,
            wChannels == 1 ? "" : "s", dwSamplesPerSecond);
-    st_debug("        %d byte/sec, %d block align, %d bits/samp, %u data bytes",
+    sox_debug("        %d byte/sec, %d block align, %d bits/samp, %u data bytes",
            dwAvgBytesPerSec, wav->blockAlign, wBitsPerSample, dwDataLength);
 
     /* Can also report extended fmt information */
@@ -864,24 +864,24 @@
     switch (wav->formatTag)
     {
         case WAVE_FORMAT_ADPCM:
-            st_debug("        %d Extsize, %d Samps/block, %d bytes/block %d Num Coefs, %d Samps/chan",
+            sox_debug("        %d Extsize, %d Samps/block, %d bytes/block %d Num Coefs, %d Samps/chan",
                       wExtSize,wav->samplesPerBlock,bytesPerBlock,wav->nCoefs,
                       wav->numSamples);
             break;
 
         case WAVE_FORMAT_IMA_ADPCM:
-            st_debug("        %d Extsize, %d Samps/block, %d bytes/block %d Samps/chan",
+            sox_debug("        %d Extsize, %d Samps/block, %d bytes/block %d Samps/chan",
                       wExtSize, wav->samplesPerBlock, bytesPerBlock, 
                       wav->numSamples);
             break;
 
         case WAVE_FORMAT_GSM610:
-            st_debug("GSM .wav: %d Extsize, %d Samps/block, %d Samples/chan",
+            sox_debug("GSM .wav: %d Extsize, %d Samps/block, %d Samples/chan",
                       wExtSize, wav->samplesPerBlock, wav->numSamples);
             break;
 
         default:
-            st_debug("        %d Samps/chans", wav->numSamples);
+            sox_debug("        %d Samps/chans", wav->numSamples);
     }
 
     /* Horrible way to find Cool Edit marker points. Taken from Quake source*/
@@ -892,16 +892,16 @@
          * doubt any machine writing Cool Edit Chunks writes them at an odd 
          * offset */
         len = (len + 1) & ~1;
-        if (st_seeki(ft, len, SEEK_CUR) == ST_SUCCESS &&
-            findChunk(ft, "LIST", &len) != ST_EOF)
+        if (sox_seeki(ft, len, SEEK_CUR) == SOX_SUCCESS &&
+            findChunk(ft, "LIST", &len) != SOX_EOF)
         {
             wav->found_cooledit = 1;
             ft->comment = (char*)xmalloc(256);
             /* Initialize comment to a NULL string */
             ft->comment[0] = 0;
-            while(!st_eof(ft))
+            while(!sox_eof(ft))
             {
-                if (st_reads(ft,magic,4) == ST_EOF)
+                if (sox_reads(ft,magic,4) == SOX_EOF)
                     break;
 
                 /* First look for type fields for LIST Chunk and
@@ -912,26 +912,26 @@
                 if (strncmp(magic, "INFO", 4) == 0)
                 {
                     /*Skip*/
-                    st_debug("Type INFO");
+                    sox_debug("Type INFO");
                 }
                 else if (strncmp(magic, "adtl", 4) == 0)
                 {
                     /* Skip */
-                    st_debug("Type adtl");
+                    sox_debug("Type adtl");
                 }
                 else
                 {
-                    if (st_readdw(ft,&len) == ST_EOF)
+                    if (sox_readdw(ft,&len) == SOX_EOF)
                         break;
                     if (strncmp(magic,"ICRD",4) == 0)
                     {
-                        st_debug("Chunk ICRD");
+                        sox_debug("Chunk ICRD");
                         if (len > 254)
                         {
-                            st_warn("Possible buffer overflow hack attack (ICRD)!");
+                            sox_warn("Possible buffer overflow hack attack (ICRD)!");
                             break;
                         }
-                        st_reads(ft,text,len);
+                        sox_reads(ft,text,len);
                         if (strlen(ft->comment) + strlen(text) < 254)
                         {
                             if (ft->comment[0] != 0)
@@ -940,17 +940,17 @@
                             strcat(ft->comment,text);
                         }
                         if (strlen(text) < len)
-                           st_seeki(ft, len - strlen(text), SEEK_CUR); 
+                           sox_seeki(ft, len - strlen(text), SEEK_CUR); 
                     } 
                     else if (strncmp(magic,"ISFT",4) == 0)
                     {
-                        st_debug("Chunk ISFT");
+                        sox_debug("Chunk ISFT");
                         if (len > 254)
                         {
-                            st_warn("Possible buffer overflow hack attack (ISFT)!");
+                            sox_warn("Possible buffer overflow hack attack (ISFT)!");
                             break;
                         }
-                        st_reads(ft,text,len);
+                        sox_reads(ft,text,len);
                         if (strlen(ft->comment) + strlen(text) < 254)
                         {
                             if (ft->comment[0] != 0)
@@ -959,36 +959,36 @@
                             strcat(ft->comment,text);
                         }
                         if (strlen(text) < len)
-                           st_seeki(ft, len - strlen(text), SEEK_CUR); 
+                           sox_seeki(ft, len - strlen(text), SEEK_CUR); 
                     } 
                     else if (strncmp(magic,"cue ",4) == 0)
                     {
-                        st_debug("Chunk cue ");
-                        st_seeki(ft,len-4,SEEK_CUR);
-                        st_readdw(ft,&dwLoopPos);
+                        sox_debug("Chunk cue ");
+                        sox_seeki(ft,len-4,SEEK_CUR);
+                        sox_readdw(ft,&dwLoopPos);
                         ft->loops[0].start = dwLoopPos;
                     } 
                     else if (strncmp(magic,"ltxt",4) == 0)
                     {
-                        st_debug("Chunk ltxt");
-                        st_readdw(ft,&dwLoopPos);
+                        sox_debug("Chunk ltxt");
+                        sox_readdw(ft,&dwLoopPos);
                         ft->loops[0].length = dwLoopPos - ft->loops[0].start;
                         if (len > 4)
-                           st_seeki(ft, len - 4, SEEK_CUR); 
+                           sox_seeki(ft, len - 4, SEEK_CUR); 
                     } 
                     else 
                     {
-                        st_debug("Attempting to seek beyond unsupported chunk '%c%c%c%c' of length %d bytes", magic[0], magic[1], magic[2], magic[3], len);
+                        sox_debug("Attempting to seek beyond unsupported chunk '%c%c%c%c' of length %d bytes", magic[0], magic[1], magic[2], magic[3], len);
                         len = (len + 1) & ~1;
-                        st_seeki(ft, len, SEEK_CUR);
+                        sox_seeki(ft, len, SEEK_CUR);
                     }
                 }
             }
         }
-        st_clearerr(ft);
-        st_seeki(ft,wav->dataStart,SEEK_SET);
+        sox_clearerr(ft);
+        sox_seeki(ft,wav->dataStart,SEEK_SET);
     }   
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 
@@ -999,19 +999,19 @@
  * Return number of samples read.
  */
 
-static st_size_t st_wavread(ft_t ft, st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_wavread(ft_t ft, sox_sample_t *buf, sox_size_t len) 
 {
         wav_t   wav = (wav_t) ft->priv;
-        st_size_t done;
+        sox_size_t done;
 
-        ft->st_errno = ST_SUCCESS;
+        ft->sox_errno = SOX_SUCCESS;
         
         /* If file is in ADPCM encoding then read in multiple blocks else */
         /* read as much as possible and return quickly. */
         switch (ft->signal.encoding)
         {
-        case ST_ENCODING_IMA_ADPCM:
-        case ST_ENCODING_ADPCM:
+        case SOX_ENCODING_IMA_ADPCM:
+        case SOX_ENCODING_ADPCM:
 
             /* See reason for cooledit check in comments below */
             if (wav->found_cooledit && len > (wav->numSamples*ft->signal.channels)) 
@@ -1034,7 +1034,7 @@
                     wav->samplePtr = wav->samples;
                 }
 
-                /* Copy interleaved data into buf, converting to st_sample_t */
+                /* Copy interleaved data into buf, converting to sox_sample_t */
                 {
                     short *p, *top;
                     size_t ct;
@@ -1048,7 +1048,7 @@
                     top = p+ct;
                     /* Output is already signed */
                     while (p<top)
-                        *buf++ = ST_SIGNED_WORD_TO_SAMPLE((*p++),);
+                        *buf++ = SOX_SIGNED_WORD_TO_SAMPLE((*p++),);
 
                     wav->samplePtr = p;
                 }
@@ -1061,7 +1061,7 @@
             return done;
             break;
 
-        case ST_ENCODING_GSM:
+        case SOX_ENCODING_GSM:
             /* See reason for cooledit check in comments below */
             if (wav->found_cooledit && len > wav->numSamples*ft->signal.channels) 
                 len = (wav->numSamples*ft->signal.channels);
@@ -1068,7 +1068,7 @@
 
             done = wavgsmread(ft, buf, len);
             if (done == 0 && wav->numSamples != 0)
-                st_warn("Premature EOF on .wav input file");
+                sox_warn("Premature EOF on .wav input file");
         break;
 
         default: /* assume PCM or float encoding */
@@ -1085,11 +1085,11 @@
             if (wav->found_cooledit && len > wav->numSamples*ft->signal.channels) 
                 len = (wav->numSamples*ft->signal.channels);
 
-            done = st_rawread(ft, buf, len);
+            done = sox_rawread(ft, buf, len);
             /* If software thinks there are more samples but I/O */
             /* says otherwise, let the user know about this.     */
             if (done == 0 && wav->numSamples != 0)
-                st_warn("Premature EOF on .wav input file");
+                sox_warn("Premature EOF on .wav input file");
         }
 
         /* Only return buffers that contain a totally playable
@@ -1107,12 +1107,12 @@
  * Do anything required when you stop reading samples.  
  * Don't close input file! 
  */
-static int st_wavstopread(ft_t ft) 
+static int sox_wavstopread(ft_t ft) 
 {
     wav_t       wav = (wav_t) ft->priv;
-    int         rc = ST_SUCCESS;
+    int         rc = SOX_SUCCESS;
 
-        ft->st_errno = ST_SUCCESS;
+        ft->sox_errno = SOX_SUCCESS;
 
     free(wav->packet);
     free(wav->samples);
@@ -1122,31 +1122,31 @@
 
     switch (ft->signal.encoding)
     {
-    case ST_ENCODING_GSM:
+    case SOX_ENCODING_GSM:
         wavgsmdestroy(ft);
         break;
-    case ST_ENCODING_IMA_ADPCM:
-    case ST_ENCODING_ADPCM:
+    case SOX_ENCODING_IMA_ADPCM:
+    case SOX_ENCODING_ADPCM:
         break;
     default:
         /* Needed for rawread() */
-        rc = st_rawstopread(ft);
+        rc = sox_rawstopread(ft);
     }
     return rc;
 }
 
-static int st_wavstartwrite(ft_t ft) 
+static int sox_wavstartwrite(ft_t ft) 
 {
     wav_t wav = (wav_t) ft->priv;
     int rc;
 
-    ft->st_errno = ST_SUCCESS;
+    ft->sox_errno = SOX_SUCCESS;
 
-    if (ft->signal.encoding != ST_ENCODING_ADPCM &&
-        ft->signal.encoding != ST_ENCODING_IMA_ADPCM &&
-        ft->signal.encoding != ST_ENCODING_GSM)
+    if (ft->signal.encoding != SOX_ENCODING_ADPCM &&
+        ft->signal.encoding != SOX_ENCODING_IMA_ADPCM &&
+        ft->signal.encoding != SOX_ENCODING_GSM)
     {
-        rc = st_rawstartwrite(ft);
+        rc = sox_rawstartwrite(ft);
         if (rc)
             return rc;
     }
@@ -1154,7 +1154,7 @@
     wav->numSamples = 0;
     wav->dataLength = 0;
     if (!ft->seekable)
-        st_warn("Length in output .wav header will be wrong since can't seek to fix it");
+        sox_warn("Length in output .wav header will be wrong since can't seek to fix it");
     rc = wavwritehdr(ft, 0);  /* also calculates various wav->* info */
     if (rc != 0)
         return rc;
@@ -1187,7 +1187,7 @@
         default:
             break;
     }
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /* wavwritehdr:  write .wav headers as follows:
@@ -1277,7 +1277,7 @@
     /* internal variables, intermediate values etc */
     int bytespersample; /* (uncompressed) bytes per sample (per channel) */
     long blocksWritten = 0;
-    st_bool isExtensible = st_false;    /* WAVE_FORMAT_EXTENSIBLE? */
+    sox_bool isExtensible = sox_false;    /* WAVE_FORMAT_EXTENSIBLE? */
 
     dwSamplesPerSecond = ft->signal.rate;
     wChannels = ft->signal.channels;
@@ -1287,61 +1287,61 @@
      * by this routine will look nicer (and more correct)
      * on verbose output.
      */
-    if ((ft->signal.encoding == ST_ENCODING_ADPCM ||
-         ft->signal.encoding == ST_ENCODING_IMA_ADPCM ||
-         ft->signal.encoding == ST_ENCODING_GSM) &&
-         ft->signal.size != ST_SIZE_BYTE)
+    if ((ft->signal.encoding == SOX_ENCODING_ADPCM ||
+         ft->signal.encoding == SOX_ENCODING_IMA_ADPCM ||
+         ft->signal.encoding == SOX_ENCODING_GSM) &&
+         ft->signal.size != SOX_SIZE_BYTE)
     {
-        st_report("Overriding output size to bytes for compressed data.");
-        ft->signal.size = ST_SIZE_BYTE;
+        sox_report("Overriding output size to bytes for compressed data.");
+        ft->signal.size = SOX_SIZE_BYTE;
     }
 
     switch (ft->signal.size)
     {
-        case ST_SIZE_BYTE:
+        case SOX_SIZE_BYTE:
             wBitsPerSample = 8;
-            if (ft->signal.encoding != ST_ENCODING_UNSIGNED &&
-                    ft->signal.encoding != ST_ENCODING_ULAW &&
-                    ft->signal.encoding != ST_ENCODING_ALAW &&
-                    ft->signal.encoding != ST_ENCODING_GSM &&
-                    ft->signal.encoding != ST_ENCODING_ADPCM &&
-                    ft->signal.encoding != ST_ENCODING_IMA_ADPCM)
+            if (ft->signal.encoding != SOX_ENCODING_UNSIGNED &&
+                    ft->signal.encoding != SOX_ENCODING_ULAW &&
+                    ft->signal.encoding != SOX_ENCODING_ALAW &&
+                    ft->signal.encoding != SOX_ENCODING_GSM &&
+                    ft->signal.encoding != SOX_ENCODING_ADPCM &&
+                    ft->signal.encoding != SOX_ENCODING_IMA_ADPCM)
             {
-                st_report("Do not support %s with 8-bit data.  Forcing to unsigned",st_encodings_str[(unsigned char)ft->signal.encoding]);
-                ft->signal.encoding = ST_ENCODING_UNSIGNED;
+                sox_report("Do not support %s with 8-bit data.  Forcing to unsigned",sox_encodings_str[(unsigned char)ft->signal.encoding]);
+                ft->signal.encoding = SOX_ENCODING_UNSIGNED;
             }
             break;
-        case ST_SIZE_16BIT:
+        case SOX_SIZE_16BIT:
             wBitsPerSample = 16;
-            if (ft->signal.encoding != ST_ENCODING_SIGN2)
+            if (ft->signal.encoding != SOX_ENCODING_SIGN2)
             {
-                st_report("Do not support %s with 16-bit data.  Forcing to Signed.",st_encodings_str[(unsigned char)ft->signal.encoding]);
-                ft->signal.encoding = ST_ENCODING_SIGN2;
+                sox_report("Do not support %s with 16-bit data.  Forcing to Signed.",sox_encodings_str[(unsigned char)ft->signal.encoding]);
+                ft->signal.encoding = SOX_ENCODING_SIGN2;
             }
             break;
-        case ST_SIZE_24BIT:
+        case SOX_SIZE_24BIT:
             wBitsPerSample = 24;
-            if (ft->signal.encoding != ST_ENCODING_SIGN2)
+            if (ft->signal.encoding != SOX_ENCODING_SIGN2)
             {
-                st_report("Do not support %s with 24-bit data.  Forcing to Signed.",st_encodings_str[(unsigned char)ft->signal.encoding]);
-                ft->signal.encoding = ST_ENCODING_SIGN2;
+                sox_report("Do not support %s with 24-bit data.  Forcing to Signed.",sox_encodings_str[(unsigned char)ft->signal.encoding]);
+                ft->signal.encoding = SOX_ENCODING_SIGN2;
             }
             break;
 
-        case ST_SIZE_32BIT:
+        case SOX_SIZE_32BIT:
             wBitsPerSample = 32;
-            if (ft->signal.encoding != ST_ENCODING_SIGN2 &&
-                ft->signal.encoding != ST_ENCODING_FLOAT)
+            if (ft->signal.encoding != SOX_ENCODING_SIGN2 &&
+                ft->signal.encoding != SOX_ENCODING_FLOAT)
             {
-                st_report("Do not support %s with 32-bit data.  Forcing to Signed.",st_encodings_str[(unsigned char)ft->signal.encoding]);
-                ft->signal.encoding = ST_ENCODING_SIGN2;
+                sox_report("Do not support %s with 32-bit data.  Forcing to Signed.",sox_encodings_str[(unsigned char)ft->signal.encoding]);
+                ft->signal.encoding = SOX_ENCODING_SIGN2;
             }
 
             break;
         default:
-            st_report("Do not support %s in WAV files.  Forcing to Signed Words.",st_sizes_str[(unsigned char)ft->signal.size]);
-            ft->signal.encoding = ST_ENCODING_SIGN2;
-            ft->signal.size = ST_SIZE_16BIT;
+            sox_report("Do not support %s in WAV files.  Forcing to Signed Words.",sox_sizes_str[(unsigned char)ft->signal.size]);
+            ft->signal.encoding = SOX_ENCODING_SIGN2;
+            ft->signal.size = SOX_SIZE_16BIT;
             wBitsPerSample = 16;
             break;
     }
@@ -1350,30 +1350,30 @@
 
     switch (ft->signal.encoding)
     {
-        case ST_ENCODING_UNSIGNED:
-        case ST_ENCODING_SIGN2:
+        case SOX_ENCODING_UNSIGNED:
+        case SOX_ENCODING_SIGN2:
             wFormatTag = WAVE_FORMAT_PCM;
             bytespersample = (wBitsPerSample + 7)/8;
             wBlockAlign = wChannels * bytespersample;
             break;
-        case ST_ENCODING_FLOAT:
+        case SOX_ENCODING_FLOAT:
             wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
             bytespersample = (wBitsPerSample + 7)/8;
             wBlockAlign = wChannels * bytespersample;
             break;
-        case ST_ENCODING_ALAW:
+        case SOX_ENCODING_ALAW:
             wFormatTag = WAVE_FORMAT_ALAW;
             wBlockAlign = wChannels;
             break;
-        case ST_ENCODING_ULAW:
+        case SOX_ENCODING_ULAW:
             wFormatTag = WAVE_FORMAT_MULAW;
             wBlockAlign = wChannels;
             break;
-        case ST_ENCODING_IMA_ADPCM:
+        case SOX_ENCODING_IMA_ADPCM:
             if (wChannels>16)
             {
-                st_fail_errno(ft,ST_EOF,"Channels(%d) must be <= 16",wChannels);
-                return ST_EOF;
+                sox_fail_errno(ft,SOX_EOF,"Channels(%d) must be <= 16",wChannels);
+                return SOX_EOF;
             }
             wFormatTag = WAVE_FORMAT_IMA_ADPCM;
             wBlockAlign = wChannels * 256; /* reasonable default */
@@ -1381,11 +1381,11 @@
             wExtSize = 2;
             wSamplesPerBlock = ImaSamplesIn(0, wChannels, wBlockAlign, 0);
             break;
-        case ST_ENCODING_ADPCM:
+        case SOX_ENCODING_ADPCM:
             if (wChannels>16)
             {
-                st_fail_errno(ft,ST_EOF,"Channels(%d) must be <= 16",wChannels);
-                return ST_EOF;
+                sox_fail_errno(ft,SOX_EOF,"Channels(%d) must be <= 16",wChannels);
+                return SOX_EOF;
             }
             wFormatTag = WAVE_FORMAT_ADPCM;
             wBlockAlign = wChannels * 128; /* reasonable default */
@@ -1393,10 +1393,10 @@
             wExtSize = 4+4*7;      /* Ext fmt data length */
             wSamplesPerBlock = AdpcmSamplesIn(0, wChannels, wBlockAlign, 0);
             break;
-        case ST_ENCODING_GSM:
+        case SOX_ENCODING_GSM:
             if (wChannels!=1)
             {
-                st_report("Overriding GSM audio from %d channel to 1",wChannels);
+                sox_report("Overriding GSM audio from %d channel to 1",wChannels);
                 wChannels = ft->signal.channels = 1;
             }
             wFormatTag = WAVE_FORMAT_GSM610;
@@ -1438,7 +1438,7 @@
 
     if ((wFormatTag == WAVE_FORMAT_PCM && wBitsPerSample > 16) || wChannels > 2)
     {
-      isExtensible = st_true;
+      isExtensible = sox_true;
       wFmtSize += 2 + 22;
     }
     else if (wFormatTag != WAVE_FORMAT_PCM)
@@ -1457,59 +1457,59 @@
     /* If user specified opposite swap than we think, assume they are
      * asking to write a RIFX file.
      */
-    if (ft->signal.reverse_bytes != ST_IS_BIGENDIAN)
+    if (ft->signal.reverse_bytes != SOX_IS_BIGENDIAN)
     {
         if (!second_header)
-            st_report("Requested to swap bytes so writing RIFX header");
-        st_writes(ft, "RIFX");
+            sox_report("Requested to swap bytes so writing RIFX header");
+        sox_writes(ft, "RIFX");
     }
     else
-        st_writes(ft, "RIFF");
-    st_writedw(ft, wRiffLength);
-    st_writes(ft, "WAVE");
-    st_writes(ft, "fmt ");
-    st_writedw(ft, wFmtSize);
-    st_writew(ft, isExtensible? WAVE_FORMAT_EXTENSIBLE : wFormatTag);
-    st_writew(ft, wChannels);
-    st_writedw(ft, dwSamplesPerSecond);
-    st_writedw(ft, dwAvgBytesPerSec);
-    st_writew(ft, wBlockAlign);
-    st_writew(ft, wBitsPerSample); /* end info common to all fmts */
+        sox_writes(ft, "RIFF");
+    sox_writedw(ft, wRiffLength);
+    sox_writes(ft, "WAVE");
+    sox_writes(ft, "fmt ");
+    sox_writedw(ft, wFmtSize);
+    sox_writew(ft, isExtensible? WAVE_FORMAT_EXTENSIBLE : wFormatTag);
+    sox_writew(ft, wChannels);
+    sox_writedw(ft, dwSamplesPerSecond);
+    sox_writedw(ft, dwAvgBytesPerSec);
+    sox_writew(ft, wBlockAlign);
+    sox_writew(ft, wBitsPerSample); /* end info common to all fmts */
 
     if (isExtensible)
     {
       size_t i;
       static const char guid[14] = "\x00\x00\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71";
-      st_writew(ft, 22);
-      st_writew(ft, wBitsPerSample); /* No padding in container */
-      st_writedw(ft, 0);             /* Speaker mapping not specified */
-      st_writew(ft, wFormatTag);
+      sox_writew(ft, 22);
+      sox_writew(ft, wBitsPerSample); /* No padding in container */
+      sox_writedw(ft, 0);             /* Speaker mapping not specified */
+      sox_writew(ft, wFormatTag);
       for (i = 0; i < array_length(guid); ++i)
       {
-        st_writeb(ft, guid[i]);
+        sox_writeb(ft, guid[i]);
       }
     }
     else 
     /* if not PCM, we need to write out wExtSize even if wExtSize=0 */
     if (wFormatTag != WAVE_FORMAT_PCM)
-        st_writew(ft,wExtSize);
+        sox_writew(ft,wExtSize);
 
     switch (wFormatTag)
     {
         int i;
         case WAVE_FORMAT_IMA_ADPCM:
-        st_writew(ft, wSamplesPerBlock);
+        sox_writew(ft, wSamplesPerBlock);
         break;
         case WAVE_FORMAT_ADPCM:
-        st_writew(ft, wSamplesPerBlock);
-        st_writew(ft, 7); /* nCoefs */
+        sox_writew(ft, wSamplesPerBlock);
+        sox_writew(ft, 7); /* nCoefs */
         for (i=0; i<7; i++) {
-            st_writew(ft, iCoef[i][0]);
-            st_writew(ft, iCoef[i][1]);
+            sox_writew(ft, iCoef[i][0]);
+            sox_writew(ft, iCoef[i][1]);
         }
         break;
         case WAVE_FORMAT_GSM610:
-        st_writew(ft, wSamplesPerBlock);
+        sox_writew(ft, wSamplesPerBlock);
         break;
         default:
         break;
@@ -1517,41 +1517,41 @@
 
     /* if not PCM, write the 'fact' chunk */
     if (isExtensible || wFormatTag != WAVE_FORMAT_PCM){
-        st_writes(ft, "fact");
-        st_writedw(ft,dwFactSize); 
-        st_writedw(ft,dwSamplesWritten);
+        sox_writes(ft, "fact");
+        sox_writedw(ft,dwFactSize); 
+        sox_writedw(ft,dwSamplesWritten);
     }
 
-    st_writes(ft, "data");
-    st_writedw(ft, dwDataLength);               /* data chunk size */
+    sox_writes(ft, "data");
+    sox_writedw(ft, dwDataLength);               /* data chunk size */
 
     if (!second_header) {
-        st_debug("Writing Wave file: %s format, %d channel%s, %d samp/sec",
+        sox_debug("Writing Wave file: %s format, %d channel%s, %d samp/sec",
                 wav_format_str(wFormatTag), wChannels,
                 wChannels == 1 ? "" : "s", dwSamplesPerSecond);
-        st_debug("        %d byte/sec, %d block align, %d bits/samp",
+        sox_debug("        %d byte/sec, %d block align, %d bits/samp",
                 dwAvgBytesPerSec, wBlockAlign, wBitsPerSample);
     } else {
-        st_debug("Finished writing Wave file, %u data bytes %u samples",
+        sox_debug("Finished writing Wave file, %u data bytes %u samples",
                 dwDataLength,wav->numSamples);
         if (wFormatTag == WAVE_FORMAT_GSM610){
-            st_debug("GSM6.10 format: %u blocks %u padded samples %u padded data bytes",
+            sox_debug("GSM6.10 format: %u blocks %u padded samples %u padded data bytes",
                     blocksWritten, dwSamplesWritten, dwDataLength);
             if (wav->gsmbytecount != dwDataLength)
-                st_warn("help ! internal inconsistency - data_written %u gsmbytecount %u",
+                sox_warn("help ! internal inconsistency - data_written %u gsmbytecount %u",
                         dwDataLength, wav->gsmbytecount);
 
         }
     }
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
-static st_size_t st_wavwrite(ft_t ft, const st_sample_t *buf, st_size_t len) 
+static sox_size_t sox_wavwrite(ft_t ft, const sox_sample_t *buf, sox_size_t len) 
 {
         wav_t   wav = (wav_t) ft->priv;
-        st_ssize_t total_len = len;
+        sox_ssize_t total_len = len;
 
-        ft->st_errno = ST_SUCCESS;
+        ft->sox_errno = SOX_SUCCESS;
 
         switch (wav->formatTag)
         {
@@ -1581,17 +1581,17 @@
             break;
 
         default:
-            len = st_rawwrite(ft, buf, len);
+            len = sox_rawwrite(ft, buf, len);
             wav->numSamples += (len/ft->signal.channels);
             return len;
         }
 }
 
-static int st_wavstopwrite(ft_t ft) 
+static int sox_wavstopwrite(ft_t ft) 
 {
         wav_t   wav = (wav_t) ft->priv;
 
-        ft->st_errno = ST_SUCCESS;
+        ft->sox_errno = SOX_SUCCESS;
 
 
         /* Call this to flush out any remaining data. */
@@ -1613,18 +1613,18 @@
         if (wav->formatTag != WAVE_FORMAT_IMA_ADPCM &&
             wav->formatTag != WAVE_FORMAT_ADPCM &&
             wav->formatTag != WAVE_FORMAT_GSM610)
-            st_rawstopwrite(ft);
+            sox_rawstopwrite(ft);
 
         /* All samples are already written out. */
         /* If file header needs fixing up, for example it needs the */
         /* the number of samples in a field, seek back and write them here. */
         if (!ft->seekable)
-                return ST_EOF;
+                return SOX_EOF;
 
-        if (st_seeki(ft, 0, SEEK_SET) != 0)
+        if (sox_seeki(ft, 0, SEEK_SET) != 0)
         {
-                st_fail_errno(ft,ST_EOF,"Can't rewind output file to rewrite .wav header.");
-                return ST_EOF;
+                sox_fail_errno(ft,SOX_EOF,"Can't rewind output file to rewrite .wav header.");
+                return SOX_EOF;
         }
 
         return (wavwritehdr(ft, 1));
@@ -1682,7 +1682,7 @@
         }
 }
 
-static int st_wavseek(ft_t ft, st_size_t offset) 
+static int sox_wavseek(ft_t ft, sox_size_t offset) 
 {
     wav_t   wav = (wav_t) ft->priv;
     int new_offset, channel_block, alignment;
@@ -1691,12 +1691,12 @@
     {
         case WAVE_FORMAT_IMA_ADPCM:
         case WAVE_FORMAT_ADPCM:
-            st_fail_errno(ft,ST_ENOTSUP,"ADPCM not supported");
+            sox_fail_errno(ft,SOX_ENOTSUP,"ADPCM not supported");
             break;
 
         case WAVE_FORMAT_GSM610:
             {   
-                st_size_t gsmoff;
+                sox_size_t gsmoff;
 
                 /* rounding bytes to blockAlign so that we
                  * don't have to decode partial block. */
@@ -1704,9 +1704,9 @@
                          wav->blockAlign * ft->signal.channels / 2;
                 gsmoff -= gsmoff % (wav->blockAlign * ft->signal.channels);
 
-                ft->st_errno = st_seeki(ft, gsmoff + wav->dataStart, SEEK_SET);
-                if (ft->st_errno != ST_SUCCESS)
-                    return ST_EOF;
+                ft->sox_errno = sox_seeki(ft, gsmoff + wav->dataStart, SEEK_SET);
+                if (ft->sox_errno != SOX_SUCCESS)
+                    return SOX_EOF;
 
                 /* offset is in samples */
                 new_offset = offset;
@@ -1730,14 +1730,14 @@
                 new_offset += (channel_block - alignment);
             new_offset += wav->dataStart;
 
-            ft->st_errno = st_seeki(ft, new_offset, SEEK_SET);
+            ft->sox_errno = sox_seeki(ft, new_offset, SEEK_SET);
 
-            if( ft->st_errno == ST_SUCCESS )
+            if( ft->sox_errno == SOX_SUCCESS )
                 wav->numSamples = (ft->length / ft->signal.channels) -
                                   (new_offset / ft->signal.size / ft->signal.channels);
     }
 
-    return(ft->st_errno);
+    return(ft->sox_errno);
 }
 
 /* Microsoft RIFF */
@@ -1746,20 +1746,20 @@
   NULL
 };
 
-static st_format_t st_wav_format = {
+static sox_format_t sox_wav_format = {
   wavnames,
   NULL,
-  ST_FILE_SEEK | ST_FILE_LIT_END,
-  st_wavstartread,
-  st_wavread,
-  st_wavstopread,
-  st_wavstartwrite,
-  st_wavwrite,
-  st_wavstopwrite,
-  st_wavseek
+  SOX_FILE_SEEK | SOX_FILE_LIT_END,
+  sox_wavstartread,
+  sox_wavread,
+  sox_wavstopread,
+  sox_wavstartwrite,
+  sox_wavwrite,
+  sox_wavstopwrite,
+  sox_wavseek
 };
 
-const st_format_t *st_wav_format_fn()
+const sox_format_t *sox_wav_format_fn()
 {
-    return &st_wav_format;
+    return &sox_wav_format;
 }
--- a/src/wve.c
+++ b/src/wve.c
@@ -3,7 +3,7 @@
  * Richard Caley (R.Caley@ed.ac.uk)
  */
 
-#include "st_i.h"
+#include "sox_i.h"
 #include <string.h>
 #include <errno.h>
 
@@ -18,12 +18,12 @@
     short padding;
     short repeats;
 /* For seeking */
-        st_size_t dataStart;
+        sox_size_t dataStart;
     } *wve_t;
 
 static void wvewriteheader(ft_t ft);
 
-static int st_wveseek(ft_t ft, st_size_t offset)
+static int sox_wveseek(ft_t ft, sox_size_t offset)
 {
     int new_offset, channel_block, alignment;
     wve_t wve = (wve_t)ft->priv;
@@ -40,10 +40,10 @@
         new_offset += (channel_block - alignment);
     new_offset += wve->dataStart;
 
-    return st_seeki(ft, offset, SEEK_SET);
+    return sox_seeki(ft, offset, SEEK_SET);
 }
 
-static int st_wvestartread(ft_t ft)
+static int sox_wvestartread(ft_t ft)
 {
         wve_t p = (wve_t)ft->priv;
         char magic[16];
@@ -53,57 +53,57 @@
         uint16_t trash16;
 
         /* Needed for rawread() */
-        rc = st_rawstartread(ft);
+        rc = sox_rawstartread(ft);
         if (rc)
             return rc;
 
         /* Check the magic word (null-terminated) */
-        st_reads(ft, magic, 16);
+        sox_reads(ft, magic, 16);
         if (strncmp(magic, PSION_MAGIC, 15)==0) {
-                st_debug("Found Psion magic word");
+                sox_debug("Found Psion magic word");
         }
         else
         {
-                st_fail_errno(ft,ST_EHDR,"Psion header doesn't start with magic word\nTry the '.al' file type with '-t al -r 8000 filename'");
-                return (ST_EOF);
+                sox_fail_errno(ft,SOX_EHDR,"Psion header doesn't start with magic word\nTry the '.al' file type with '-t al -r 8000 filename'");
+                return (SOX_EOF);
         }
 
-        st_readw(ft, (unsigned short *)&version);
+        sox_readw(ft, (unsigned short *)&version);
 
         /* Check magic version */
         if (version == PSION_VERSION)
-            st_debug("Found Psion magic word");
+            sox_debug("Found Psion magic word");
         else
         {
-            st_fail_errno(ft,ST_EHDR,"Wrong version in Psion header");
-            return(ST_EOF);
+            sox_fail_errno(ft,SOX_EHDR,"Wrong version in Psion header");
+            return(SOX_EOF);
         }
 
-        st_readdw(ft, &(p->length));
+        sox_readdw(ft, &(p->length));
 
-        st_readw(ft, (unsigned short *)&(p->padding));
+        sox_readw(ft, (unsigned short *)&(p->padding));
 
-        st_readw(ft, (unsigned short *)&(p->repeats));
+        sox_readw(ft, (unsigned short *)&(p->repeats));
 
-        st_readw(ft, (unsigned short *)&trash16);
-        st_readw(ft, (unsigned short *)&trash16);
-        st_readw(ft, (unsigned short *)&trash16);
+        sox_readw(ft, (unsigned short *)&trash16);
+        sox_readw(ft, (unsigned short *)&trash16);
+        sox_readw(ft, (unsigned short *)&trash16);
 
-        ft->signal.encoding = ST_ENCODING_ALAW;
-        ft->signal.size = ST_SIZE_BYTE;
+        ft->signal.encoding = SOX_ENCODING_ALAW;
+        ft->signal.size = SOX_SIZE_BYTE;
 
         if (ft->signal.rate != 0)
-            st_report("WVE must use 8000 sample rate.  Overriding");
+            sox_report("WVE must use 8000 sample rate.  Overriding");
         ft->signal.rate = 8000;
 
-        if (ft->signal.channels != ST_ENCODING_UNKNOWN && ft->signal.channels != 1)
-            st_report("WVE must only supports 1 channel.  Overriding");
+        if (ft->signal.channels != SOX_ENCODING_UNKNOWN && ft->signal.channels != 1)
+            sox_report("WVE must only supports 1 channel.  Overriding");
         ft->signal.channels = 1;
 
-        p->dataStart = st_tell(ft);
+        p->dataStart = sox_tell(ft);
         ft->length = p->length/ft->signal.size;
 
-        return (ST_SUCCESS);
+        return (SOX_SUCCESS);
 }
 
 /* When writing, the header is supposed to contain the number of
@@ -115,15 +115,15 @@
    if it is not, the unspecified size remains in the header
    (this is illegal). */
 
-static int st_wvestartwrite(ft_t ft)
+static int sox_wvestartwrite(ft_t ft)
 {
         wve_t p = (wve_t)ft->priv;
         int rc;
 
         /* Needed for rawwrite() */
-        rc = st_rawstartwrite(ft);
+        rc = sox_rawstartwrite(ft);
         if (rc)
-            return ST_EOF;
+            return SOX_EOF;
 
         p->length = 0;
         if (p->repeats == 0)
@@ -130,42 +130,42 @@
             p->repeats = 1;
 
         if (ft->signal.rate != 0)
-            st_report("WVE must use 8000 sample rate.  Overriding");
+            sox_report("WVE must use 8000 sample rate.  Overriding");
 
         if (ft->signal.channels != 0 && ft->signal.channels != 1)
-            st_report("WVE must only supports 1 channel.  Overriding");
+            sox_report("WVE must only supports 1 channel.  Overriding");
 
-        ft->signal.encoding = ST_ENCODING_ALAW;
-        ft->signal.size = ST_SIZE_BYTE;
+        ft->signal.encoding = SOX_ENCODING_ALAW;
+        ft->signal.size = SOX_SIZE_BYTE;
         ft->signal.rate = 8000;
 
         wvewriteheader(ft);
-        return ST_SUCCESS;
+        return SOX_SUCCESS;
 }
 
-static st_size_t st_wvewrite(ft_t ft, const st_sample_t *buf, st_size_t samp)
+static sox_size_t sox_wvewrite(ft_t ft, const sox_sample_t *buf, sox_size_t samp)
 {
         wve_t p = (wve_t)ft->priv;
         p->length += samp * ft->signal.size;
-        return st_rawwrite(ft, buf, samp);
+        return sox_rawwrite(ft, buf, samp);
 }
 
-static int st_wvestopwrite(ft_t ft)
+static int sox_wvestopwrite(ft_t ft)
 {
 
         /* Call before seeking to flush buffer */
-        st_rawstopwrite(ft);
+        sox_rawstopwrite(ft);
 
         if (!ft->seekable)
         {
-            st_warn("Header will be have invalid file length since file is not seekable");
-            return ST_SUCCESS;
+            sox_warn("Header will be have invalid file length since file is not seekable");
+            return SOX_SUCCESS;
         }
 
-        if (st_seeki(ft, 0, 0) != 0)
+        if (sox_seeki(ft, 0, 0) != 0)
         {
-                st_fail_errno(ft,errno,"Can't rewind output file to rewrite Psion header.");
-                return(ST_EOF);
+                sox_fail_errno(ft,errno,"Can't rewind output file to rewrite Psion header.");
+                return(SOX_EOF);
         }
         wvewriteheader(ft);
 }
@@ -182,19 +182,19 @@
     version=PSION_VERSION;
     zero=0;
 
-    st_writes(ft, magic);
+    sox_writes(ft, magic);
     /* Null terminate string */
-    st_writeb(ft, 0);
+    sox_writeb(ft, 0);
 
-    st_writew(ft, version);
+    sox_writew(ft, version);
 
-    st_writedw(ft, p->length);
-    st_writew(ft, p->padding);
-    st_writew(ft, p->repeats);
+    sox_writedw(ft, p->length);
+    sox_writew(ft, p->padding);
+    sox_writew(ft, p->repeats);
 
-    st_writew(ft, zero);
-    st_writew(ft, zero);
-    st_writew(ft, zero);
+    sox_writew(ft, zero);
+    sox_writew(ft, zero);
+    sox_writew(ft, zero);
 }
 
 /* Psion .wve */
@@ -203,20 +203,20 @@
   NULL
 };
 
-static st_format_t st_wve_format = {
+static sox_format_t sox_wve_format = {
   wvenames,
   NULL,
-  ST_FILE_SEEK | ST_FILE_BIG_END,
-  st_wvestartread,
-  st_rawread,
-  st_rawstopread,
-  st_wvestartwrite,
-  st_wvewrite,
-  st_wvestopwrite,
-  st_wveseek
+  SOX_FILE_SEEK | SOX_FILE_BIG_END,
+  sox_wvestartread,
+  sox_rawread,
+  sox_rawstopread,
+  sox_wvestartwrite,
+  sox_wvewrite,
+  sox_wvestopwrite,
+  sox_wveseek
 };
 
-const st_format_t *st_wve_format_fn(void)
+const sox_format_t *sox_wve_format_fn(void)
 {
-    return &st_wve_format;
+    return &sox_wve_format;
 }
--- a/src/xa.c
+++ b/src/xa.c
@@ -31,7 +31,7 @@
 #include <unistd.h>             /* For SEEK_* defines if not found in stdio */
 #endif
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #define HNIBBLE(byte) (((byte) >> 4) & 0xf)
 #define LNIBBLE(byte) ((byte) & 0xf)
@@ -89,87 +89,87 @@
     }
 }
 
-static int st_xastartread(ft_t ft)
+static int sox_xastartread(ft_t ft)
 {
     xa_t xa = (xa_t) ft->priv;
     char *magic = xa->header.magic;
 
     /* Check for the magic value */
-    if (st_readbuf(ft, xa->header.magic, 1, 4) != 4 ||
+    if (sox_readbuf(ft, xa->header.magic, 1, 4) != 4 ||
         (memcmp("XA\0\0", xa->header.magic, 4) != 0 &&
          memcmp("XAI\0", xa->header.magic, 4) != 0 &&
          memcmp("XAJ\0", xa->header.magic, 4) != 0))
     {
-        st_fail_errno(ft, ST_EHDR, "XA: Header not found");
-        return ST_EOF;
+        sox_fail_errno(ft, SOX_EHDR, "XA: Header not found");
+        return SOX_EOF;
     }
     
     /* Read the rest of the header */
-    if (st_readdw(ft, &xa->header.outSize) != ST_SUCCESS) return ST_EOF;
-    if (st_readw(ft, &xa->header.tag) != ST_SUCCESS) return ST_EOF;
-    if (st_readw(ft, &xa->header.channels) != ST_SUCCESS) return ST_EOF;
-    if (st_readdw(ft, &xa->header.sampleRate) != ST_SUCCESS) return ST_EOF;
-    if (st_readdw(ft, &xa->header.avgByteRate) != ST_SUCCESS) return ST_EOF;
-    if (st_readw(ft, &xa->header.align) != ST_SUCCESS) return ST_EOF;
-    if (st_readw(ft, &xa->header.bits) != ST_SUCCESS) return ST_EOF;
+    if (sox_readdw(ft, &xa->header.outSize) != SOX_SUCCESS) return SOX_EOF;
+    if (sox_readw(ft, &xa->header.tag) != SOX_SUCCESS) return SOX_EOF;
+    if (sox_readw(ft, &xa->header.channels) != SOX_SUCCESS) return SOX_EOF;
+    if (sox_readdw(ft, &xa->header.sampleRate) != SOX_SUCCESS) return SOX_EOF;
+    if (sox_readdw(ft, &xa->header.avgByteRate) != SOX_SUCCESS) return SOX_EOF;
+    if (sox_readw(ft, &xa->header.align) != SOX_SUCCESS) return SOX_EOF;
+    if (sox_readw(ft, &xa->header.bits) != SOX_SUCCESS) return SOX_EOF;
 
     /* Output the data from the header */
-    st_debug("XA Header:");
-    st_debug(" szID:          %02x %02x %02x %02x  |%c%c%c%c|",
+    sox_debug("XA Header:");
+    sox_debug(" szID:          %02x %02x %02x %02x  |%c%c%c%c|",
         magic[0], magic[1], magic[2], magic[3],
         (magic[0] >= 0x20 && magic[0] <= 0x7e) ? magic[0] : '.',
         (magic[1] >= 0x20 && magic[1] <= 0x7e) ? magic[1] : '.',
         (magic[2] >= 0x20 && magic[2] <= 0x7e) ? magic[2] : '.',
         (magic[3] >= 0x20 && magic[3] <= 0x7e) ? magic[3] : '.');
-    st_debug(" dwOutSize:     %u", xa->header.outSize);
-    st_debug(" wTag:          0x%04x", xa->header.tag);
-    st_debug(" wChannels:     %u", xa->header.channels);
-    st_debug(" dwSampleRate:  %u", xa->header.sampleRate);
-    st_debug(" dwAvgByteRate: %u", xa->header.avgByteRate);
-    st_debug(" wAlign:        %u", xa->header.align);
-    st_debug(" wBits:         %u", xa->header.bits);
+    sox_debug(" dwOutSize:     %u", xa->header.outSize);
+    sox_debug(" wTag:          0x%04x", xa->header.tag);
+    sox_debug(" wChannels:     %u", xa->header.channels);
+    sox_debug(" dwSampleRate:  %u", xa->header.sampleRate);
+    sox_debug(" dwAvgByteRate: %u", xa->header.avgByteRate);
+    sox_debug(" wAlign:        %u", xa->header.align);
+    sox_debug(" wBits:         %u", xa->header.bits);
 
-    /* Populate the st_soundstream structure */
-    ft->signal.encoding = ST_ENCODING_SIGN2;
+    /* Populate the sox_soundstream structure */
+    ft->signal.encoding = SOX_ENCODING_SIGN2;
     
     if (ft->signal.size == -1 || ft->signal.size == (xa->header.bits >> 3)) {
         ft->signal.size = xa->header.bits >> 3;
     } else {
-        st_report("User options overriding size read in .xa header");
+        sox_report("User options overriding size read in .xa header");
     }
     
     if (ft->signal.channels == 0 || ft->signal.channels == xa->header.channels) {
         ft->signal.channels = xa->header.channels;
     } else {
-        st_report("User options overriding channels read in .xa header");
+        sox_report("User options overriding channels read in .xa header");
     }
     
     if (ft->signal.rate == 0 || ft->signal.rate == xa->header.sampleRate) {
         ft->signal.rate = xa->header.sampleRate;
     } else {
-        st_report("User options overriding rate read in .xa header");
+        sox_report("User options overriding rate read in .xa header");
     }
     
     /* Check for supported formats */
     if (ft->signal.size != 2) {
-        st_fail_errno(ft, ST_EFMT, "%d-bit sample resolution not supported.",
+        sox_fail_errno(ft, SOX_EFMT, "%d-bit sample resolution not supported.",
             ft->signal.size << 3);
-        return ST_EOF;
+        return SOX_EOF;
     }
     
     /* Validate the header */
     if (xa->header.bits != ft->signal.size << 3) {
-        st_report("Invalid sample resolution %d bits.  Assuming %d bits.",
+        sox_report("Invalid sample resolution %d bits.  Assuming %d bits.",
             xa->header.bits, ft->signal.size << 3);
         xa->header.bits = ft->signal.size << 3;
     }
     if (xa->header.align != ft->signal.size * xa->header.channels) {
-        st_report("Invalid sample alignment value %d.  Assuming %d.",
+        sox_report("Invalid sample alignment value %d.  Assuming %d.",
             xa->header.align, ft->signal.size * xa->header.channels);
         xa->header.align = ft->signal.size * xa->header.channels;
     }
     if (xa->header.avgByteRate != (xa->header.align * xa->header.sampleRate)) {
-        st_report("Invalid dwAvgByteRate value %d.  Assuming %d.",
+        sox_report("Invalid dwAvgByteRate value %d.  Assuming %d.",
             xa->header.avgByteRate, xa->header.align * xa->header.sampleRate);
         xa->header.avgByteRate = xa->header.align * xa->header.sampleRate;
     }
@@ -187,7 +187,7 @@
     /* Final initialization */
     xa->bytesDecoded = 0;
     
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
 /* 
@@ -194,7 +194,7 @@
  * Read up to len samples from a file, converted to signed longs.
  * Return the number of samples read.
  */
-static st_size_t st_xaread(ft_t ft, st_sample_t *buf, st_size_t len)
+static sox_size_t sox_xaread(ft_t ft, sox_sample_t *buf, sox_size_t len)
 {
     xa_t xa = (xa_t) ft->priv;
     int32_t sample;
@@ -201,23 +201,23 @@
     unsigned char inByte;
     size_t i, done, bytes;
 
-    ft->st_errno = ST_SUCCESS;
+    ft->sox_errno = SOX_SUCCESS;
     done = 0;
     while (done < len) {
         if (xa->bufPos >= xa->blockSize) {
             /* Read the next block */
-            bytes = st_readbuf(ft, xa->buf, 1, xa->blockSize);
+            bytes = sox_readbuf(ft, xa->buf, 1, xa->blockSize);
             if (bytes < xa->blockSize) {
-                if (st_eof(ft)) {
+                if (sox_eof(ft)) {
                     if (done > 0) {
                         return done;
                     }
-                    st_fail_errno(ft,ST_EOF,"Premature EOF on .xa input file");
-                    return ST_EOF;
+                    sox_fail_errno(ft,SOX_EOF,"Premature EOF on .xa input file");
+                    return SOX_EOF;
                 } else {
                     /* error */
-                    st_fail_errno(ft,ST_EOF,"read error on input stream");
-                    return ST_EOF;
+                    sox_fail_errno(ft,SOX_EOF,"read error on input stream");
+                    return SOX_EOF;
                 }
             }
             xa->bufPos = 0;
@@ -242,7 +242,7 @@
                 xa->state[i].prevSample = xa->state[i].curSample;
                 xa->state[i].curSample = sample;
                 
-                buf[done++] = ST_SIGNED_WORD_TO_SAMPLE(sample,);
+                buf[done++] = SOX_SIGNED_WORD_TO_SAMPLE(sample,);
                 xa->bytesDecoded += ft->signal.size;
             }
             for (i = 0; i < ft->signal.channels && done < len; i++) {
@@ -256,7 +256,7 @@
                 xa->state[i].prevSample = xa->state[i].curSample;
                 xa->state[i].curSample = sample;
                 
-                buf[done++] = ST_SIGNED_WORD_TO_SAMPLE(sample,);
+                buf[done++] = SOX_SIGNED_WORD_TO_SAMPLE(sample,);
                 xa->bytesDecoded += ft->signal.size;
             }
 
@@ -264,16 +264,16 @@
         }
     }
     if (done == 0) {
-        return ST_EOF;
+        return SOX_EOF;
     }
     return done;
 }
 
-static int st_xastopread(ft_t ft)
+static int sox_xastopread(ft_t ft)
 {
     xa_t xa = (xa_t) ft->priv;
 
-    ft->st_errno = ST_SUCCESS;
+    ft->sox_errno = SOX_SUCCESS;
 
     /* Free memory */
     free(xa->buf);
@@ -281,30 +281,30 @@
     free(xa->state);
     xa->state = NULL;
     
-    return ST_SUCCESS;
+    return SOX_SUCCESS;
 }
 
-static int st_xastartwrite(ft_t ft)
+static int sox_xastartwrite(ft_t ft)
 {
-    st_fail_errno(ft, ST_ENOTSUP, ".XA writing not supported");
-    return ST_EOF;
+    sox_fail_errno(ft, SOX_ENOTSUP, ".XA writing not supported");
+    return SOX_EOF;
 }
 
-static st_size_t st_xawrite(ft_t ft, const st_sample_t *buf UNUSED, st_size_t len UNUSED)
+static sox_size_t sox_xawrite(ft_t ft, const sox_sample_t *buf UNUSED, sox_size_t len UNUSED)
 {
-    st_fail_errno(ft, ST_ENOTSUP, ".XA writing not supported");
-    return ST_EOF;
+    sox_fail_errno(ft, SOX_ENOTSUP, ".XA writing not supported");
+    return SOX_EOF;
 }
 
-static int st_xastopwrite(ft_t ft)
+static int sox_xastopwrite(ft_t ft)
 {
-    st_fail_errno(ft, ST_ENOTSUP, ".XA writing not supported");
-    return ST_EOF;
+    sox_fail_errno(ft, SOX_ENOTSUP, ".XA writing not supported");
+    return SOX_EOF;
 }
 
-static int st_xaseek(ft_t ft, st_size_t offset)
+static int sox_xaseek(ft_t ft, sox_size_t offset)
 {
-    return st_format_nothing_seek(ft, offset);
+    return sox_format_nothing_seek(ft, offset);
 }
 
 /* Maxis .xa */
@@ -313,20 +313,20 @@
     NULL
 };
 
-st_format_t st_xa_format = {
+sox_format_t sox_xa_format = {
   xanames,
   NULL,
-  ST_FILE_LIT_END,
-  st_xastartread,
-  st_xaread,
-  st_xastopread,
-  st_xastartwrite,
-  st_xawrite,
-  st_xastopwrite,
-  st_xaseek
+  SOX_FILE_LIT_END,
+  sox_xastartread,
+  sox_xaread,
+  sox_xastopread,
+  sox_xastartwrite,
+  sox_xawrite,
+  sox_xastopwrite,
+  sox_xaseek
 };
 
-const st_format_t *st_xa_format_fn(void)
+const sox_format_t *sox_xa_format_fn(void)
 {
-  return &st_xa_format;
+  return &sox_xa_format;
 }
--- a/src/xmalloc.c
+++ b/src/xmalloc.c
@@ -19,7 +19,7 @@
    Software Foundation, Fifth Floor, 51 Franklin Street, Boston, MA
    02111-1301, USA.  */
 
-#include "st_i.h"
+#include "sox_i.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -37,7 +37,7 @@
     return NULL;
 
   if ((ptr = realloc(ptr, newsize)) == NULL) {
-    st_fail("out of memory");
+    sox_fail("out of memory");
     exit(2);
   }
 
@@ -52,7 +52,7 @@
   void *ptr = calloc(nmemb, size);
 
   if (ptr == NULL) {
-    st_fail("out of memory");
+    sox_fail("out of memory");
     exit(2);
   }
 
@@ -71,7 +71,7 @@
 
   t = strdup(s);
   if (t == NULL) {
-    st_fail("out of memory");
+    sox_fail("out of memory");
     exit(2);
   }