shithub: sox

Download patch

ref: b9f0992bf01ed92ecbe08d1576f693e608164c69
parent: 5ac69af1fada28257ab8a5118c46d6680902fb8e
author: cbagwell <cbagwell>
date: Wed Jun 7 14:35:38 EDT 2000

Adding patch to rename fail() and warn() functions to be nicer to the
namespace.

--- a/README
+++ b/README
@@ -42,6 +42,7 @@
   o Apply a high-pass filter
   o Apply a low-pass filter
   o Pan sound between channels
+  o Change the pitch of a sound file
   o Display a list of loops in a file
   o Add masking noise to a signal
   o Apply a phaser effect
@@ -53,6 +54,7 @@
   o Reverse the sound samples (to search for Satanic messages ;-)
   o Change the speed of samples being played (like speeding up the motor
     on a tape recorder)
+  o Stretch/shorten the duration of a sound file.
   o Convert from mono to stereo
   o Swap stereo channels
   o Display general stats on a sound sample
--- a/configure.in
+++ b/configure.in
@@ -63,7 +63,7 @@
 		CFLAGS="$CFLAGS -D_HPUX_SOURCE"
 		;;
 
-	*next*|*rhapsody* )
+	*next*|*rhapsody*|*apple*darwin* )
 		CFLAGS="$CFLAGS -DNeXT"
 		;;
 
--- a/pick.c
+++ b/pick.c
@@ -81,18 +81,18 @@
 
 	if (effp->outinfo.channels != 1)  /* must be one output channel */
 	{
-	   fail("Can't pick with other than 1 output channel."); 
+	   st_fail("Can't pick with other than 1 output channel."); 
 	   return (ST_EOF);
 	}
 	if (effp->ininfo.channels != 2 && effp->ininfo.channels != 4)
 	{
-	        fail("Can't pick with other than 2 or 4 input channels.");
+	        st_fail("Can't pick with other than 2 or 4 input channels.");
 		return (ST_EOF);
 	}
         if (effp->ininfo.channels == 2) {  /* check for valid option */
 	   if (pick->chan == -1 || pick->chan == CHAN_3 || pick->chan == CHAN_4)
 	   {
-   	      fail("Must specify channel to pick: '-l', '-r', '-1', or '-2'.");
+   	      st_fail("Must specify channel to pick: '-l', '-r', '-1', or '-2'.");
 	      return (ST_EOF);
 	   }
 	}
@@ -99,7 +99,7 @@
 	else  /* must be 4 channels; check for valid option */
 	   if (pick->chan == -1)
 	   {
-	      fail("Must specify channel to pick: '-1', '-2', '-3', or '-4'.");
+	      st_fail("Must specify channel to pick: '-1', '-2', '-3', or '-4'.");
 	      return (ST_EOF);
 	   }
 	return (ST_SUCCESS);
--- a/sox.1
+++ b/sox.1
@@ -117,7 +117,7 @@
 .br
 	stretch [ \fIfactor [ window fade shift fading ]\fB
 .br
-	swap [ \fI1 2 3 4\fB ]
+	swap [ \fI1 2\fB | \fI1 2 3 4\fB ]
 .br
 	vibro \fIspeed \fB[ \fIdepth\fB ]
 .br
@@ -918,10 +918,15 @@
 ratio, in [0.0 0.5]. The amount of a fade's default depends on factor
 and shift.
 .TP 10
-swap [ \fI1 2 3 4\fB ]
-Swap channels in multi-channel sound files.  In files with more than 2
-channels you may specify the order that the channels should be rearranged
-in.
+swap [ \fI1 2\fB | \fI1 2 3 4\fB ]
+Swap channels in multi-channel sound files.  Optionally, you may
+specify the channel order you would like the output in.  This defaults
+to output channel 2 and then 1 for stereo and 2, 1, 4, 3 for quad-channels.  
+An interesting
+feature is that you may duplicate a given channel by overwriting another.
+This is done by repeating an output channel on the command line.  For example,
+swap 2 2 will overwrite channel 1 with channel 2's data; creating a stereo
+file with both channels containing the same audio data.
 .TP 10
 vibro \fIspeed \fB [ \fIdepth\fB ]
 Add the world-famous Fender Vibro-Champ sound
--- a/split.c
+++ b/split.c
@@ -32,7 +32,7 @@
 {
 	if (n)
 	{
-		fail("Split effect takes no options.");
+		st_fail("Split effect takes no options.");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
@@ -59,7 +59,7 @@
 			}
 			break;
 	}
-	fail("Can't split %d channels into %d channels",
+	st_fail("Can't split %d channels into %d channels",
 		effp->ininfo.channels, effp->outinfo.channels);
 	return (ST_EOF);
 }
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -60,13 +60,13 @@
 	/* read FORM chunk */
 	if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "FORM", 4) != 0)
 	{
-		st_fail(ft, ST_EHDR, "Header did not begin with magic word 'FORM'");
+		st_fail_errno(ft, ST_EHDR, "Header did not begin with magic word 'FORM'");
 		return(ST_EOF);
 	}
 	st_readdw(ft, &totalsize);
 	if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "8SVX", 4) != 0)
 	{
-		st_fail(ft, ST_EHDR, "'FORM' chunk does not specify '8SVX' as type");
+		st_fail_errno(ft, ST_EHDR, "'FORM' chunk does not specify '8SVX' as type");
 		return(ST_EOF);
 	}
 
@@ -76,7 +76,7 @@
 			st_readdw(ft, &chunksize);
 			if (chunksize != 20)
 			{
-				st_fail(ft, ST_EHDR, "VHDR chunk has bad size");
+				st_fail_errno(ft, ST_EHDR, "VHDR chunk has bad size");
 				return(ST_EOF);
 			}
 			fseek(ft->fp,12,SEEK_CUR);
@@ -85,7 +85,7 @@
 			fread(buf,1,1,ft->fp);
 			if (buf[0] != 0)
 			{
-				st_fail(ft, ST_EFMT, "Unsupported data compression");
+				st_fail_errno(ft, ST_EFMT, "Unsupported data compression");
 				return(ST_EOF);
 			}
 			fseek(ft->fp,4,SEEK_CUR);
@@ -99,17 +99,17 @@
 			chunk_buf = (char *) malloc(chunksize + 2);
 			if (chunk_buf == 0)
 			{
-			    st_fail(ft, ST_ENOMEM, "Unable to alloc memory");
+			    st_fail_errno(ft, ST_ENOMEM, "Unable to alloc memory");
 			    return(ST_EOF);
 			}
 			if (fread(chunk_buf,1,(size_t)chunksize,ft->fp) 
 					!= chunksize)
 			{
-				st_fail(ft, ST_EHDR, "Couldn't read all of header");
+				st_fail_errno(ft, ST_EHDR, "Couldn't read all of header");
 				return(ST_EOF);
 			}
 			chunk_buf[chunksize] = '\0';
-			report ("%s",chunk_buf);
+			st_report("%s",chunk_buf);
 			free(chunk_buf);
 
 			continue;
@@ -122,17 +122,17 @@
 			chunk_buf = (char *) malloc(chunksize + 1);
 			if (chunk_buf == 0)
 			{
-			    st_fail(ft, ST_ENOMEM, "Unable to alloc memory");
+			    st_fail_errno(ft, ST_ENOMEM, "Unable to alloc memory");
 			    return(ST_EOF);
 			}
 			if (fread (chunk_buf,1,(size_t)chunksize,ft->fp) 
 					!= chunksize)
 			{
-				st_fail(ft, ST_EHDR, "Couldn't read all of header");
+				st_fail_errno(ft, ST_EHDR, "Couldn't read all of header");
 				return(ST_EOF);
 			}
 			chunk_buf[chunksize] = '\0';
-			report ("%s",chunk_buf);
+			st_report("%s",chunk_buf);
 			free(chunk_buf);
 
 			continue;
@@ -142,7 +142,7 @@
 			st_readdw(ft, &chunksize);
 			if (chunksize != 4) 
 			{
-				st_fail(ft, ST_EHDR, "Couldn't read all of header");
+				st_fail_errno(ft, ST_EHDR, "Couldn't read all of header");
 				return(ST_EOF);
 			}
 			st_readdw(ft, &channels);
@@ -165,12 +165,12 @@
 
 	if (rate == 0)
 	{
-		st_fail(ft, ST_ERATE, "Invalid sample rate");
+		st_fail_errno(ft, ST_ERATE, "Invalid sample rate");
 		return(ST_EOF);
 	}
 	if (strncmp(buf,"BODY",4) != 0)
 	{
-		st_fail(ft, ST_EHDR, "BODY chunk not found");
+		st_fail_errno(ft, ST_EHDR, "BODY chunk not found");
 		return(ST_EOF);
 	}
 	st_readdw(ft, &(p->nsamples));
@@ -187,7 +187,7 @@
 	for (i = 1; i < channels; i++) {
 		if ((p->ch[i] = fopen(ft->filename, READBINARY)) == NULL)
 		{
-			st_fail(ft,errno,"Can't open channel file '%s'",
+			st_fail_errno(ft,errno,"Can't open channel file '%s'",
 				ft->filename);
 			return(ST_EOF);
 		}
@@ -195,12 +195,12 @@
 		/* position channel files */
 		if (fseek(p->ch[i],chan1_pos,SEEK_SET))
 		{
-		    st_fail (ft,errno,"Can't position channel %d",i);
+		    st_fail_errno (ft,errno,"Can't position channel %d",i);
 		    return(ST_EOF);
 		}
 		if (fseek(p->ch[i],p->nsamples/channels*i,SEEK_CUR))
 		{
-		    st_fail (ft,errno,"Can't seek channel %d",i);
+		    st_fail_errno (ft,errno,"Can't seek channel %d",i);
 		    return(ST_EOF);
 		}
 	}
@@ -277,7 +277,7 @@
 	for (i = 1; i < ft->info.channels; i++) {
 		if ((p->ch[i] = tmpfile()) == NULL)
 		{
-			st_fail(ft,errno,"Can't open channel output file");
+			st_fail_errno(ft,errno,"Can't open channel output file");
 			return(ST_EOF);
 		}
 	}
@@ -336,7 +336,7 @@
 	for (i = 1; i < ft->info.channels; i++) {
 		if (fseek (p->ch[i], 0L, 0))
 		{
-			st_fail (ft,errno,"Can't rewind channel output file %d",i);
+			st_fail_errno (ft,errno,"Can't rewind channel output file %d",i);
 			return(ST_EOF);
 		}
 		while (!feof(p->ch[i])) {
@@ -353,7 +353,7 @@
 	/* fixup file sizes in header */
 	if (fseek(ft->fp, 0L, 0) != 0)
 	{
-		st_fail(ft,errno,"can't rewind output file to rewrite 8SVX header");
+		st_fail_errno(ft,errno,"can't rewind output file to rewrite 8SVX header");
 		return(ST_EOF);
 	}
 	svxwriteheader(ft, p->nsamples);
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -113,13 +113,13 @@
 	/* FORM chunk */
 	if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "FORM", 4) != 0)
 	{
-		fail("AIFF header does not begin with magic word 'FORM'");
+		st_fail("AIFF header does not begin with magic word 'FORM'");
 		return(ST_EOF);
 	}
 	st_readdw(ft, &totalsize);
 	if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "AIFF", 4) != 0)
 	{
-		fail("AIFF 'FORM' chunk does not specify 'AIFF' as type");
+		st_fail("AIFF 'FORM' chunk does not specify 'AIFF' as type");
 		return(ST_EOF);
 	}
 
@@ -133,7 +133,7 @@
 				break;
 			else
 			{
-				fail("Missing SSND chunk in AIFF file");
+				st_fail("Missing SSND chunk in AIFF file");
 				return(ST_EOF);
 			}
 		}
@@ -142,7 +142,7 @@
 			st_readdw(ft, &chunksize);
 			if (chunksize != 18)
 			{
-				fail("AIFF COMM chunk has bad size");
+				st_fail("AIFF COMM chunk has bad size");
 				return(ST_EOF);
 			}
 			st_readw(ft, &channels);
@@ -293,7 +293,7 @@
 				break;
 			if (feof(ft->fp))
 				break;
-			report("AIFFstartread: ignoring '%s' chunk\n", buf);
+			st_report("AIFFstartread: ignoring '%s' chunk\n", buf);
 			st_readdw(ft, &chunksize);
 			if (feof(ft->fp))
 				break;
@@ -318,7 +318,7 @@
 			fseek(ft->fp, seekto, SEEK_SET);
 		else
 		{
-			fail("AIFF: no sound data on input file");
+			st_fail("AIFF: no sound data on input file");
 			return(ST_EOF);
 		}
 	}
@@ -325,13 +325,13 @@
 	/* SSND chunk just read */
 	if (blocksize != 0)
 	{
-		fail("AIFF header specifies nonzero blocksize?!?!");
+		st_fail("AIFF header specifies nonzero blocksize?!?!");
 		return(ST_EOF);
 	}
 	while ((LONG) (--offset) >= 0) {
 		if (st_readb(ft, (unsigned char *)&trash) == ST_EOF)
 		{
-			fail("unexpected EOF while skipping AIFF offset");
+			st_fail("unexpected EOF while skipping AIFF offset");
 			return(ST_EOF);
 		}
 	}
@@ -348,7 +348,7 @@
 			ft->info.size = ST_SIZE_WORD;
 			break;
 		default:
-			fail("unsupported sample size in AIFF header: %d", bits);
+			st_fail("unsupported sample size in AIFF header: %d", bits);
 			return(ST_EOF);
 			/*NOTREACHED*/
 		}
@@ -357,9 +357,9 @@
 			|| (ft->info.rate == -1)
 			|| (ft->info.encoding == -1)
 			|| (ft->info.size == -1)) {
-		  report("You must specify # channels, sample rate, signed/unsigned,\n");
-		  report("and 8/16 on the command line.");
-		  fail("Bogus AIFF file: no COMM section.");
+		  st_report("You must specify # channels, sample rate, signed/unsigned,\n");
+		  st_report("and 8/16 on the command line.");
+		  st_fail("Bogus AIFF file: no COMM section.");
 		  return(ST_EOF);
 		}
 
@@ -369,12 +369,12 @@
 
 	if (foundmark && !foundinstr)
 	{
-		fail("Bogus AIFF file: MARKers but no INSTrument.");
+		st_fail("Bogus AIFF file: MARKers but no INSTrument.");
 		return(ST_EOF);
 	}
 	if (!foundmark && foundinstr)
 	{
-		fail("Bogus AIFF file: INSTrument but no MARKers.");
+		st_fail("Bogus AIFF file: INSTrument but no MARKers.");
 		return(ST_EOF);
 	}
 	if (foundmark && foundinstr) {
@@ -459,12 +459,12 @@
   *text = (char *) malloc((size_t) chunksize + 1);
   if (*text == NULL)
   {
-    fail("AIFF: Couldn't allocate %s header", chunkDescription);
+    st_fail("AIFF: Couldn't allocate %s header", chunkDescription);
     return(ST_EOF);
   }
   if (fread(*text, 1, chunksize, ft->fp) != chunksize)
   {
-    fail("AIFF: Unexpected EOF in %s header", chunkDescription);
+    st_fail("AIFF: Unexpected EOF in %s header", chunkDescription);
     return(ST_EOF);
   }
   *(*text + chunksize) = '\0';
@@ -474,7 +474,7 @@
 		char c;
 		if (fread(&c, 1, 1, ft->fp) != 1)
 		{
-			fail("AIFF: Unexpected EOF in %s header", chunkDescription);
+			st_fail("AIFF: Unexpected EOF in %s header", chunkDescription);
 			return(ST_EOF);
 		}
 	}
@@ -516,10 +516,10 @@
 		if (feof(ft->fp))
 			break;
 		buf[4] = '\0';
-		warn("Ignoring AIFF tail chunk: '%s', %d bytes long\n", 
+		st_warn("Ignoring AIFF tail chunk: '%s', %d bytes long\n", 
 			buf, chunksize);
 		if (! strcmp(buf, "MARK") || ! strcmp(buf, "INST"))
-			warn("	You're stripping MIDI/loop info!\n");
+			st_warn("	You're stripping MIDI/loop info!\n");
 		while ((LONG) (--chunksize) >= 0) 
 		{
 			if (st_readb(ft, (unsigned char *)&trash) == ST_EOF)
@@ -568,7 +568,7 @@
 	if ((ft->info.encoding == ST_ENCODING_ULAW ||
 	     ft->info.encoding == ST_ENCODING_ALAW) && 
 	    ft->info.size == ST_SIZE_BYTE) {
-		report("expanding 8-bit u-law to 16 bits");
+		st_report("expanding 8-bit u-law to 16 bits");
 		ft->info.size = ST_SIZE_WORD;
 	}
 	ft->info.encoding = ST_ENCODING_SIGN2; /* We have a fixed encoding */
@@ -607,12 +607,12 @@
 
 	if (!ft->seekable)
 	{
-	    fail("Non-seekable file.");
+	    st_fail("Non-seekable file.");
 	    return(ST_EOF);
 	}
 	if (fseek(ft->fp, 0L, SEEK_SET) != 0)
 	{
-		fail("can't rewind output file to rewrite AIFF header");
+		st_fail("can't rewind output file to rewrite AIFF header");
 		return(ST_EOF);
 	}
 	return(aiffwriteheader(ft, p->nsamples / ft->info.channels));
@@ -640,7 +640,7 @@
 		bits = 16;
 	else
 	{
-		fail("unsupported output encoding/size for AIFF header");
+		st_fail("unsupported output encoding/size for AIFF header");
 		return(ST_EOF);
 	}
 
@@ -733,7 +733,7 @@
 	char buf[10];
 	if (fread(buf, 1, 10, ft->fp) != 10)
 	{
-		fail("EOF while reading IEEE extended number");
+		st_fail("EOF while reading IEEE extended number");
 		return(ST_EOF);
 	}
 	return ConvertFromIeeeExtended(buf);
@@ -746,7 +746,7 @@
 	char buf[10];
 	ConvertToIeeeExtended(x, buf);
 	/*
-	report("converted %g to %o %o %o %o %o %o %o %o %o %o",
+	st_report("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]);
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -44,7 +44,7 @@
     ft->file.eof = 0;
     ft->file.size = c_info.buffer_size;
     if ((ft->file.buf = malloc (ft->file.size)) == NULL) {
-	fail("unable to allocate output buffer of size %d", ft->file.size);
+	st_fail("unable to allocate output buffer of size %d", ft->file.size);
 	return (ST_EOF);
     }
     if (ft->info.rate < c_info.min_rate) ft->info.rate = 2 * c_info.min_rate;
@@ -69,7 +69,7 @@
 	    case ST_ENCODING_SIGN2:
 		if (!(c_info.hw_formats & SND_PCM_FMT_S8))
 		{
-		    fail("ALSA driver does not support signed byte samples");
+		    st_fail("ALSA driver does not support signed byte samples");
 		    return(ST_EOF);
 		}
 		fmt = SND_PCM_SFMT_S8;
@@ -77,13 +77,13 @@
 	    case ST_ENCODING_UNSIGNED:
 		if (!(c_info.hw_formats & SND_PCM_FMT_U8))
 		{
-		    fail("ALSA driver does not support unsigned byte samples");
+		    st_fail("ALSA driver does not support unsigned byte samples");
 		    return(ST_EOF);
 		}
 		fmt = SND_PCM_SFMT_U8;
 		break;
 	    default:
-		fail("Hardware does not support %s output", st_encodings_str[ft->info.encoding]);
+		st_fail("Hardware does not support %s output", st_encodings_str[ft->info.encoding]);
 		return(ST_EOF);
 		break;
 	}
@@ -93,16 +93,16 @@
 	{
 	    case ST_ENCODING_SIGN2:
 		if (!(c_info.hw_formats & SND_PCM_FMT_S16_LE))
-		    fail("ALSA driver does not support signed word samples");
+		    st_fail("ALSA driver does not support signed word samples");
 		fmt = SND_PCM_SFMT_S16_LE;
 		break;
 	    case ST_ENCODING_UNSIGNED:
 		if (!(c_info.hw_formats & SND_PCM_FMT_U16_LE))
-		    fail("ALSA driver does not support unsigned word samples");
+		    st_fail("ALSA driver does not support unsigned word samples");
 		fmt = SND_PCM_SFMT_U16_LE;
 		break;
 	    default:
-		fail("Hardware does not support %s output", st_encodings_str[ft->info.encoding]);
+		st_fail("Hardware does not support %s output", st_encodings_str[ft->info.encoding]);
 		return(ST_EOF);
 		break;
 	}
@@ -147,7 +147,7 @@
     ft->file.eof = 0;
     ft->file.size = p_info.buffer_size;
     if ((ft->file.buf = malloc (ft->file.size)) == NULL) {
-	fail("unable to allocate output buffer of size %d", ft->file.size);
+	st_fail("unable to allocate output buffer of size %d", ft->file.size);
 	return(ST_EOF);
     }
     if (ft->info.rate < p_info.min_rate) ft->info.rate = 2 * p_info.min_rate;
@@ -172,7 +172,7 @@
 	    case ST_ENCODING_SIGN2:
 		if (!(p_info.hw_formats & SND_PCM_FMT_S8))
 		{
-		    fail("ALSA driver does not support signed byte samples");
+		    st_fail("ALSA driver does not support signed byte samples");
 		    return (ST_EOF);
 		}
 		fmt = SND_PCM_SFMT_S8;
@@ -180,13 +180,13 @@
 	    case ST_ENCODING_UNSIGNED:
 		if (!(p_info.hw_formats & SND_PCM_FMT_U8))
 		{
-		    fail("ALSA driver does not support unsigned byte samples");
+		    st_fail("ALSA driver does not support unsigned byte samples");
 		    return (ST_EOF);
 		}
 		fmt = SND_PCM_SFMT_U8;
 		break;
 	    default:
-		fail("Hardware does not support %s output", st_encodings_str[ft->info.encoding]);
+		st_fail("Hardware does not support %s output", st_encodings_str[ft->info.encoding]);
 		return(ST_EOF);
 		break;
 	}
@@ -197,7 +197,7 @@
 	    case ST_ENCODING_SIGN2:
 		if (!(p_info.hw_formats & SND_PCM_FMT_S16_LE))
 		{
-		    fail("ALSA driver does not support signed word samples");
+		    st_fail("ALSA driver does not support signed word samples");
 		    return (ST_EOF);
 		}
 		fmt = SND_PCM_SFMT_S16_LE;
@@ -205,13 +205,13 @@
 	    case ST_ENCODING_UNSIGNED:
 		if (!(p_info.hw_formats & SND_PCM_FMT_U16_LE))
 		{
-		    fail("ALSA driver does not support unsigned word samples");
+		    st_fail("ALSA driver does not support unsigned word samples");
 		    return(ST_EOF);
 		}
 		fmt = SND_PCM_SFMT_U16_LE;
 		break;
 	    default:
-		fail("Hardware does not support %s output", st_encodings_str[ft->info.encoding]);
+		st_fail("Hardware does not support %s output", st_encodings_str[ft->info.encoding]);
 		return(ST_EOF);
 		break;
 	}
--- a/src/au.c
+++ b/src/au.c
@@ -102,21 +102,21 @@
 		 * endianess.  Its not hurting though.
 		 */
 		ft->swap = ft->swap ? 0 : 1;
-		report("Found inverted DEC magic word.  Swapping bytes.");
+		st_report("Found inverted DEC magic word.  Swapping bytes.");
 	}
 	else if (magic == SUN_INV_MAGIC) {
 		ft->swap = ft->swap ? 0 : 1;
-		report("Found inverted Sun/NeXT magic word. Swapping bytes.");
+		st_report("Found inverted Sun/NeXT magic word. Swapping bytes.");
 	}
 	else if (magic == SUN_MAGIC) {
-		report("Found Sun/NeXT magic word");
+		st_report("Found Sun/NeXT magic word");
 	}
 	else if (magic == DEC_MAGIC) {
-		report("Found DEC magic word");
+		st_report("Found DEC magic word");
 	}
 	else
 	{
-		fail("Sun/NeXT/DEC header doesn't start with magic word\nTry the '.ul' file type with '-t ul -r 8000 filename'");
+		st_fail("Sun/NeXT/DEC header doesn't start with magic word\nTry the '.ul' file type with '-t ul -r 8000 filename'");
 		return(ST_EOF);
 	}
 
@@ -124,7 +124,7 @@
 	st_readdw(ft, &hdr_size);
 	if (hdr_size < SUN_HDRSIZE)
 	{
-		fail("Sun/NeXT header size too small.");
+		st_fail("Sun/NeXT header size too small.");
 		return(0);
 	}
 
@@ -178,8 +178,8 @@
 		p->dec_bits = 5;
 		break;
 	default:
-		report("encoding: 0x%lx", encoding);
-		fail("Unsupported encoding in Sun/NeXT header.\nOnly U-law, signed bytes, signed words, and ADPCM are supported.");
+		st_report("encoding: 0x%lx", encoding);
+		st_fail("Unsupported encoding in Sun/NeXT header.\nOnly U-law, signed bytes, signed words, and ADPCM are supported.");
 		return(ST_EOF);
 	}
 
@@ -199,13 +199,13 @@
 		    	st_readb(ft, &(buf[i]));
 			if (feof(ft->fp))
 			{
-				fail("Unexpected EOF in Sun/NeXT header info.");
+				st_fail("Unexpected EOF in Sun/NeXT header info.");
 				return(ST_EOF);
 			}
 		}
 		buf[i] = '\0';
 		ft->comment = buf;
-		report("Input file %s: Sun header info: %s", ft->filename, buf);
+		st_report("Input file %s: Sun header info: %s", ft->filename, buf);
 	}
 	return(ST_SUCCESS);
 }
@@ -320,7 +320,7 @@
 	{
 	  if (fseek(ft->fp, 0L, 0) != 0)
 	  {
-		fail("Can't rewind output file to rewrite Sun header.");
+		st_fail("Can't rewind output file to rewrite Sun header.");
 		return(ST_EOF);
 	  }
 	  auwriteheader(ft, p->data_size);
@@ -351,9 +351,9 @@
 		 ft->info.size == ST_SIZE_WORD)
 		encoding = SUN_LIN_16;
 	else {
-		report("Unsupported output encoding/size for Sun/NeXT header or .AU format not specified.");
-		report("Only U-law, A-law signed bytes, and signed words are supported.");
-		report("Defaulting to 8khz u-law\n");
+		st_report("Unsupported output encoding/size for Sun/NeXT header or .AU format not specified.");
+		st_report("Only U-law, A-law signed bytes, and signed words are supported.");
+		st_report("Defaulting to 8khz u-law\n");
 		encoding = SUN_ULAW;
 		ft->info.encoding = ST_ENCODING_ULAW;
 		ft->info.size = ST_SIZE_BYTE;
--- a/src/auto.c
+++ b/src/auto.c
@@ -24,12 +24,12 @@
 	char header[132];
 	if (!ft->seekable)
 	{
-		fail("Type AUTO input must be a file, not a pipe");
+		st_fail("Type AUTO input must be a file, not a pipe");
 		return(ST_EOF);
 	}
 	if (fread(header, 1, sizeof(header), ft->fp) != sizeof(header))
 	{
-		fail("Type AUTO detects short file");
+		st_fail("Type AUTO detects short file");
 		return(ST_EOF);
 	}
 	fseek(ft->fp, 0L - sizeof header, 1); /* Seek back */
@@ -77,7 +77,7 @@
                 ft->info.size = ST_SIZE_BYTE;
                 ft->info.encoding = ST_ENCODING_UNSIGNED;
                 }
-	report("Type AUTO changed to %s", type);
+	st_report("Type AUTO changed to %s", type);
 	ft->filetype = type;
 	st_gettype(ft); /* Change ft->h to the new format */
 	(* ft->h->startread)(ft);
@@ -87,6 +87,6 @@
 int st_autostartwrite(ft) 
 ft_t ft;
 {
-	fail("Type AUTO can only be used for input!");
+	st_fail("Type AUTO can only be used for input!");
 	return(ST_EOF);
 }
--- a/src/avg.c
+++ b/src/avg.c
@@ -51,7 +51,7 @@
 			avg->mix = MIX_RIGHT;
 		else
 		{
-			fail("Usage: avg [ -l | -r ]");
+			st_fail("Usage: avg [ -l | -r ]");
 			return (ST_EOF);
 		}
 	}
@@ -68,7 +68,7 @@
         if ((effp->ininfo.channels == effp->outinfo.channels) ||
 	    effp->outinfo.channels == -1)
 	{
-	    fail("Output must have different number of channels to use avg effect");
+	    st_fail("Output must have different number of channels to use avg effect");
 	    return(ST_EOF);
 	}
 
@@ -103,7 +103,7 @@
 	default:
 		break;
 	}	
-	fail("Can't average %d channels into %d channels",
+	st_fail("Can't average %d channels into %d channels",
 		effp->ininfo.channels, effp->outinfo.channels);
 	return (ST_EOF);
 }
--- a/src/avr.c
+++ b/src/avr.c
@@ -86,7 +86,7 @@
   st_reads(ft, avr->magic, 4);
 
   if (strncmp (avr->magic, AVR_MAGIC, 4)) {
-    fail ("AVR: unknown header");
+    st_fail("AVR: unknown header");
     return(ST_EOF);
   }
 
@@ -108,7 +108,7 @@
     ft->info.size = ST_SIZE_WORD;
   }
   else {
-    fail ("AVR: unsupported sample resolution");
+    st_fail("AVR: unsupported sample resolution");
     return(0);
   }
 
@@ -169,7 +169,7 @@
   }
 
   if (!ft->seekable) {
-    fail ("AVR: file is not seekable");
+    st_fail("AVR: file is not seekable");
     return(ST_EOF);
   }
 
@@ -198,7 +198,7 @@
     st_writew (ft, 0xffff);
   }
   else {
-    fail ("AVR: number of channels not supported");
+    st_fail("AVR: number of channels not supported");
     return(0);
   }
 
@@ -210,7 +210,7 @@
     st_writew (ft, 16);
   }
   else {
-    fail ("AVR: unsupported sample resolution");
+    st_fail("AVR: unsupported sample resolution");
     return(ST_EOF);
   }
 
@@ -222,7 +222,7 @@
     st_writew (ft, 0);
   }
   else {
-    fail ("AVR: unsupported encoding");
+    st_fail("AVR: unsupported encoding");
     return(ST_EOF);
   }
 
--- a/src/band.c
+++ b/src/band.c
@@ -74,13 +74,13 @@
 	}
 	if ((n < 1) || !sscanf(argv[0], "%f", &band->center))
 	{
-		fail("Usage: band [ -n ] center [ width ]");
+		st_fail("Usage: band [ -n ] center [ width ]");
 		return (ST_EOF);
 	}
 	band->width = band->center / 2;
 	if ((n >= 2) && !sscanf(argv[1], "%f", &band->width))
 	{
-		fail("Usage: band [ -n ] center [ width ]");
+		st_fail("Usage: band [ -n ] center [ width ]");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
@@ -95,7 +95,7 @@
 	band_t band = (band_t) effp->priv;
 	if (band->center > effp->ininfo.rate/2)
 	{
-		fail("Band: center must be < minimum data rate/2\n");
+		st_fail("Band: center must be < minimum data rate/2\n");
 		return (ST_EOF);
 	}
 
--- a/src/bandpass.c
+++ b/src/bandpass.c
@@ -44,7 +44,7 @@
   butterworth_t butterworth = (butterworth_t)effp->priv;
 
   if (n != 2) {
-    fail("Usage: bandpass FREQUENCY BANDWIDTH");
+    st_fail("Usage: bandpass FREQUENCY BANDWIDTH");
     return (ST_EOF);
   }
 
@@ -51,12 +51,12 @@
   st_butterworth_start (effp);
 
   if (!(sscanf (argv [0], "%lf", &butterworth->frequency))) {
-    fail("bandpass: illegal frequency");
+    st_fail("bandpass: illegal frequency");
     return (ST_EOF);
   }
 
   if (!(sscanf (argv [1], "%lf", &butterworth->bandwidth))) {
-    fail("bandpass: illegal bandwidth");
+    st_fail("bandpass: illegal bandwidth");
     return (ST_EOF);
   }
   return (ST_SUCCESS);
--- a/src/breject.c
+++ b/src/breject.c
@@ -44,7 +44,7 @@
   butterworth_t butterworth = (butterworth_t)effp->priv;
 
   if (n != 2) {
-    fail("Usage: bandreject FREQUENCY BANDWIDTH");
+    st_fail("Usage: bandreject FREQUENCY BANDWIDTH");
     return (ST_EOF);
   }
 
@@ -51,12 +51,12 @@
   st_butterworth_start (effp);
 
   if (!(sscanf (argv [0], "%lf", &butterworth->frequency))) {
-    fail("bandreject: illegal frequency");
+    st_fail("bandreject: illegal frequency");
     return (ST_EOF);
   }
 
   if (!(sscanf (argv [1], "%lf", &butterworth->bandwidth))) {
-   fail("bandreject: illegal bandwidth");
+   st_fail("bandreject: illegal bandwidth");
    return (ST_EOF);
   }
   return (ST_SUCCESS);
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -103,7 +103,7 @@
 
 	if ( ( n < 7 ) || (( n - 2 ) % 5 ) )
 	{
-	    fail("Usage: chorus gain-in gain-out delay decay speed depth [ -s | -t ]");
+	    st_fail("Usage: chorus gain-in gain-out delay decay speed depth [ -s | -t ]");
 	    return (ST_EOF);
 	}
 
@@ -112,7 +112,7 @@
 	while ( i < n ) {
 		if ( chorus->num_chorus > MAX_CHORUS )
 		{
-			fail("chorus: to many delays, use less than %i delays", MAX_CHORUS);
+			st_fail("chorus: to many delays, use less than %i delays", MAX_CHORUS);
 			return (ST_EOF);
 		}
 		sscanf(argv[i++], "%f", &chorus->delay[chorus->num_chorus]);
@@ -125,7 +125,7 @@
 			chorus->modulation[chorus->num_chorus] = MOD_TRIANGLE;
 		else
 		{
-    			fail("Usage: chorus gain-in gain-out delay decay speed [ -s | -t ]");
+    			st_fail("Usage: chorus gain-in gain-out delay decay speed [ -s | -t ]");
 			return (ST_EOF);
 		}
 		i++;
@@ -148,17 +148,17 @@
 
 	if ( chorus->in_gain < 0.0 )
 	{
-		fail("chorus: gain-in must be positive!\n");
+		st_fail("chorus: gain-in must be positive!\n");
 		return (ST_EOF);
 	}
 	if ( chorus->in_gain > 1.0 )
 	{
-		fail("chorus: gain-in must be less than 1.0!\n");
+		st_fail("chorus: gain-in must be less than 1.0!\n");
 		return (ST_EOF);
 	}
 	if ( chorus->out_gain < 0.0 )
 	{
-		fail("chorus: gain-out must be positive!\n");
+		st_fail("chorus: gain-out must be positive!\n");
 		return (ST_EOF);
 	}
 	for ( i = 0; i < chorus->num_chorus; i++ ) {
@@ -169,42 +169,42 @@
 
 		if ( chorus->delay[i] < 20.0 )
 		{
-	    		fail("chorus: delay must be more than 20.0 msec!\n");
+	    		st_fail("chorus: delay must be more than 20.0 msec!\n");
 			return (ST_EOF);
 		}
 		if ( chorus->delay[i] > 100.0 )
 		{
-	    		fail("chorus: delay must be less than 100.0 msec!\n");
+	    		st_fail("chorus: delay must be less than 100.0 msec!\n");
 			return (ST_EOF);
 		}
 		if ( chorus->speed[i] < 0.1 )
 		{
-	    		fail("chorus: speed must be more than 0.1 Hz!\n");
+	    		st_fail("chorus: speed must be more than 0.1 Hz!\n");
 			return (ST_EOF);
 		}
 		if ( chorus->speed[i] > 5.0 )
 		{
-	    		fail("chorus: speed must be less than 5.0 Hz!\n");
+	    		st_fail("chorus: speed must be less than 5.0 Hz!\n");
 			return (ST_EOF);
 		}
 		if ( chorus->depth[i] < 0.0 )
 		{
-	    		fail("chorus: delay must be more positive!\n");
+	    		st_fail("chorus: delay must be more positive!\n");
 			return (ST_EOF);
 		}
 		if ( chorus->depth[i] > 10.0 )
 		{
-		    fail("chorus: delay must be less than 10.0 msec!\n");
+		    st_fail("chorus: delay must be less than 10.0 msec!\n");
 		    return (ST_EOF);
 		}
 		if ( chorus->decay[i] < 0.0 )
 		{
-	    		fail("chorus: decay must be positive!\n" );
+	    		st_fail("chorus: decay must be positive!\n" );
 			return (ST_EOF);
 		}
 		if ( chorus->decay[i] > 1.0 )
 		{
-	    		fail("chorus: decay must be less that 1.0!\n" );
+	    		st_fail("chorus: decay must be less that 1.0!\n" );
 			return (ST_EOF);
 		}
 		chorus->length[i] = effp->ininfo.rate / chorus->speed[i];
@@ -211,7 +211,7 @@
 		if (! (chorus->lookup_tab[i] = 
 			(int *) malloc(sizeof (int) * chorus->length[i])))
 		{
-			fail("chorus: Cannot malloc %d bytes!\n", 
+			st_fail("chorus: Cannot malloc %d bytes!\n", 
 				sizeof(int) * chorus->length[i]);
 			return (ST_EOF);
 		}
@@ -234,13 +234,13 @@
 	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 )
-	warn("chorus: warning >>> gain-out can cause saturation or clipping of output <<<");
+	st_warn("chorus: warning >>> gain-out can cause saturation or clipping of output <<<");
 
 
 	if (! (chorus->chorusbuf = 
 		(float *) malloc(sizeof (float) * chorus->maxsamples)))
 	{
-		fail("chorus: Cannot malloc %d bytes!\n", 
+		st_fail("chorus: Cannot malloc %d bytes!\n", 
 			sizeof(float) * chorus->maxsamples);
 		return (ST_EOF);
 	}
--- a/src/compand.c
+++ b/src/compand.c
@@ -47,7 +47,7 @@
 
     if (n < 2 || n > 4)
     {
-      fail("Wrong number of arguments for the compander effect\n"
+      st_fail("Wrong number of arguments for the compander effect\n"
 	   "Use: {<attack_time>,<decay_time>}+ {<dB_in>,<db_out>}+ "
 	   "[<dB_postamp>]\n"
 	   "where {}+ means `one or more in a comma-separated, "
@@ -68,7 +68,7 @@
       if (commas % 2 == 0) /* There must be an even number of
 			      attack/decay parameters */
       {
-	fail("compander: Odd number of attack & decay rate parameters");
+	st_fail("compander: Odd number of attack & decay rate parameters");
 	return (ST_EOF);
       }
 
@@ -78,7 +78,7 @@
 	  (l->volume     = malloc(sizeof(double) * rates)) == NULL ||
 	  (l->lastSamp   = calloc(rates, sizeof(LONG)))    == NULL)
       {
-	fail("Out of memory");
+	st_fail("Out of memory");
 	return (ST_EOF);
       }
       l->expectedChannels = rates;
@@ -101,7 +101,7 @@
       if (commas % 2 == 0) /* There must be an even number of
 			      transfer parameters */
       {
-	fail("compander: Odd number of transfer function parameters\n"
+	st_fail("compander: Odd number of transfer function parameters\n"
 	     "Each input value in dB must have a corresponding output value");
 	return (ST_EOF);
       }
@@ -110,7 +110,7 @@
       if ((l->transferIns  = malloc(sizeof(double) * tfers)) == NULL ||
 	  (l->transferOuts = malloc(sizeof(double) * tfers)) == NULL)
       {
-	fail("Out of memory");
+	st_fail("Out of memory");
 	return (ST_EOF);
       }
       l->transferPoints = tfers;
@@ -120,13 +120,13 @@
       do {
 	if (!strcmp(s, "-inf"))
 	{
-	  fail("Input signals of zero level must always generate zero output");
+	  st_fail("Input signals of zero level must always generate zero output");
 	  return (ST_EOF);
 	}
 	l->transferIns[i]  = pow(10.0, atof(s)/20.0);
 	if (l->transferIns[i] > 1.0)
 	{
-	  fail("dB values are relative to maximum input, and, ipso facto, "
+	  st_fail("dB values are relative to maximum input, and, ipso facto, "
 	       "cannot exceed 0");
 	  return (ST_EOF);
 	}
@@ -134,7 +134,7 @@
 	  --(l->transferPoints);
 	if (i > 0 && l->transferIns[i] <= l->transferIns[i-1])
 	{
-	  fail("Transfer function points don't have strictly ascending "
+	  st_fail("Transfer function points don't have strictly ascending "
 	       "input amplitude");
 	  return (ST_EOF);
 	}
--- a/src/copy.c
+++ b/src/copy.c
@@ -23,7 +23,7 @@
 {
 	if (n)
 	{
-		fail("Copy effect takes no options.");
+		st_fail("Copy effect takes no options.");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -155,7 +155,7 @@
 	p->bytes_written = 0;
 	p->com.v_min = 1;
 	p->com.v_max = -1;
-	report("cvsd: bit rate %dbit/s, bits from %s\n", p->cvsd_rate,
+	st_report("cvsd: bit rate %dbit/s, bits from %s\n", p->cvsd_rate,
 	       p->swapbits ? "msb to lsb" : "lsb to msb");
 }
 
@@ -220,7 +220,7 @@
 		st_writeb(ft, p->bit.shreg);
 		p->bytes_written++;
 	}
-	report("cvsd: min slope %f, max slope %f\n", 
+	st_report("cvsd: min slope %f, max slope %f\n", 
 	       p->com.v_min, p->com.v_max);	
 
 	return (ST_SUCCESS);
@@ -233,7 +233,7 @@
 {
 	struct cvsdpriv *p = (struct cvsdpriv *) ft->priv;
 
-	report("cvsd: min value %f, max value %f\n", 
+	st_report("cvsd: min value %f, max value %f\n", 
 	       p->com.v_min, p->com.v_max);
 
 	return(ST_SUCCESS);
@@ -263,7 +263,7 @@
 	if (!dbg.f1) {
 		if (!(dbg.f1 = fopen("dbg1", "w")))
 		{
-			fail("debugging");
+			st_fail("debugging");
 			return (0);
 		}
 		fprintf(dbg.f1, "\"input\"\n");
@@ -271,7 +271,7 @@
 	if (!dbg.f2) {
 		if (!(dbg.f2 = fopen("dbg2", "w")))
 		{
-			fail("debugging");
+			st_fail("debugging");
 			return (0);
 		}
 		fprintf(dbg.f2, "\"recon\"\n");
@@ -345,7 +345,7 @@
 	if (!dbg.f1) {
 		if (!(dbg.f1 = fopen("dbg1", "w")))
 		{
-			fail("debugging");
+			st_fail("debugging");
 			return (0);
 		}
 		fprintf(dbg.f1, "\"input\"\n");
@@ -353,7 +353,7 @@
 	if (!dbg.f2) {
 		if (!(dbg.f2 = fopen("dbg2", "w")))
 		{
-			fail("debugging");
+			st_fail("debugging");
 			return (0);
 		}
 		fprintf(dbg.f2, "\"recon\"\n");
@@ -490,7 +490,7 @@
 
 	if (fread(hdrbuf, sizeof(hdrbuf), 1, f) != 1)
 	{
-		fail("unable to read DVMS header\n");
+		st_fail("unable to read DVMS header\n");
 		return (ST_EOF);
 	}
 	for(i = sizeof(hdrbuf), sum = 0; i > /*2*/3; i--) /* Deti bug */
@@ -515,7 +515,7 @@
 	hdr->Crc = get16(&pch);
 	if (sum != hdr->Crc) 
 	{
-		fail("DVMS header checksum error, read %u, calculated %u\n",
+		st_fail("DVMS header checksum error, read %u, calculated %u\n",
 		     hdr->Crc, sum);
 		return (ST_EOF);
 	}
@@ -559,12 +559,12 @@
 	put16(&pch, hdr->Crc);
 	if (fseek(f, 0, SEEK_SET) < 0)
 	{
-		fail("cannot write DVMS header, seek failed\n");
+		st_fail("cannot write DVMS header, seek failed\n");
 		return (ST_EOF);
 	}
 	if (fwrite(hdrbuf, sizeof(hdrbuf), 1, f) != 1)
 	{
-		fail("cannot write DVMS header\n");
+		st_fail("cannot write DVMS header\n");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
@@ -611,21 +611,21 @@
 	if (rc)
 	    return rc;
 
-	report("DVMS header of source file \"%s\":");
-	report("  filename  \"%.14s\"",ft->filename);
-        report("  id        0x%x", hdr.Filename);
-	report("  state     0x%x", hdr.Id, hdr.State);
-	report("  time      %s",ctime(&hdr.Unixtime)); /* ctime generates lf */
-	report("  usender   %u", hdr.Usender);
-	report("  ureceiver %u", hdr.Ureceiver);
-	report("  length    %u", hdr.Length);
-	report("  srate     %u", hdr.Srate);
-	report("  days      %u", hdr.Days);
-	report("  custom1   %u", hdr.Custom1);
-	report("  custom2   %u", hdr.Custom2);
-	report("  info      \"%.16s\"\n", hdr.Info);
+	st_report("DVMS header of source file \"%s\":");
+	st_report("  filename  \"%.14s\"",ft->filename);
+        st_report("  id        0x%x", hdr.Filename);
+	st_report("  state     0x%x", hdr.Id, hdr.State);
+	st_report("  time      %s",ctime(&hdr.Unixtime)); /* ctime generates lf */
+	st_report("  usender   %u", hdr.Usender);
+	st_report("  ureceiver %u", hdr.Ureceiver);
+	st_report("  length    %u", hdr.Length);
+	st_report("  srate     %u", hdr.Srate);
+	st_report("  days      %u", hdr.Days);
+	st_report("  custom1   %u", hdr.Custom1);
+	st_report("  custom2   %u", hdr.Custom2);
+	st_report("  info      \"%.16s\"\n", hdr.Info);
 	ft->info.rate = (hdr.Srate < 240) ? 16000 : 32000;
-	report("DVMS rate %dbit/s using %dbit/s deviation %d%%\n", 
+	st_report("DVMS rate %dbit/s using %dbit/s deviation %d%%\n", 
 	       hdr.Srate*100, ft->info.rate, 
 	       ((ft->info.rate - hdr.Srate*100) * 100) / ft->info.rate);
 	rc = st_cvsdstartread(ft);
@@ -655,7 +655,7 @@
 	    return rc;
 
 	if (!ft->seekable)
-	       warn("Length in output .DVMS header will wrong since can't seek to fix it");
+	       st_warn("Length in output .DVMS header will wrong since can't seek to fix it");
 
 	p->swapbits = 0;
 	return(ST_SUCCESS);
@@ -672,12 +672,12 @@
 	st_cvsdstopwrite(ft);
 	if (!ft->seekable)
 	{
-	    warn("File not seekable");
+	    st_warn("File not seekable");
 	    return (ST_EOF);
 	}
 	if (fseek(ft->fp, 0L, 0) != 0)
 	{
-		fail("Can't rewind output file to rewrite DVMS header.");
+		st_fail("Can't rewind output file to rewrite DVMS header.");
 		return(ST_EOF);
 	}
 	make_dvms_hdr(ft, &hdr);
--- a/src/dat.c
+++ b/src/dat.c
@@ -47,7 +47,7 @@
       sscanf(inpstr," %c",&sc);
       if (sc != ';') 
       {
-	  fail("Cannot determine sample rate.");
+	  st_fail("Cannot determine sample rate.");
 	  return (ST_EOF);
       }
 #ifdef __alpha__
@@ -74,8 +74,8 @@
 
    if (ft->info.channels > 1)
    {
-        report("Can only create .dat files with one channel.");
-	report("Forcing output to 1 channel.");
+        st_report("Can only create .dat files with one channel.");
+	st_report("Forcing output to 1 channel.");
 	ft->info.channels = 1;
    }
    
@@ -116,7 +116,7 @@
         retc = sscanf(inpstr,"%*s %lg",&sampval);
         if (retc != 1) 
 	{
-	    fail("Unable to read sample.");
+	    st_fail("Unable to read sample.");
 	    return (0);
 	}
         *buf++ = roundoff(sampval * 2.147483648e9);
--- a/src/deemphas.c
+++ b/src/deemphas.c
@@ -120,12 +120,12 @@
 {
      if (n)
      {
-          fail("Deemphasis filtering effect takes no options.\n");
+          st_fail("Deemphasis filtering effect takes no options.\n");
 	  return (ST_EOF);
      }
      if (sizeof(double)*ST_MAX_PRIVSIZE < sizeof(struct deemphstuff))
      {
-          fail("Internal error: PRIVSIZE too small.\n");
+          st_fail("Internal error: PRIVSIZE too small.\n");
 	  return (ST_EOF);
      }
      return (ST_SUCCESS);
@@ -143,7 +143,7 @@
          || effp->ininfo.rate != 44100
          || effp->ininfo.size != ST_SIZE_WORD)
      {
-          fail("The deemphasis effect works only with audio cd like samples.\nThe input format however has %d Hz sample rate and %d-byte%s signed linearly coded samples.",
+          st_fail("The deemphasis effect works only with audio cd like samples.\nThe input format however has %d Hz sample rate and %d-byte%s signed linearly coded samples.",
             effp->ininfo.rate, effp->ininfo.size,
             effp->ininfo.encoding != ST_ENCODING_SIGN2 ? ", but not" : "");
 	  return (ST_EOF);
--- a/src/echo.c
+++ b/src/echo.c
@@ -91,7 +91,7 @@
 
 	if ((n < 4) || (n % 2))
 	{
-	    fail("Usage: echo gain-in gain-out delay decay [ delay decay ... ]");
+	    st_fail("Usage: echo gain-in gain-out delay decay [ delay decay ... ]");
 	    return (ST_EOF);
 	}
 
@@ -100,7 +100,7 @@
 	sscanf(argv[i++], "%f", &echo->out_gain);
 	while (i < n) {
 		if ( echo->num_delays >= MAX_ECHOS )
-			fail("echo: to many delays, use less than %i delays",
+			st_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]);
@@ -124,17 +124,17 @@
 	echo->maxsamples = 0L;
 	if ( echo->in_gain < 0.0 )
 	{
-		fail("echo: gain-in must be positive!\n");
+		st_fail("echo: gain-in must be positive!\n");
 		return (ST_EOF);
 	}
 	if ( echo->in_gain > 1.0 )
 	{
-		fail("echo: gain-in must be less than 1.0!\n");
+		st_fail("echo: gain-in must be less than 1.0!\n");
 		return (ST_EOF);
 	}
 	if ( echo->out_gain < 0.0 )
 	{
-		fail("echo: gain-in must be positive!\n");
+		st_fail("echo: gain-in must be positive!\n");
 		return (ST_EOF);
 	}
 	for ( i = 0; i < echo->num_delays; i++ ) {
@@ -141,23 +141,23 @@
 		echo->samples[i] = echo->delay[i] * effp->ininfo.rate / 1000.0;
 		if ( echo->samples[i] < 1 )
 		{
-		    fail("echo: delay must be positive!\n");
+		    st_fail("echo: delay must be positive!\n");
 		    return (ST_EOF);
 		}
 		if ( echo->samples[i] > DELAY_BUFSIZ )
 		{
-			fail("echo: delay must be less than %g seconds!\n",
+			st_fail("echo: delay must be less than %g seconds!\n",
 				DELAY_BUFSIZ / (float) effp->ininfo.rate );
 			return (ST_EOF);
 		}
 		if ( echo->decay[i] < 0.0 )
 		{
-		    fail("echo: decay must be positive!\n" );
+		    st_fail("echo: decay must be positive!\n" );
 		    return (ST_EOF);
 		}
 		if ( echo->decay[i] > 1.0 )
 		{
-		    fail("echo: decay must be less than 1.0!\n" );
+		    st_fail("echo: decay must be less than 1.0!\n" );
 		    return (ST_EOF);
 		}
 		if ( echo->samples[i] > echo->maxsamples )
@@ -165,7 +165,7 @@
 	}
 	if (! (echo->delay_buf = (double *) malloc(sizeof (double) * echo->maxsamples)))
 	{
-		fail("echo: Cannot malloc %d bytes!\n", 
+		st_fail("echo: Cannot malloc %d bytes!\n", 
 			sizeof(long) * echo->maxsamples);
 		return (ST_EOF);
 	}
@@ -176,7 +176,7 @@
 	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 )
-		warn("echo: warning >>> gain-out can cause saturation of output <<<");
+		st_warn("echo: warning >>> gain-out can cause saturation of output <<<");
 	echo->counter = 0;
 	echo->fade_out = echo->maxsamples;
 	return (ST_SUCCESS);
--- a/src/echos.c
+++ b/src/echos.c
@@ -81,7 +81,7 @@
 
 	if ((n < 4) || (n % 2))
 	{
-	    fail("Usage: echos gain-in gain-out delay decay [ delay decay ... ]");
+	    st_fail("Usage: echos gain-in gain-out delay decay [ delay decay ... ]");
 	    return (ST_EOF);
 	}
 
@@ -95,7 +95,7 @@
 		echos->num_delays++;
 		if ( echos->num_delays > MAX_ECHOS )
 		{
-			fail("echos: to many delays, use less than %i delays",
+			st_fail("echos: to many delays, use less than %i delays",
 				MAX_ECHOS);
 			return (ST_EOF);
 		}
@@ -117,17 +117,17 @@
 
 	if ( echos->in_gain < 0.0 )
 	{
-		fail("echos: gain-in must be positive!\n");
+		st_fail("echos: gain-in must be positive!\n");
 		return (ST_EOF);
 	}
 	if ( echos->in_gain > 1.0 )
 	{
-		fail("echos: gain-in must be less than 1.0!\n");
+		st_fail("echos: gain-in must be less than 1.0!\n");
 		return (ST_EOF);
 	}
 	if ( echos->out_gain < 0.0 )
 	{
-		fail("echos: gain-in must be positive!\n");
+		st_fail("echos: gain-in must be positive!\n");
 		return (ST_EOF);
 	}
 	for ( i = 0; i < echos->num_delays; i++ ) {
@@ -134,23 +134,23 @@
 		echos->samples[i] = echos->delay[i] * effp->ininfo.rate / 1000.0;
 		if ( echos->samples[i] < 1 )
 		{
-		    fail("echos: delay must be positive!\n");
+		    st_fail("echos: delay must be positive!\n");
 		    return (ST_EOF);
 		}
 		if ( echos->samples[i] > DELAY_BUFSIZ )
 		{
-			fail("echos: delay must be less than %g seconds!\n",
+			st_fail("echos: delay must be less than %g seconds!\n",
 				DELAY_BUFSIZ / (float) effp->ininfo.rate );
 			return (ST_EOF);
 		}
 		if ( echos->decay[i] < 0.0 )
 		{
-		    fail("echos: decay must be positive!\n" );
+		    st_fail("echos: decay must be positive!\n" );
 		    return (ST_EOF);
 		}
 		if ( echos->decay[i] > 1.0 )
 		{
-		    fail("echos: decay must be less than 1.0!\n" );
+		    st_fail("echos: decay must be less than 1.0!\n" );
 		    return (ST_EOF);
 		}
 		echos->counter[i] = 0;
@@ -159,7 +159,7 @@
 	}
 	if (! (echos->delay_buf = (double *) malloc(sizeof (double) * echos->sumsamples)))
 	{
-		fail("echos: Cannot malloc %d bytes!\n", 
+		st_fail("echos: Cannot malloc %d bytes!\n", 
 			sizeof(double) * echos->sumsamples);
 		return(ST_EOF);
 	}
@@ -170,7 +170,7 @@
 	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 )
-		warn("echos: warning >>> gain-out can cause saturation of output <<<");
+		st_warn("echos: warning >>> gain-out can cause saturation of output <<<");
 	return (ST_SUCCESS);
 }
 
--- a/src/filter.c
+++ b/src/filter.c
@@ -85,27 +85,27 @@
 	/* fprintf(stderr,"freq: %d-%d\n", f->freq0, f->freq1);fflush(stderr); */
 	if (f->freq0 == 0 && f->freq1 == 0)
 	{
-		fail("Usage: filter low-high [ windowlength [ beta ] ]");
+		st_fail("Usage: filter low-high [ windowlength [ beta ] ]");
 		return (ST_EOF);
 	}
 
 	if ((n >= 2) && !sscanf(argv[1], "%ld", &f->Nwin))
 	{
-		fail("Usage: filter low-high [ windowlength ]");
+		st_fail("Usage: filter low-high [ windowlength ]");
 		return (ST_EOF);
 	}
 	else if (f->Nwin < 4) {
-		fail("filter: window length (%ld) <4 is too short", f->Nwin);
+		st_fail("filter: window length (%ld) <4 is too short", f->Nwin);
 		return (ST_EOF);
 	}
 
 	if ((n >= 3) && !sscanf(argv[2], "%lf", &f->beta))
 	{
-		fail("Usage: filter low-high [ windowlength [ beta ] ]");
+		st_fail("Usage: filter low-high [ windowlength [ beta ] ]");
 		return (ST_EOF);
 	}
 
-	report("filter opts: %d-%d, window-len %d, beta %f\n", f->freq0, f->freq1, f->Nwin, f->beta);
+	st_report("filter opts: %d-%d, window-len %d, beta %f\n", f->freq0, f->freq1, f->Nwin, f->beta);
 	return (ST_SUCCESS);
 }
 
@@ -128,7 +128,7 @@
 
 	if ((f->freq0 < 0) || (f->freq0 > f->freq1))
 	{
-		fail("filter: low(%d),high(%d) parameters must satisfy 0 <= low <= high <= %d",
+		st_fail("filter: low(%d),high(%d) parameters must satisfy 0 <= low <= high <= %d",
 					f->freq0, f->freq1, f->rate/2);
 		return (ST_EOF);
 	}
@@ -139,7 +139,7 @@
 		Xh0 = makeFilter(Fp0, Xh, 2.0*(double)f->freq0/f->rate, f->beta, 1, 0);
 		if (Xh0 <= 1)
 		{
-			fail("filter: Unable to make low filter\n");
+			st_fail("filter: Unable to make low filter\n");
 			return (ST_EOF);
 		}
 	} else {
@@ -151,7 +151,7 @@
 		Xh1 = makeFilter(Fp1, Xh, 2.0*(double)f->freq1/f->rate, f->beta, 1, 0);
 		if (Xh1 <= 1)
 		{
-			fail("filter: Unable to make high filter\n");
+			st_fail("filter: Unable to make high filter\n");
 			return (ST_EOF);
 		}
 	} else {
@@ -172,7 +172,7 @@
 
 	Xh -= 1;       /* Xh = 0 can only happen if filter was identity 0-Nyquist */
 	if (Xh<=0)
-		warn("filter: adjusted freq %d-%d is identity", f->freq0, f->freq1);
+		st_warn("filter: adjusted freq %d-%d is identity", f->freq0, f->freq1);
 
 	f->Nwin = 2*Xh + 1;  /* not really used afterwards */
 	f->Xh = Xh;
@@ -274,7 +274,7 @@
 	*osamp -= osamp_res;
 	/* fprintf(stderr,"DRAIN osamp %d\n", *osamp); */
 	if (isamp_res)
-		warn("drain overran obuf by %d\n", isamp_res); fflush(stderr);
+		st_warn("drain overran obuf by %d\n", isamp_res); fflush(stderr);
 	return (ST_SUCCESS);
 }
 
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -88,7 +88,7 @@
 
 	if (!((n == 5) || (n == 6)))
 	{
-	    fail("Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]");
+	    st_fail("Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]");
 	    return (ST_EOF);
 	}
 
@@ -105,7 +105,7 @@
 			flanger->modulation = MOD_TRIANGLE;
 		else
 		{
-	    		fail("Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]");
+	    		st_fail("Usage: flanger gain-in gain-out delay decay speed [ -s | -t ]");
 			return (ST_EOF);
 		}
 	}
@@ -125,52 +125,52 @@
 
 	if ( flanger->in_gain < 0.0 )
 	{
-	    fail("flanger: gain-in must be positive!\n");
+	    st_fail("flanger: gain-in must be positive!\n");
 	    return (ST_EOF);
 	}
 	if ( flanger->in_gain > 1.0 )
 	{
-	    fail("flanger: gain-in must be less than 1.0!\n");
+	    st_fail("flanger: gain-in must be less than 1.0!\n");
 	    return (ST_EOF);
 	}
 	if ( flanger->out_gain < 0.0 )
 	{
-	    fail("flanger: gain-out must be positive!\n");
+	    st_fail("flanger: gain-out must be positive!\n");
 	    return (ST_EOF);
 	}
 	if ( flanger->delay < 0.0 )
 	{
-	    fail("flanger: delay must be positive!\n");
+	    st_fail("flanger: delay must be positive!\n");
 	    return (ST_EOF);
 	}
 	if ( flanger->delay > 5.0 )
 	{
-	    fail("flanger: delay must be less than 5.0 msec!\n");
+	    st_fail("flanger: delay must be less than 5.0 msec!\n");
 	    return (ST_EOF);
 	}
 	if ( flanger->speed < 0.1 )
 	{
-	    fail("flanger: speed must be more than 0.1 Hz!\n");
+	    st_fail("flanger: speed must be more than 0.1 Hz!\n");
 	    return (ST_EOF);
 	}
 	if ( flanger->speed > 2.0 )
 	{
-	    fail("flanger: speed must be less than 2.0 Hz!\n");
+	    st_fail("flanger: speed must be less than 2.0 Hz!\n");
 	    return (ST_EOF);
 	}
 	if ( flanger->decay < 0.0 )
 	{
-	    fail("flanger: decay must be positive!\n" );
+	    st_fail("flanger: decay must be positive!\n" );
 	    return (ST_EOF);
 	}
 	if ( flanger->decay > 1.0 )
 	{
-	    fail("flanger: decay must be less that 1.0!\n" );
+	    st_fail("flanger: decay must be less that 1.0!\n" );
 	    return (ST_EOF);
 	}
 	/* Be nice and check the hint with warning, if... */
 	if ( flanger->in_gain * ( 1.0 + flanger->decay ) > 1.0 / flanger->out_gain )
-		warn("flanger: warning >>> gain-out can cause saturation or clipping of output <<<");
+		st_warn("flanger: warning >>> gain-out can cause saturation or clipping of output <<<");
 
 	flanger->length = effp->ininfo.rate / flanger->speed;
 
@@ -177,7 +177,7 @@
 	if (! (flanger->flangerbuf = 
 		(double *) malloc(sizeof (double) * flanger->maxsamples)))
 	{
-		fail("flanger: Cannot malloc %d bytes!\n", 
+		st_fail("flanger: Cannot malloc %d bytes!\n", 
 			sizeof(double) * flanger->maxsamples);
 		return (ST_EOF);
 	}
@@ -186,7 +186,7 @@
 	if (! (flanger->lookup_tab = 
 		(int *) malloc(sizeof (int) * flanger->length)))
 	{
-		fail("flanger: Cannot malloc %d bytes!\n", 
+		st_fail("flanger: Cannot malloc %d bytes!\n", 
 			sizeof(int) * flanger->length);
 		return(ST_EOF);
 	}
--- a/src/gsm.c
+++ b/src/gsm.c
@@ -63,7 +63,7 @@
 	p->channels = ft->info.channels;
 	if (p->channels > MAXCHANS || p->channels <= 0)
 	{
-		fail("gsm: channels(%d) must be in 1-16", ft->info.channels);
+		st_fail("gsm: channels(%d) must be in 1-16", ft->info.channels);
 		return(ST_EOF);
 	}
 
@@ -71,7 +71,7 @@
 		p->handle[ch] = gsm_create();
 		if (!p->handle[ch])
 		{
-			fail("unable to create GSM stream");
+			st_fail("unable to create GSM stream");
 			return (ST_EOF);
 		}
 	}
@@ -130,7 +130,7 @@
 			gbuff = p->sampleTop;
 			if (gsm_decode(p->handle[ch], p->frames + ch*FRAMESIZE, gbuff) < 0)
 			{
-				fail("error during GSM decode");
+				st_fail("error during GSM decode");
 				return (0);
 			}
 			
@@ -172,7 +172,7 @@
 		r = fwrite(p->frames, FRAMESIZE, 1, ft->fp);
 		if (r != 1)
 		{
-			fail("write error");
+			st_fail("write error");
 			return(ST_EOF);
 		}
 	}
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -81,7 +81,7 @@
 	/* Check the file type (bytes 65-68) */
 	if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "FSSD", 4) != 0)
 	{
-		fail("Mac header type is not FSSD");
+		st_fail("Mac header type is not FSSD");
 		return (ST_EOF);
 	}
 
@@ -102,7 +102,7 @@
 	/* The data fork must contain a "HCOM" header */
 	if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "HCOM", 4) != 0)
 	{
-		fail("Mac data fork is not HCOM");
+		st_fail("Mac data fork is not HCOM");
 		return (ST_EOF);
 	}
 
@@ -112,13 +112,13 @@
 	st_readdw(ft, &compresstype);
 	if (compresstype > 1)
 	{
-		fail("Bad compression type in HCOM header");
+		st_fail("Bad compression type in HCOM header");
 		return (ST_EOF);
 	}
 	st_readdw(ft, &divisor);
 	if (divisor == 0 || divisor > 4)
 	{
-		fail("Bad sampling rate divisor in HCOM header");
+		st_fail("Bad sampling rate divisor in HCOM header");
 		return (ST_EOF);
 	}
 	st_readw(ft, &dictsize);
@@ -133,7 +133,7 @@
 	p->dictionary = (dictent *) malloc(511 * sizeof(dictent));
 	if (p->dictionary == NULL)
 	{
-		fail("can't malloc memory for Huffman dictionary");
+		st_fail("can't malloc memory for Huffman dictionary");
 		return (0);
 	}
 
@@ -142,7 +142,7 @@
 		st_readw(ft, &(p->dictionary[i].dict_leftson));
 		st_readw(ft, &(p->dictionary[i].dict_rightson));
 		/*
-		report("%d %d",
+		st_report("%d %d",
 		       p->dictionary[i].dict_leftson,
 		       p->dictionary[i].dict_rightson);
 		       */
@@ -155,7 +155,7 @@
 	p->checksum = checksum;
 	p->deltacompression = compresstype;
 	if (!p->deltacompression)
-		report("HCOM data using value compression");
+		st_report("HCOM data using value compression");
 	p->huffcount = huffcount;
 	p->cksum = 0;
 	p->dictentry = 0;
@@ -173,7 +173,7 @@
 	while (--n >= 0) {
 	    	if (st_readb(ft, &trash) == ST_EOF)
 		{
-			fail("unexpected EOF in Mac header");
+			st_fail("unexpected EOF in Mac header");
 			return(ST_EOF);
 		}
 	}
@@ -194,7 +194,7 @@
 			return 0; /* Don't know if this can happen... */
 		if (st_readb(ft, &sample_rate) == ST_EOF)
 		{
-			fail("unexpected EOF at start of HCOM data");
+			st_fail("unexpected EOF at start of HCOM data");
 			return (0);
 		}
 		p->sample = sample_rate;
@@ -212,7 +212,7 @@
 			st_readdw(ft, &(p->current));
 			if (feof(ft->fp))
 			{
-				fail("unexpected EOF in HCOM data");
+				st_fail("unexpected EOF in HCOM data");
 				return (0);
 			}
 			p->cksum += p->current;
@@ -256,12 +256,12 @@
 
 	if (p->huffcount != 0)
 	{
-		fail("not all HCOM data read");
+		st_fail("not all HCOM data read");
 		return (ST_EOF);
 	}
 	if(p->cksum != p->checksum)
 	{
-		fail("checksum error in HCOM data");
+		st_fail("checksum error in HCOM data");
 		return (ST_EOF);
 	}
 	free((char *)p->dictionary);
@@ -301,7 +301,7 @@
 	case 22050/4:
 		break;
 	default:
-		fail("unacceptable output rate for HCOM: try 5512, 7350, 11025 or 22050 hertz");
+		st_fail("unacceptable output rate for HCOM: try 5512, 7350, 11025 or 22050 hertz");
 		return (ST_EOF);
 	}
 	ft->info.size = ST_SIZE_BYTE;
@@ -313,7 +313,7 @@
 	p->data = (unsigned char *) malloc(p->size);
 	if (p->data == NULL)
 	{
-		fail("can't malloc buffer for uncompressed HCOM data");
+		st_fail("can't malloc buffer for uncompressed HCOM data");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
@@ -335,7 +335,7 @@
 		p->data = (unsigned char *) realloc(p->data, p->size);
 		if (p->data == NULL)
 		{
-		    fail("can't realloc buffer for uncompressed HCOM data");
+		    st_fail("can't realloc buffer for uncompressed HCOM data");
 		    return (0);
 		}
 	}
@@ -499,11 +499,11 @@
 	  l += frequtable[i] * codesize[i];
   }
   l = (((l + 31) >> 5) << 2) + 24 + dictsize * 4;
-  report("  Original size: %6d bytes", *dl);
-  report("Compressed size: %6d bytes", l);
+  st_report("  Original size: %6d bytes", *dl);
+  st_report("Compressed size: %6d bytes", l);
   if((datafork = (unsigned char *)malloc((unsigned)l)) == NULL)
   {
-    fail("can't malloc buffer for compressed HCOM data");
+    st_fail("can't malloc buffer for compressed HCOM data");
     return (ST_EOF);
   }
   ddf = datafork + 22;
@@ -574,7 +574,7 @@
 	padbytes(ft, 128 - 91);
 	if (ferror(ft->fp))
 	{
-		fail("write error in HCOM header");
+		st_fail("write error in HCOM header");
 		return (ST_EOF);
 	}
 
@@ -581,7 +581,7 @@
 	/* Write the compressed_data fork */
 	if (fwrite((char *) compressed_data, 1, (int)compressed_len, ft->fp) != compressed_len)
 	{
-		fail("can't write compressed HCOM data");
+		st_fail("can't write compressed HCOM data");
 		rc = ST_EOF;
 	}
 	else
--- a/src/highp.c
+++ b/src/highp.c
@@ -42,7 +42,7 @@
 
 	if ((n < 1) || !sscanf(argv[0], "%f", &highp->center))
 	{
-		fail("Usage: highp center");
+		st_fail("Usage: highp center");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
@@ -57,7 +57,7 @@
 	highp_t highp = (highp_t) effp->priv;
 	if (highp->center > effp->ininfo.rate*2)
 	{
-		fail("Highpass: center must be < minimum data rate*2\n");
+		st_fail("Highpass: center must be < minimum data rate*2\n");
 		return (ST_EOF);
 	}
 	
--- a/src/highpass.c
+++ b/src/highpass.c
@@ -45,7 +45,7 @@
   butterworth_t butterworth = (butterworth_t)effp->priv;
 
   if (n != 1) {
-    fail("Usage: highpass FREQUENCY");
+    st_fail("Usage: highpass FREQUENCY");
     return (ST_EOF);
   }
 
@@ -52,7 +52,7 @@
   st_butterworth_start (effp);
 
   if (!(sscanf (argv [0], "%lf", &butterworth->frequency))) {
-    fail("highpass: illegal frequency");
+    st_fail("highpass: illegal frequency");
     return (ST_EOF);
   }
   return (ST_SUCCESS);
--- a/src/lowp.c
+++ b/src/lowp.c
@@ -42,7 +42,7 @@
 
 	if ((n < 1) || !sscanf(argv[0], "%f", &lowp->center))
 	{
-		fail("Usage: lowp center");
+		st_fail("Usage: lowp center");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
@@ -57,7 +57,7 @@
 	lowp_t lowp = (lowp_t) effp->priv;
 	if (lowp->center > effp->ininfo.rate*2)
 	{
-		fail("Lowpass: center must be < minimum data rate*2\n");
+		st_fail("Lowpass: center must be < minimum data rate*2\n");
 		return (ST_EOF);
 	}
 
--- a/src/lowpass.c
+++ b/src/lowpass.c
@@ -32,7 +32,7 @@
   butterworth_t butterworth = (butterworth_t)effp->priv;
 
   if (n != 1) {
-    fail("Usage: lowpass FREQUENCY");
+    st_fail("Usage: lowpass FREQUENCY");
     return (ST_EOF);
   }
 
@@ -39,7 +39,7 @@
   st_butterworth_start (effp);
 
   if (!(sscanf (argv [0], "%lf", &butterworth->frequency))) {
-    fail("lowpass: illegal frequency");
+    st_fail("lowpass: illegal frequency");
     return (ST_EOF);
   }
   return (ST_SUCCESS);
--- a/src/map.c
+++ b/src/map.c
@@ -27,7 +27,7 @@
 {
 	if (n)
 	{
-		fail("Map effect takes no options.");
+		st_fail("Map effect takes no options.");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
--- a/src/mask.c
+++ b/src/mask.c
@@ -35,7 +35,7 @@
 {
 	if (n)
 	{
-		fail("Mask effect takes no options.");
+		st_fail("Mask effect takes no options.");
 		return (ST_EOF);
 	}
 	/* should take # of bits */
--- a/src/maud.c
+++ b/src/maud.c
@@ -77,7 +77,7 @@
 	/* read FORM chunk */
 	if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "FORM", 4) != 0)
 	{
-		fail("MAUD: header does not begin with magic word 'FORM'");
+		st_fail("MAUD: header does not begin with magic word 'FORM'");
 		return (ST_EOF);
 	}
 	
@@ -85,7 +85,7 @@
 	
 	if (st_reads(ft, buf, 4) == ST_EOF || strncmp(buf, "MAUD", 4) != 0)
 	{
-		fail("MAUD: 'FORM' chunk does not specify 'MAUD' as type");
+		st_fail("MAUD: 'FORM' chunk does not specify 'MAUD' as type");
 		return(ST_EOF);
 	}
 	
@@ -95,7 +95,7 @@
 		
 		/*
 		buf[4] = 0;
-		report("chunk %s",buf);
+		st_report("chunk %s",buf);
 		*/
 		
 		if (strncmp(buf,"MHDR",4) == 0) {
@@ -103,7 +103,7 @@
 			st_readdw(ft, &chunksize);
 			if (chunksize != 8*4) 
 			{
-			    fail ("MAUD: MHDR chunk has bad size");
+			    st_fail("MAUD: MHDR chunk has bad size");
 			    return(0);
 			}
 			
@@ -122,7 +122,7 @@
 			st_readw(ft, &denom);       /* clock devide           */
 			if (denom == 0) 
 			{
-			    fail("MAUD: frequency denominator == 0, failed");
+			    st_fail("MAUD: frequency denominator == 0, failed");
 			    return (ST_EOF);
 			}
 			
@@ -137,7 +137,7 @@
 				ft->info.channels = 2;
 				break;
 			default:
-				fail("MAUD: unsupported number of channels in file");
+				st_fail("MAUD: unsupported number of channels in file");
 				return (ST_EOF);
 			}
 			
@@ -144,7 +144,7 @@
 			st_readw(ft, &chaninf); /* number of channels (mono: 1, stereo: 2, ...) */
 			if (chaninf != ft->info.channels) 
 			{
-			    fail("MAUD: unsupported number of channels in file");
+			    st_fail("MAUD: unsupported number of channels in file");
 			    return(ST_EOF);
 			}
 			
@@ -172,7 +172,7 @@
 			}
 			else 
 			{
-				fail("MAUD: unsupported compression type detected");
+				st_fail("MAUD: unsupported compression type detected");
 				return(ST_EOF);
 			}
 			
@@ -188,17 +188,17 @@
 			chunk_buf = (char *) malloc(chunksize + 1);
 			if (!chunk_buf)
 			{
-			    fail("Couldn't alloc resources");
+			    st_fail("Couldn't alloc resources");
 			    return(ST_EOF);
 			}
 			if (fread(chunk_buf,1,(int)chunksize,ft->fp) 
 					!= chunksize)
 			{
-				fail("MAUD: Unexpected EOF in ANNO header");
+				st_fail("MAUD: Unexpected EOF in ANNO header");
 				return(ST_EOF);
 			}
 			chunk_buf[chunksize] = '\0';
-			report ("%s",chunk_buf);
+			st_report("%s",chunk_buf);
 			free(chunk_buf);
 			
 			continue;
@@ -215,7 +215,7 @@
 	
 	if (strncmp(buf,"MDAT",4) != 0) 
 	{
-	    fail("MAUD: MDAT chunk not found");
+	    st_fail("MAUD: MDAT chunk not found");
 	    return(ST_EOF);
 	}
 	st_readdw(ft, &(p->nsamples));
@@ -273,12 +273,12 @@
 	/* If you have to seek around the output file */
 	if (! ft->seekable) 
 	{
-	    fail("Output .maud file must be a file, not a pipe");
+	    st_fail("Output .maud file must be a file, not a pipe");
 	    return (ST_EOF);
 	}
 	
 	if (ft->info.channels != 1 && ft->info.channels != 2) {
-		fail("MAUD: unsupported number of channels, unable to store");
+		st_fail("MAUD: unsupported number of channels, unable to store");
 		return(ST_EOF);
 	}
 	if (ft->info.size == ST_SIZE_WORD) ft->info.encoding = ST_ENCODING_SIGN2;
@@ -319,7 +319,7 @@
 	
 	if (fseek(ft->fp, 0L, 0) != 0) 
 	{
-	    fail("can't rewind output file to rewrite MAUD header");
+	    st_fail("can't rewind output file to rewrite MAUD header");
 	    return(ST_EOF);
 	}
 	
--- a/src/misc.c
+++ b/src/misc.c
@@ -89,7 +89,7 @@
 {
 	if (fwrite(c, 1, strlen(c), ft->fp) != strlen(c))
 	{
-		fail(writerr);
+		st_fail(writerr);
 		return(ST_EOF);
 	}
 	return(ST_SUCCESS);
@@ -116,7 +116,7 @@
 {
 	if (fwrite(&uc, 1, 1, ft->fp) != 1)
 	{
-		fail(writerr);
+		st_fail(writerr);
 		return(ST_EOF);
 	}
 	return(ST_SUCCESS);
@@ -147,7 +147,7 @@
 		us = st_swapw(us);
 	if (fwrite(&us, 2, 1, ft->fp) != 1)
 	{
-		fail(writerr);
+		st_fail(writerr);
 		return (ST_EOF);
 	}
 	return(ST_SUCCESS);
@@ -178,7 +178,7 @@
 		ul = st_swapl(ul);
 	if (fwrite(&ul, 4, 1, ft->fp) != 1)
 	{
-		fail(writerr);
+		st_fail(writerr);
 		return (ST_EOF);
 	}
 	return(ST_SUCCESS);
@@ -211,7 +211,7 @@
 		t = st_swapf(t);
 	if (fwrite(&t, sizeof(float), 1, ft->fp) != 1)
 	{
-		fail(writerr);
+		st_fail(writerr);
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
@@ -242,7 +242,7 @@
 		d = st_swapd(d);
 	if (fwrite(&d, sizeof(double), 1, ft->fp) != 1)
 	{
-		fail(writerr);
+		st_fail(writerr);
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
--- a/src/oss.c
+++ b/src/oss.c
@@ -54,8 +54,8 @@
 	if (ft->info.encoding == -1)
 	    ft->info.encoding = ST_ENCODING_UNSIGNED;
 	if (ft->info.encoding != ST_ENCODING_UNSIGNED) {
-	    report("OSS driver only supports unsigned with bytes");
-	    report("Forcing to unsigned");
+	    st_report("OSS driver only supports unsigned with bytes");
+	    st_report("Forcing to unsigned");
 	    ft->info.encoding = ST_ENCODING_UNSIGNED;
 	}
     }
@@ -64,8 +64,8 @@
 	if (ft->info.encoding == -1)
 	    ft->info.encoding = ST_ENCODING_SIGN2;
 	if (ft->info.encoding != ST_ENCODING_SIGN2) {
-	    report("OSS driver only supports signed with words");
-	    report("Forcing to signed linear");
+	    st_report("OSS driver only supports signed with words");
+	    st_report("Forcing to signed linear");
 	    ft->info.encoding = ST_ENCODING_SIGN2;
 	}
     }
@@ -72,8 +72,8 @@
     else {
         ft->info.size = ST_SIZE_WORD;
 	ft->info.encoding = ST_ENCODING_SIGN2;
-	report("OSS driver only supports bytes and words");
-	report("Forcing to signed linear word");
+	st_report("OSS driver only supports bytes and words");
+	st_report("Forcing to signed linear word");
     }
 
     if (ft->info.channels == -1) ft->info.channels = 1;
@@ -81,13 +81,13 @@
 
     if (ioctl(fileno(ft->fp), SNDCTL_DSP_RESET, 0) < 0)
     {
-	fail("Unable to reset OSS driver.  Possibly accessing an invalid file/device");
+	st_fail("Unable to reset OSS driver.  Possibly accessing an invalid file/device");
 	return(ST_EOF);
     }
     ft->file.size = 0;
     ioctl (fileno(ft->fp), SNDCTL_DSP_GETBLKSIZE, &ft->file.size);
     if (ft->file.size < 4 || ft->file.size > 65536) {
-	    fail("Invalid audio buffer size %d", ft->file.size);
+	    st_fail("Invalid audio buffer size %d", ft->file.size);
 	    return (ST_EOF);
     }
     ft->file.count = 0;
@@ -95,12 +95,12 @@
     ft->file.eof = 0;
 
     if ((ft->file.buf = malloc (ft->file.size)) == NULL) {
-	fail("Unable to allocate input/output buffer of size %d", ft->file.size);
+	st_fail("Unable to allocate input/output buffer of size %d", ft->file.size);
 	return (ST_EOF);
     }
 
     if (ioctl(fileno(ft->fp), SNDCTL_DSP_SYNC, NULL) < 0) {
-	fail("Unable to sync dsp");
+	st_fail("Unable to sync dsp");
 	return (ST_EOF);
     }
 
@@ -108,7 +108,7 @@
     if (ioctl(fileno(ft->fp), SNDCTL_DSP_SAMPLESIZE, &tmp) < 0 || 
 	tmp != samplesize)
     {
-	fail("Unable to set the sample size to %d", samplesize);
+	st_fail("Unable to set the sample size to %d", samplesize);
 	return (ST_EOF);
     }
 
@@ -119,7 +119,7 @@
     if (ioctl(fileno(ft->fp), SNDCTL_DSP_STEREO, &tmp) < 0 ||
 	tmp != dsp_stereo) {
 	ft->info.channels = 1;
-	warn("Couldn't set to %s", dsp_stereo?  "stereo":"mono");
+	st_warn("Couldn't set to %s", dsp_stereo?  "stereo":"mono");
 	dsp_stereo = 0;
     }
 
@@ -136,7 +136,7 @@
 	 */
 	if (ft->info.rate - tmp > (tmp * .01) || 
 	    tmp - ft->info.rate > (tmp * .01)) {
-	    warn("Unable to set audio speed to %d (set to %d)",
+	    st_warn("Unable to set audio speed to %d (set to %d)",
 		     ft->info.rate, tmp);
 	    ft->info.rate = tmp;
 	}
--- a/src/pan.c
+++ b/src/pan.c
@@ -73,7 +73,7 @@
     if (n && (!sscanf(argv[0], PAN_FLOAT_SCAN, &pan->dir) || 
 	      pan->dir < MONE || pan->dir > ONE))
     {
-	fail(PAN_USAGE);
+	st_fail(PAN_USAGE);
 	return ST_EOF;
     }
 
@@ -87,11 +87,11 @@
 eff_t effp;
 {
     if (effp->outinfo.channels==1)
-	warn("PAN onto a mono channel...");
+	st_warn("PAN onto a mono channel...");
 
     if (effp->outinfo.rate != effp->ininfo.rate)
     {
-	fail("PAN cannot handle different rates (in=%ld, out=%ld)"
+	st_fail("PAN cannot handle different rates (in=%ld, out=%ld)"
 	     " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
 	return ST_EOF;
     }
@@ -125,7 +125,7 @@
 #endif
 
 #define UNEXPECTED_CHANNELS \
-    fail("unexpected number of channels (in=%d, out=%d)", ich, och); \
+    st_fail("unexpected number of channels (in=%d, out=%d)", ich, och); \
     return ST_EOF
 
 /*
@@ -405,7 +405,7 @@
 {
     pan_t pan = (pan_t) effp->priv;
     if (pan->clipped) {
-	warn("PAN clipped %d values, maybe adjust volume?",
+	st_warn("PAN clipped %d values, maybe adjust volume?",
 	     pan->clipped);
     }
     return ST_SUCCESS;
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -89,7 +89,7 @@
 
 	if (!((n == 5) || (n == 6)))
 	{
-	    fail("Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]");
+	    st_fail("Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]");
 	    return (ST_EOF);
 	}
 
@@ -106,7 +106,7 @@
 			phaser->modulation = MOD_TRIANGLE;
 		else
 		{
-	    		fail("Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]");
+	    		st_fail("Usage: phaser gain-in gain-out delay decay speed [ -s | -t ]");
 			return (ST_EOF);
 		}
 	}
@@ -126,39 +126,39 @@
 
 	if ( phaser->delay < 0.0 )
 	{
-	    fail("phaser: delay must be positive!\n");
+	    st_fail("phaser: delay must be positive!\n");
 	    return (ST_EOF);
 	}
 	if ( phaser->delay > 5.0 )
 	{
-	    fail("phaser: delay must be less than 5.0 msec!\n");
+	    st_fail("phaser: delay must be less than 5.0 msec!\n");
 	    return (ST_EOF);
 	}
 	if ( phaser->speed < 0.1 )
 	{
-	    fail("phaser: speed must be more than 0.1 Hz!\n");
+	    st_fail("phaser: speed must be more than 0.1 Hz!\n");
 	    return (ST_EOF);
 	}
 	if ( phaser->speed > 2.0 )
 	{
-	    fail("phaser: speed must be less than 2.0 Hz!\n");
+	    st_fail("phaser: speed must be less than 2.0 Hz!\n");
 	    return (ST_EOF);
 	}
 	if ( phaser->decay < 0.0 )
 	{
-	    fail("phaser: decay must be positive!\n" );
+	    st_fail("phaser: decay must be positive!\n" );
 	    return (ST_EOF);
 	}
 	if ( phaser->decay >= 1.0 )
 	{
-	    fail("phaser: decay must be less that 1.0!\n" );
+	    st_fail("phaser: decay must be less that 1.0!\n" );
 	    return (ST_EOF);
 	}
 	/* Be nice and check the hint with warning, if... */
 	if ( phaser->in_gain > ( 1.0 - phaser->decay * phaser->decay ) )
-		warn("phaser: warning >>> gain-in can cause saturation or clipping of output <<<");
+		st_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 )
-		warn("phaser: warning >>> gain-out can cause saturation or clipping of output <<<");
+		st_warn("phaser: warning >>> gain-out can cause saturation or clipping of output <<<");
 
 	phaser->length = effp->ininfo.rate / phaser->speed;
 
@@ -165,7 +165,7 @@
 	if (! (phaser->phaserbuf = 
 		(double *) malloc(sizeof (double) * phaser->maxsamples)))
 	{
-		fail("phaser: Cannot malloc %d bytes!\n", 
+		st_fail("phaser: Cannot malloc %d bytes!\n", 
 			sizeof(double) * phaser->maxsamples);
 		return (ST_EOF);
 	}
@@ -174,7 +174,7 @@
 	if (! (phaser->lookup_tab = 
 		(int *) malloc(sizeof (int) * phaser->length)))
 	{
-		fail("phaser: Cannot malloc %d bytes!\n", 
+		st_fail("phaser: Cannot malloc %d bytes!\n", 
 			sizeof(int) * phaser->length);
 		return (ST_EOF);
 	}
--- a/src/pitch.c
+++ b/src/pitch.c
@@ -306,7 +306,7 @@
 
     if (n && !sscanf(argv[0], PITCH_FLOAT_SCAN, &pitch->shift))
     {
-	fail(PITCH_USAGE);
+	st_fail(PITCH_USAGE);
 	return ST_EOF;
     }
 
@@ -314,7 +314,7 @@
     pitch->width = PITCH_DEFAULT_WIDTH;
     if (n>1 && !sscanf(argv[1], PITCH_FLOAT_SCAN, &pitch->width))
     {
-	fail(PITCH_USAGE);
+	st_fail(PITCH_USAGE);
 	return ST_EOF;
     }
 
@@ -333,7 +333,7 @@
 	    pitch->interopt = PITCH_INTERPOLE_CUB;
 	    break;
 	default:
-	    fail(PITCH_USAGE);
+	    st_fail(PITCH_USAGE);
 	    return ST_EOF;
 	}
     }
@@ -361,7 +361,7 @@
 	    pitch->fadeopt = PITCH_FADE_COS;
 	    break;
 	default:
-	    fail(PITCH_USAGE);
+	    st_fail(PITCH_USAGE);
 	    return ST_EOF;
 	}
     }
@@ -370,7 +370,7 @@
     if (n>4 && (!sscanf(argv[4], PITCH_FLOAT_SCAN, &pitch->coef) ||
 		pitch->coef<ZERO || pitch->coef>HALF))
     {
-	fail(PITCH_USAGE);
+	st_fail(PITCH_USAGE);
 	return ST_EOF;
     }
 
@@ -392,7 +392,7 @@
      */
     if (effp->outinfo.rate != effp->ininfo.rate)
     {
-	fail("PITCH cannot handle different rates (in=%ld, out=%ld)"
+	st_fail("PITCH cannot handle different rates (in=%ld, out=%ld)"
 	     " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
 	return ST_EOF;
     }
@@ -399,7 +399,7 @@
  
     if (effp->outinfo.channels != effp->ininfo.channels)
     {
-	fail("PITCH cannot handle different channels (in=%ld, out=%ld)"
+	st_fail("PITCH cannot handle different channels (in=%ld, out=%ld)"
 	     " use avg or pan", effp->ininfo.channels, effp->outinfo.channels);
 	return ST_EOF;
     }
@@ -434,7 +434,7 @@
 
     if (!pitch->fade || !pitch->tmp || !pitch->acc || !pitch->buf)
     {
-	fail("malloc failed in st_pitch_start");
+	st_fail("malloc failed in st_pitch_start");
 	return ST_EOF;
     }
 
@@ -487,7 +487,7 @@
     }
     else
     {
-	fail("unexpected PITCH_FADE parameter %d", pitch->fadeopt);
+	st_fail("unexpected PITCH_FADE parameter %d", pitch->fadeopt);
 	return ST_EOF;
     }
 
@@ -619,7 +619,7 @@
     free(pitch->buf);
 
     if (pitch->clipped)
-	warn("PITCH clipped %d values... adjust volume with -v option maybe?", 
+	st_warn("PITCH clipped %d values... adjust volume with -v option maybe?", 
 	     pitch->clipped);
 
     return ST_SUCCESS;
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -128,7 +128,7 @@
       continue;
     }
 
-    fail("Polyphase: unknown argument (%s %s)!", argv[0], argv[1]);
+    st_fail("Polyphase: unknown argument (%s %s)!", argv[0], argv[1]);
     return (ST_EOF);
   }
   return (ST_SUCCESS);
@@ -170,11 +170,11 @@
 
   p = primes;
   q = q0;
-  report("factors(%d) =",n);
+  st_report("factors(%d) =",n);
   while (n > 1) {
     while ((pr = *p) && (n % pr)) p++;
     if (!pr) {
-      fail("Number %d too large of a prime.\n",n);
+      st_fail("Number %d too large of a prime.\n",n);
       pr = n;
     }
     *q++ = pr;
@@ -300,7 +300,7 @@
   int N1;
 
   if(buffer == NULL || length <= 0)
-    fail("Illegal buffer %p or length %d to nuttall.\n", buffer, length);
+    st_fail("Illegal buffer %p or length %d to nuttall.\n", buffer, length);
 
   /* Initial variable setups. */
   N = length;
@@ -323,7 +323,7 @@
     int N1;
 
     if(buffer == NULL || length <= 0)
-      fail("Illegal buffer %p or length %d to hamming.\n",buffer,length);
+      st_fail("Illegal buffer %p or length %d to hamming.\n",buffer,length);
 
     N1 = length/2;
     for(j=0;j<length;j++) 
@@ -349,7 +349,7 @@
     double sum;
 
     if(buffer == NULL || length < 0 || cutoff < 0 || cutoff > PI)
-      fail("Illegal buffer %p, length %d, or cutoff %f.\n",buffer,length,cutoff);
+      st_fail("Illegal buffer %p, length %d, or cutoff %f.\n",buffer,length,cutoff);
 
     /* Use the user-option of window type */
     if(win_type == 0) 
@@ -407,9 +407,9 @@
     rate->total = total;
     /* l1 and l2 are now lists of the up/down factors for conversion */
 
-    report("Poly:  input rate %d, output rate %d.  %d stages.",
+    st_report("Poly:  input rate %d, output rate %d.  %d stages.",
             effp->ininfo.rate, effp->outinfo.rate,total);
-    report("Poly:  window: %s  size: %d  cutoff: %f.",
+    st_report("Poly:  window: %s  size: %d  cutoff: %f.",
             (win_type == 0) ? ("nut") : ("ham"), win_width, cutoff);
 
     /* Create an array of filters and past history */
@@ -429,7 +429,7 @@
       s->size = size;
       s->hsize = f_len/s->up; /* this much of window is past-history */
       s->held = 0;
-      report("Poly:  stage %d:  Up by %d, down by %d,  i_samps %d, hsize %d",
+      st_report("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 *) malloc(sizeof(Float) * f_len);
@@ -439,7 +439,7 @@
         s->window[j] = 0.0;
 
       uprate *= s->up;
-      report("Poly:         :  filt_len %d, cutoff freq %.1f",
+      st_report("Poly:         :  filt_len %d, cutoff freq %.1f",
               f_len, uprate*cutoff/f_cutoff);
       uprate /= s->down;
       fir_design(s->filt_array, f_len, cutoff/f_cutoff);
@@ -463,7 +463,7 @@
       s->filt_array = NULL;
       s->window = (Float *) malloc(sizeof(Float) * size);
     }
-    report("Poly:  output samples %d, oskip %d",size, rate->oskip);
+    st_report("Poly:  output samples %d, oskip %d",size, rate->oskip);
     return (ST_SUCCESS);
 }
 
@@ -500,7 +500,7 @@
   /*for (mm=0; mm<s->filt_len; mm++) fprintf(stderr,"cf_%d %f\n",mm,s->filt_array[mm]);*/
   /* assumes s->size divisible by down (now true) */
   o_top = output + (s->size * up) / down;
-  /*report(" isize %d, osize %d, up %d, down %d, N %d", s->size, o_top-output, up, down, f_len);*/
+  /*st_report(" 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;
--- a/src/rate.c
+++ b/src/rate.c
@@ -60,7 +60,7 @@
 {
 	if (n)
 	{
-		fail("Rate effect takes no options.");
+		st_fail("Rate effect takes no options.");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
@@ -77,13 +77,13 @@
 
 	if (effp->ininfo.rate >= 65535 || effp->outinfo.rate >= 65535)
 	{
-	    fail("rate effect can only handle rates <= 65535");
+	    st_fail("rate effect can only handle rates <= 65535");
 	    return (ST_EOF);
 	}
 	if (effp->ininfo.size == ST_SIZE_DWORD ||
 	    effp->ininfo.size == ST_SIZE_FLOAT)
 	{
-	    warn("rate effect reduces data to 16 bits");
+	    st_warn("rate effect reduces data to 16 bits");
 	}
 
         rate->opos_frac=0;
@@ -245,7 +245,7 @@
 {
 	if (n)
 	{
-		fail("Rate effect takes no options.");
+		st_fail("Rate effect takes no options.");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
--- a/src/raw.c
+++ b/src/raw.c
@@ -39,7 +39,7 @@
 	ft->file.buf = malloc(BUFSIZ);
 	if (!ft->file.buf)
 	{
-	    fail("Unable to alloc resources");
+	    st_fail("Unable to alloc resources");
 	    return(ST_EOF);
 	}
 	ft->file.size = BUFSIZ;
@@ -56,7 +56,7 @@
 	ft->file.buf = malloc(BUFSIZ);
 	if (!ft->file.buf)
 	{
-	    fail("Unable to alloc resources");
+	    st_fail("Unable to alloc resources");
 	    return(ST_EOF);
 	}
 	ft->file.size = BUFSIZ;
@@ -241,10 +241,10 @@
 				}
 				return done;
 			case ST_ENCODING_ULAW:
-				fail("No U-Law support for shorts");
+				st_fail("No U-Law support for shorts");
 				return 0;
 			case ST_ENCODING_ALAW:
-				fail("No A-Law support for shorts");
+				st_fail("No A-Law support for shorts");
 				return 0;
 		    }
 		    break;
@@ -276,7 +276,7 @@
 		default:
 			break;
 	}
-	fail("Sorry, don't have code to read %s, %s",
+	st_fail("Sorry, don't have code to read %s, %s",
 		st_encodings_str[ft->info.encoding], st_sizes_str[ft->info.size]);
 	return(0);
 }
@@ -294,7 +294,7 @@
 {
 	if (fwrite(ft->file.buf, 1, ft->file.pos, ft->fp) != ft->file.pos)
 	{
-		fail("Error writing data to file");
+		st_fail("Error writing data to file");
 	}
 	ft->file.pos = 0;
 }
@@ -454,10 +454,10 @@
 				}
 				return done;
 			case ST_ENCODING_ULAW:
-				fail("No U-Law support for shorts");
+				st_fail("No U-Law support for shorts");
 				return 0;
 			case ST_ENCODING_ALAW:
-				fail("No A-Law support for shorts");
+				st_fail("No A-Law support for shorts");
 				return 0;
 		    }
 		    break;
@@ -486,7 +486,7 @@
 		default:
 			break;
 	}
-	fail("Sorry, don't have code to write %s, %s",
+	st_fail("Sorry, don't have code to write %s, %s",
 		st_encodings_str[ft->info.encoding], st_sizes_str[ft->info.size]);
 	return 0;
 }
--- a/src/resample.c
+++ b/src/resample.c
@@ -145,25 +145,25 @@
 
 	if ((n >= 1) && (sscanf(argv[0], "%lf", &r->rolloff) != 1))
 	{
-	  fail("Usage: resample [ rolloff [ beta ] ]");
+	  st_fail("Usage: resample [ rolloff [ beta ] ]");
 	  return (ST_EOF);
 	}
 	else if ((r->rolloff <= 0.01) || (r->rolloff >= 1.0))
 	{
-	  fail("resample: rolloff factor (%f) no good, should be 0.01<x<1.0", r->rolloff);
+	  st_fail("resample: rolloff factor (%f) no good, should be 0.01<x<1.0", r->rolloff);
 	  return(ST_EOF);
 	}
 
 	if ((n >= 2) && !sscanf(argv[1], "%lf", &r->beta))
 	{
-	  fail("Usage: resample [ rolloff [ beta ] ]");
+	  st_fail("Usage: resample [ rolloff [ beta ] ]");
 	  return (ST_EOF);
 	}
 	else if (r->beta <= 2.0) {
 	  r->beta = 0;
-		report("resample opts: Nuttall window, cutoff %f\n", r->rolloff);
+		st_report("resample opts: Nuttall window, cutoff %f\n", r->rolloff);
 	} else {
-		report("resample opts: Kaiser window, cutoff %f, beta %f\n", r->rolloff, r->beta);
+		st_report("resample opts: Kaiser window, cutoff %f, beta %f\n", r->rolloff, r->beta);
 	}
 	return (ST_SUCCESS);
 }
@@ -194,9 +194,9 @@
 
 	/* Check for illegal constants */
 # if 0
-	if (Lp >= 16) fail("Error: Lp>=16");
-	if (Nb+Nhg+NLpScl >= 32) fail("Error: Nb+Nhg+NLpScl>=32");
-	if (Nh+Nb > 32) fail("Error: Nh+Nb>32");
+	if (Lp >= 16) st_fail("Error: Lp>=16");
+	if (Nb+Nhg+NLpScl >= 32) st_fail("Error: Nb+Nhg+NLpScl>=32");
+	if (Nh+Nb > 32) st_fail("Error: Nh+Nb>32");
 # endif
 
 	/* Nwing: # of filter coeffs in right wing */
@@ -208,15 +208,15 @@
 	i = makeFilter(r->Imp, r->Nwing, r->rolloff, r->beta, r->Nq, 1);
 	if (i <= 0)
 	{
-		fail("resample: Unable to make filter\n");
+		st_fail("resample: Unable to make filter\n");
 		return (ST_EOF);
 	}
 
-	/*report("Nmult: %ld, Nwing: %ld, Nq: %ld\n",r->Nmult,r->Nwing,r->Nq);*/
+	/*st_report("Nmult: %ld, Nwing: %ld, Nq: %ld\n",r->Nmult,r->Nwing,r->Nq);*/
 
 	if (r->quadr < 0) { /* exact coeff's method */
 		r->Xh = r->Nwing/r->b;
-	  report("resample: rate ratio %ld:%ld, coeff interpolation not needed\n", r->a, r->b);
+	  st_report("resample: rate ratio %ld:%ld, coeff interpolation not needed\n", r->a, r->b);
 	} else {
 	  r->dhb = Np;  /* Fixed-point Filter sampling-time-increment */
 	  if (r->Factor<1.0) r->dhb = r->Factor*Np + 0.5;
@@ -240,13 +240,13 @@
 	i = BUFFSIZE - 2*Xoff;
 	if (i < r->Factor + 1.0/r->Factor)      /* Check input buffer size */
 	{
-		fail("Factor is too small or large for BUFFSIZE");
+		st_fail("Factor is too small or large for BUFFSIZE");
 		return (ST_EOF);
 	}
 	
 	r->Xsize = 2*Xoff + i/(1.0+r->Factor);
 	r->Ysize = BUFFSIZE - r->Xsize;
-	/* report("Xsize %d, Ysize %d, Xoff %d",r->Xsize,r->Ysize,r->Xoff); */
+	/* st_report("Xsize %d, Ysize %d, Xoff %d",r->Xsize,r->Ysize,r->Xoff); */
 
 	r->X = (Float *) malloc(sizeof(Float) * (BUFFSIZE));
 	r->Y = r->X + r->Xsize;
@@ -282,7 +282,7 @@
 	Nx = Nproc - r->Xread; /* space for right-wing future-data */
 	if (Nx <= 0)
 	{
-		fail("Nx not positive: %d", Nx);
+		st_fail("Nx not positive: %d", Nx);
 		return (ST_EOF);
 	}
 	if (Nx > *isamp)
@@ -396,7 +396,7 @@
 	*osamp -= osamp_res;
 	/* fprintf(stderr,"DRAIN osamp %d\n", *osamp); */
 	if (isamp_res)
-		warn("drain overran obuf by %d\n", isamp_res); fflush(stderr);
+		st_warn("drain overran obuf by %d\n", isamp_res); fflush(stderr);
 	return (ST_SUCCESS);
 }
 
@@ -616,7 +616,7 @@
       for (i=Dh; i<Mwing; i+=Dh)
          DCgain += ImpR[i];
       DCgain = 2*DCgain + ImpR[0];    /* DC gain of real coefficients */
-      /*report("DCgain err=%.12f",DCgain-1.0);*/
+      /*st_report("DCgain err=%.12f",DCgain-1.0);*/
   
       DCgain = 1.0/DCgain;
       for (i=0; i<Mwing; i++)
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -127,13 +127,13 @@
 
 	if ( n < 3 )
 	{
-	    fail("Usage: reverb gain-out reverb-time delay [ delay ... ]");
+	    st_fail("Usage: reverb gain-out reverb-time delay [ delay ... ]");
 	    return (ST_EOF);
 	}
 
 	if ( n - 2 > MAXREVERBS )
 	{
-	    fail("reverb: to many dalays, use less than %i delays",
+	    st_fail("reverb: to many dalays, use less than %i delays",
 			MAXREVERBS);
 	    return (ST_EOF);
 	}
@@ -162,14 +162,14 @@
 
 	if ( reverb->out_gain < 0.0 )
 	{
-		fail("reverb: gain-out must be positive");
+		st_fail("reverb: gain-out must be positive");
 		return (ST_EOF);
 	}
 	if ( reverb->out_gain > 1.0 )
-		warn("reverb: warnig >>> gain-out can cause saturation of output <<<");
+		st_warn("reverb: warnig >>> gain-out can cause saturation of output <<<");
 	if ( reverb->time < 0.0 )
 	{
-		fail("reverb: reverb-time must be positive");
+		st_fail("reverb: reverb-time must be positive");
 		return (ST_EOF);
 	}
 	for(i = 0; i < reverb->numdelays; i++) {
@@ -176,12 +176,12 @@
 		reverb->samples[i] = reverb->delay[i] * effp->ininfo.rate / 1000.0;
 		if ( reverb->samples[i] < 1 )
 		{
-		    fail("reverb: delay must be positive!\n");
+		    st_fail("reverb: delay must be positive!\n");
 		    return (ST_EOF);
 		}
 		if ( reverb->samples[i] > DELAY_BUFSIZ )
 		{
-			fail("reverb: delay must be less than %g seconds!\n",
+			st_fail("reverb: delay must be less than %g seconds!\n",
 				DELAY_BUFSIZ / (float) effp->ininfo.rate );
 			return(ST_EOF);
 		}
@@ -192,7 +192,7 @@
 	}
 	if (! (reverb->reverbbuf = (float *) malloc(sizeof (float) * reverb->maxsamples)))
 	{
-		fail("reverb: Cannot malloc %d bytes!\n", 
+		st_fail("reverb: Cannot malloc %d bytes!\n", 
 			sizeof(float) * reverb->maxsamples);
 		return(ST_EOF);
 	}
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -42,7 +42,7 @@
 {
 	if (n)
 	{
-		fail("Reverse effect takes no options.");
+		st_fail("Reverse effect takes no options.");
 		return (ST_EOF);
 	}
 	return(ST_SUCCESS);
@@ -59,7 +59,7 @@
 	reverse->fp = tmpfile();
 	if (reverse->fp == NULL)
 	{
-		fail("Reverse effect can't create temporary file\n");
+		st_fail("Reverse effect can't create temporary file\n");
 		return (ST_EOF);
 	}
 	reverse->phase = WRITING;
@@ -80,13 +80,13 @@
 
 	if (reverse->phase != WRITING)
 	{
-		fail("Internal error: reverse_flow called in wrong phase");
+		st_fail("Internal error: reverse_flow called in wrong phase");
 		return(ST_EOF);
 	}
 	if (fwrite((char *)ibuf, sizeof(LONG), *isamp, reverse->fp)
 	    != *isamp)
 	{
-		fail("Reverse effect write error on temporary file\n");
+		st_fail("Reverse effect write error on temporary file\n");
 		return(ST_EOF);
 	}
 	*osamp = 0;
@@ -113,7 +113,7 @@
 		reverse->pos = ftell(reverse->fp);
 		if (reverse->pos % sizeof(LONG) != 0)
 		{
-			fail("Reverse effect finds odd temporary file\n");
+			st_fail("Reverse effect finds odd temporary file\n");
 			return(ST_EOF);
 		}
 		reverse->phase = READING;
@@ -128,7 +128,7 @@
 	fseek(reverse->fp, reverse->pos, SEEK_SET);
 	if (fread((char *)obuf, sizeof(LONG), len, reverse->fp) != len)
 	{
-		fail("Reverse effect read error from temporary file\n");
+		st_fail("Reverse effect read error from temporary file\n");
 		return(ST_EOF);
 	}
 	for (i = 0, j = len-1; i < j; i++, j--) {
--- a/src/sf.c
+++ b/src/sf.c
@@ -55,7 +55,7 @@
 		case SF_COMMENT:
 			if((commentbuf = (char *) malloc(bsize + 1)) != NULL) {
 				memcpy(commentbuf, sfcharp, bsize);
-				report("IRCAM comment: %s", sfcharp);
+				st_report("IRCAM comment: %s", sfcharp);
 				commentbuf[bsize] = '\0';
 				if((newline = strchr(commentbuf, '\n')) != NULL)
 					*newline = '\0';
@@ -89,7 +89,7 @@
 	
 	if (fread(&sfhead, 1, sizeof(sfhead), ft->fp) != sizeof(sfhead))
 	{
-		fail("unexpected EOF in SF header");
+		st_fail("unexpected EOF in SF header");
 		return(ST_EOF);
 	}
 	memcpy(&sf->info, &sfhead.sfinfo, sizeof(struct sfinfo));
@@ -100,7 +100,7 @@
 	}
 	if ((sfmagic1(&sfhead) != SF_MAGIC1) ||
 	    (sfmagic2(&sfhead) != SF_MAGIC2))
-		fail(
+		st_fail(
 "SF %s file: can't read, it is byte-swapped or it is not an IRCAM SoundFile", 
 			ft->filename);
 
@@ -120,7 +120,7 @@
 			ft->info.encoding = ST_ENCODING_SIGN2;
 			break;
 		default:
-			fail("Soundfile input: unknown format 0x%x\n",
+			st_fail("Soundfile input: unknown format 0x%x\n",
 				sf->info.sf_packmode);
 			return(ST_EOF);
 	}
--- a/src/silence.c
+++ b/src/silence.c
@@ -40,7 +40,7 @@
 {
 	if (n)
 	{
-		fail("Silence effect takes no options.");
+		st_fail("Silence effect takes no options.");
 		return (ST_EOF);
 	}
 }
--- a/src/skel.c
+++ b/src/skel.c
@@ -34,7 +34,7 @@
 	/* If you need to seek around the input file. */
 	if (! ft->seekable)
 	{
-		fail("SKEL input file must be a file, not a pipe");
+		st_fail("SKEL input file must be a file, not a pipe");
 		return (ST_EOF);
 	}
 
@@ -103,7 +103,7 @@
 	/* If you have to seek around the output file */
 	if (! ft->seekable)
 	{
-		fail("Output .skel file must be a file, not a pipe");
+		st_fail("Output .skel file must be a file, not a pipe");
 		return (ST_EOF);
 	}
 
@@ -130,7 +130,7 @@
 	while(len--)
 	    st_writeb(ft, (*buf++ >> 24) ^ 0x80);
 	/* If you cannot write out all of the supplied samples, */
-	/*	fail("SKEL: Can't write all samples to %s", ft->filename); */
+	/*	st_fail("SKEL: Can't write all samples to %s", ft->filename); */
 	/*      return (ST_EOF); */
 	return (ST_SUCCESS);
 	
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -35,7 +35,7 @@
     {
 	if (n != 1)
 	{
-	    fail("Usage: skeleff [option]");
+	    st_fail("Usage: skeleff [option]");
 	    return (ST_EOF);
 	}
     }
@@ -51,7 +51,7 @@
 {
     if (effp->outinfo.channels == 1)
     {
-	fail("Can't run skeleff on mono data.");
+	st_fail("Can't run skeleff on mono data.");
 	return (ST_EOF);
     }
     return (ST_SUCCESS);
--- a/src/smp.c
+++ b/src/smp.c
@@ -92,7 +92,7 @@
 	for(i = 0; i < 8; i++) {	/* read the 8 markers */
 	        if (fread(trailer->markers[i].name, 1, 10, ft->fp) != 10)
 		{
-		    fail("EOF in SMP");
+		    st_fail("EOF in SMP");
 		    return(ST_EOF);
 		}
 		st_readdw(ft, &(trailer->markers[i].position));
@@ -160,7 +160,7 @@
 	for(i = 0; i < 8; i++) {	/* write the 8 markers */
 		if (st_writes(ft, trailer->markers[i].name) == ST_EOF)
 		{
-		    fail("EOF in SMP");
+		    st_fail("EOF in SMP");
 	 	    return(ST_EOF);
 		}
 		st_writedw(ft, trailer->markers[i].position);
@@ -202,7 +202,7 @@
 	/* If you need to seek around the input file. */
 	if (! ft->seekable)
 	{
-		fail("SMP input file must be a file, not a pipe");
+		st_fail("SMP input file must be a file, not a pipe");
 		return(ST_EOF);
 	}
 
@@ -209,17 +209,17 @@
 	/* Read SampleVision header */
 	if (fread((char *) &header, 1, HEADERSIZE, ft->fp) != HEADERSIZE)
 	{
-		fail("unexpected EOF in SMP header");
+		st_fail("unexpected EOF in SMP header");
 		return(ST_EOF);
 	}
 	if (strncmp(header.Id, SVmagic, 17) != 0)
 	{
-		fail("SMP header does not begin with magic word %s\n", SVmagic);
+		st_fail("SMP header does not begin with magic word %s\n", SVmagic);
 		return(ST_EOF);
 	}
 	if (strncmp(header.version, SVvers, 4) != 0)
 	{
-		fail("SMP header is not version %s\n", SVvers);
+		st_fail("SMP header is not version %s\n", SVvers);
 		return(ST_EOF);
 	}
 
@@ -236,7 +236,7 @@
 		commentlen+1, header.comments);
 	ft->comment = smp->comment;
 
-	report("SampleVision file name and comments: %s", ft->comment);
+	st_report("SampleVision file name and comments: %s", ft->comment);
 	/* Extract out the sample size (always intel format) */
 	st_readdw(ft, &(smp->NoOfSamps));
 	/* mark the start of the sample data */
@@ -246,12 +246,12 @@
 	/* NoOfSamps * 2 */
 	if (fseek(ft->fp, smp->NoOfSamps * 2L, 1) == -1)
 	{
-		fail("SMP unable to seek to trailer");
+		st_fail("SMP unable to seek to trailer");
 		return(ST_EOF);
 	}
 	if (readtrailer(ft, &trailer))
 	{
-		fail("unexpected EOF in SMP trailer");
+		st_fail("unexpected EOF in SMP trailer");
 		return(ST_EOF);
 	}
 
@@ -258,7 +258,7 @@
 	/* seek back to the beginning of the data */
 	if (fseek(ft->fp, samplestart, 0) == -1) 
 	{
-		fail("SMP unable to seek back to start of sample data");
+		st_fail("SMP unable to seek back to start of sample data");
 		return(ST_EOF);
 	}
 
@@ -267,23 +267,23 @@
 	ft->info.encoding = ST_ENCODING_SIGN2;
 	ft->info.channels = 1;
 
-	report("SampleVision trailer:\n");
+	st_report("SampleVision trailer:\n");
 	for(i = 0; i < 8; i++) if (1 || trailer.loops[i].count) {
 #ifdef __alpha__
-		report("Loop %d: start: %6d", i, trailer.loops[i].start);
-		report(" end:   %6d", trailer.loops[i].end);
+		st_report("Loop %d: start: %6d", i, trailer.loops[i].start);
+		st_report(" end:   %6d", trailer.loops[i].end);
 #else
-		report("Loop %d: start: %6ld", i, trailer.loops[i].start);
-		report(" end:   %6ld", trailer.loops[i].end);
+		st_report("Loop %d: start: %6ld", i, trailer.loops[i].start);
+		st_report(" end:   %6ld", trailer.loops[i].end);
 #endif
-		report(" count: %6d", trailer.loops[i].count);
+		st_report(" count: %6d", trailer.loops[i].count);
 		switch(trailer.loops[i].type) {
-		    case 0: report("type:  off\n"); break;
-		    case 1: report("type:  forward\n"); break;
-		    case 2: report("type:  forward/backward\n"); break;
+		    case 0: st_report("type:  off\n"); break;
+		    case 1: st_report("type:  forward\n"); break;
+		    case 2: st_report("type:  forward/backward\n"); break;
 		}
 	}
-	report("MIDI Note number: %d\n\n", trailer.MIDInote);
+	st_report("MIDI Note number: %d\n\n", trailer.MIDInote);
 
 	ft->instr.nloops = 0;
 	for(i = 0; i < 8; i++) 
@@ -358,7 +358,7 @@
 	/* If you have to seek around the output file */
 	if (! ft->seekable)
 	{
-		fail("Output .smp file must be a file, not a pipe");
+		st_fail("Output .smp file must be a file, not a pipe");
 		return(ST_EOF);
 	}
 
@@ -375,7 +375,7 @@
 	/* Write file header */
 	if(fwrite(&header, 1, HEADERSIZE, ft->fp) != HEADERSIZE)
 	{
-	    fail("SMP: Can't write header completely");
+	    st_fail("SMP: Can't write header completely");
 	    return(ST_EOF);
 	}
 	st_writedw(ft, 0);	/* write as zero length for now, update later */
@@ -413,7 +413,7 @@
 	writetrailer(ft, &trailer);
 	if (fseek(ft->fp, 112, 0) == -1)
 	{
-		fail("SMP unable to seek back to save size");
+		st_fail("SMP unable to seek back to save size");
 		return(ST_EOF);
 	}
 	st_writedw(ft, smp->NoOfSamps);
--- a/src/sndrtool.c
+++ b/src/sndrtool.c
@@ -67,7 +67,7 @@
 
 	if (fread(buf, 1, 2, ft->fp) != 2)
 	{
-		fail("SND: unexpected EOF");
+		st_fail("SND: unexpected EOF");
 		return(ST_EOF);
 	}
 	if (strncmp(buf,"\0\0",2) == 0)
@@ -76,7 +76,7 @@
 	st_readw(ft, &rate);
 	if (rate < 4000 || rate > 25000 )
 	{
-		fail ("SND: sample rate out of range");
+		st_fail("SND: sample rate out of range");
 		return(ST_EOF);
 	}
 	fseek(ft->fp,4,SEEK_CUR);
@@ -87,7 +87,7 @@
 	fread(&buf[2], 1, 6, ft->fp);
 	if (strncmp(buf,"SOUND",5))
 	{
-		fail ("SND: unrecognized SND format");
+		st_fail("SND: unrecognized SND format");
 		return(ST_EOF);
 	}
 	fseek(ft->fp,12,SEEK_CUR);
@@ -95,10 +95,10 @@
 	fseek(ft->fp,6,SEEK_CUR);
 	if (st_reads(ft, buf, 96) == ST_EOF)
 	{
-		fail ("SND: unexpected EOF in SND header");
+		st_fail("SND: unexpected EOF in SND header");
 		return(ST_EOF);
 	}
-	report ("%s",buf);
+	st_report("%s",buf);
 	}
 
 ft->info.channels = 1;
@@ -212,7 +212,7 @@
 
 	/* fixup file sizes in header */
 	if (fseek(ft->fp, 0L, 0) != 0)
-		fail("can't rewind output file to rewrite SND header");
+		st_fail("can't rewind output file to rewrite SND header");
 	sndtwriteheader(ft, p->nsamples);
 
 	return(ST_SUCCESS);
--- a/src/sox.c
+++ b/src/sox.c
@@ -128,7 +128,7 @@
 	if (! strcmp(ifile, "-"))
 		ft->fp = stdin;
 	else if ((ft->fp = fopen(ifile, READBINARY)) == NULL)
-		fail("Can't open input file '%s': %s", 
+		st_fail("Can't open input file '%s': %s", 
 			ifile, strerror(errno));
 	ft->filename = ifile;
 #if	defined(DUMB_FILESYSTEM)
@@ -187,7 +187,7 @@
 
 	/* Check global arguments */
 	if (informat.info.dovol && informat.info.vol == 0.0)
-		fail("Volume must be non-zero"); /* negative volume is phase-reversal */
+		st_fail("Volume must be non-zero"); /* negative volume is phase-reversal */
 	
 	/* If file types have not been set with -t, set from file names. */
 	if (! informat.filetype) {
@@ -254,7 +254,7 @@
 			str = optarg;
 			/* FIXME: allow "A-B" "-B" "A-" "A,B" also maybe lists of ranges */
 			if ( 2 != sscanf(str, "%lu-%lu", &ft->info.x0, &ft->info.x1))
-				fail("eXtract range '%s' is not valid", optarg);
+				st_fail("eXtract range '%s' is not valid", optarg);
 			if (ft->info.x1==0) ft->info.x1 -= 1; /* MAXULONG */
 			break;
 
@@ -268,13 +268,13 @@
 			if ((! sscanf(str, "%lu", &ft->info.rate)) ||
 					(ft->info.rate <= 0))
 #endif
-				fail("-r must be given a positive integer");
+				st_fail("-r must be given a positive integer");
 			break;
 		case 'v':
 			if (!ft || ft->info.dovol) usage("-v");
 			str = optarg;
 			if (! sscanf(str, "%lf", &ft->info.vol)) /* neg volume is ok */
-				fail("Volume value '%s' is not a number", optarg);
+				st_fail("Volume value '%s' is not a number", optarg);
 			ft->info.dovol = 1;
 			break;
 
@@ -282,13 +282,13 @@
 			if (! ft) usage("-c");
 			str = optarg;
 			if (! sscanf(str, "%d", &ft->info.channels))
-				fail("-c must be given a number");
+				st_fail("-c must be given a number");
 			break;
 		case 'B':
 			if (! ft) usage("-B");
 			str = optarg;
 			if (! sscanf(str, "%hu", &ft->info.bs) || ft->info.bs<=0) /* blocksize */
-				fail("-B must be given a positive number");
+				st_fail("-B must be given a positive number");
 			break;
 		case 'b':
 			if (! ft) usage("-b");
@@ -407,21 +407,21 @@
     /* Read and write starters can change their formats. */
     if ((* informat.h->startread)(&informat) == ST_EOF)
     {
-        fail(informat.st_errstr);
+        st_fail(informat.st_errstr);
     }
     st_checkformat(&informat);
     
     if (informat.info.dovol)
-	report("Volume factor: %f\n", informat.info.vol);
+	st_report("Volume factor: %f\n", informat.info.vol);
     if (informat.info.x0 || informat.info.x1 != MAXULONG)
-	report("Extract samples %lu <= x < %lu\n", informat.info.x0, informat.info.x0);
+	st_report("Extract samples %lu <= x < %lu\n", informat.info.x0, informat.info.x0);
     
-    report("Input file: using sample rate %lu\n\tsize %s, encoding %s, %d %s",
+    st_report("Input file: using sample rate %lu\n\tsize %s, encoding %s, %d %s",
 	   informat.info.rate, st_sizes_str[informat.info.size], 
 	   st_encodings_str[informat.info.encoding], informat.info.channels, 
 	   (informat.info.channels > 1) ? "channels" : "channel");
     if (informat.comment)
-	report("Input file: comment \"%s\"\n", informat.comment);
+	st_report("Input file: comment \"%s\"\n", informat.comment);
 	
     /* need to check EFF_REPORT */
     if (writing) {
@@ -438,7 +438,7 @@
 	    /* to be Full Buffering. */
 	    if (setvbuf (ft->fp,NULL,_IOFBF,sizeof(char)*BUFSIZ))
 	    {
-	        fail("Can't set write buffer");
+	        st_fail("Can't set write buffer");
 	    }
 	 }
          else {
@@ -446,7 +446,7 @@
 	     ft->fp = fopen(ofile, WRITEBINARY);
 
 	     if (ft->fp == NULL)
-	         fail("Can't open output file '%s': %s", 
+	         st_fail("Can't open output file '%s': %s", 
 		      ofile, strerror(errno));
 
 	     /* stdout tends to be line-buffered.  Override this */
@@ -453,7 +453,7 @@
 	     /* to be Full Buffering. */
 	     if (setvbuf (ft->fp,NULL,_IOFBF,sizeof(char)*BUFSIZ))
 	     {
-	         fail("Can't set write buffer");
+	         st_fail("Can't set write buffer");
 	     }
 
         } /* end of else != stdout */
@@ -466,16 +466,16 @@
 	st_copyformat(&informat, &outformat);
 	if ((* outformat.h->startwrite)(&outformat) == ST_EOF)
 	{
-	    fail(outformat.st_errstr);
+	    st_fail(outformat.st_errstr);
 	}
 	st_checkformat(&outformat);
 	st_cmpformats(&informat, &outformat);
-	report("Output file: using sample rate %lu\n\tsize %s, encoding %s, %d %s",
+	st_report("Output file: using sample rate %lu\n\tsize %s, encoding %s, %d %s",
 	       outformat.info.rate, st_sizes_str[outformat.info.size], 
 	       st_encodings_str[outformat.info.encoding], outformat.info.channels, 
 	       (outformat.info.channels > 1) ? "channels" : "channel");
 	if (outformat.comment)
-	    report("Output file: comment \"%s\"\n", outformat.comment);
+	    st_report("Output file: comment \"%s\"\n", outformat.comment);
     }
 
     /* Very Important: 
@@ -552,7 +552,7 @@
 	    }
 
 	    if (outformat.st_errno)
-		fail(outformat.st_errstr);
+		st_fail(outformat.st_errstr);
 
 	    /* if stuff still in pipeline, set up to flow effects again */
 	    havedata = 0;
@@ -566,7 +566,7 @@
     }
 
     if (informat.st_errno)
-	fail(informat.st_errstr);
+	st_fail(informat.st_errstr);
 
     /* Drain the effects out first to last, 
      * pushing residue through subsequent effects */
@@ -600,13 +600,13 @@
     }
 
     if ((* informat.h->stopread)(&informat) == ST_EOF)
-	fail(informat.st_errstr);
+	st_fail(informat.st_errstr);
     fclose(informat.fp);
 
     if (writing)
     {
         if ((* outformat.h->stopwrite)(&outformat) == ST_EOF)
-	    fail(outformat.st_errstr);
+	    st_fail(outformat.st_errstr);
     }
     if (writing)
         fclose(outformat.fp);
@@ -672,7 +672,7 @@
 	done = idonel + idoner + odonel + odoner;
     } 
     if (done == 0) 
-	fail("Effect took & gave no samples!");
+	st_fail("Effect took & gave no samples!");
     return 1;
 }
 
@@ -910,7 +910,7 @@
 /* Guido Van Rossum fix */
 static void statistics(P0) {
 	if (informat.info.dovol && clipped > 0)
-		report("Volume change clipped %d samples", clipped);
+		st_report("Volume change clipped %d samples", clipped);
 }
 
 static LONG volumechange(buf, ct, vol)
--- a/src/speed.c
+++ b/src/speed.c
@@ -121,7 +121,7 @@
     if (n && (!sscanf(argv[0], SPEED_FLOAT_SCAN, &speed->factor) ||
 	      speed->factor<=ZERO))
     {
-	fail(SPEED_USAGE);
+	st_fail(SPEED_USAGE);
 	return ST_EOF;
     }
 
@@ -155,7 +155,7 @@
     speed->frac = ZERO;
 
     if (!speed->ibuf) {
-	fail("malloc failed");
+	st_fail("malloc failed");
 	return ST_EOF;
     }
 
@@ -287,7 +287,7 @@
     speed_t speed = (speed_t) effp->priv;
 
     if (speed->clipped) 
-	warn("SPEED: %d values clipped...", speed->clipped);
+	st_warn("SPEED: %d values clipped...", speed->clipped);
 
     free(speed->ibuf);
     
--- a/src/st.h
+++ b/src/st.h
@@ -330,10 +330,10 @@
 double 	       st_swapd(P1(double d));			/* Swap double */
 
 /* util.c */
-void report(P2(const char *, ...));
-void warn(P2(const char *, ...));
-void fail(P2(const char *, ...))NORET;
-void st_fail(P4(ft_t, int, const char *, ...));
+void st_report(P2(const char *, ...));
+void st_warn(P2(const char *, ...));
+void st_fail(P2(const char *, ...))NORET;
+void st_fail_errno(P4(ft_t, int, const char *, ...));
 
 void st_geteffect(P1(eff_t));
 void st_gettype(P1(ft_t));
--- a/src/stat.c
+++ b/src/stat.c
@@ -58,7 +58,7 @@
 
 			if (n <= 1) 
 			{
-			  fail("-s option: invalid argument");
+			  st_fail("-s option: invalid argument");
 			  return (ST_EOF);
 			}
 			if (!strcmp(argv[1],"rms")) {
@@ -67,7 +67,7 @@
 			}
 			if (!sscanf(argv[1], "%lf", &scale))
 			{
-			  fail("-s option: invalid argument");
+			  st_fail("-s option: invalid argument");
 			  return (ST_EOF);
 			}
 			stat->scale = scale;
@@ -77,7 +77,7 @@
 			double scale;
 			if (n <= 1 || !sscanf(argv[1], "%lf", &scale))
 			{
-			  fail("-s option expects float argument");
+			  st_fail("-s option expects float argument");
 			  return(ST_EOF);
 			}
 			stat->srms = 1;
@@ -89,7 +89,7 @@
 		}
 		else
 		{
-			fail("Summary effect: unknown option");
+			st_fail("Summary effect: unknown option");
 			return(ST_EOF);
 		}
 	  did2: --n; ++argv;
--- a/src/stretch.c
+++ b/src/stretch.c
@@ -140,13 +140,13 @@
 
     if (n>0 && !sscanf(argv[0], STRETCH_FLOAT_SCAN, &stretch->factor))
     {
-	fail(STRETCH_USAGE "\n\terror while parsing factor");
+	st_fail(STRETCH_USAGE "\n\terror while parsing factor");
 	return ST_EOF;
     }
 
     if (n>1 && !sscanf(argv[1], STRETCH_FLOAT_SCAN, &stretch->window))
     {
-	fail(STRETCH_USAGE "\n\terror while parsing window size");
+	st_fail(STRETCH_USAGE "\n\terror while parsing window size");
 	return ST_EOF;
     }
 
@@ -159,7 +159,7 @@
 	    stretch->fade = st_linear_fading;
 	    break;
 	default:
-	    fail(STRETCH_USAGE "\n\terror while parsing fade type");
+	    st_fail(STRETCH_USAGE "\n\terror while parsing fade type");
 	    return ST_EOF;
 	}
     }
@@ -170,13 +170,13 @@
  
     if (n>3 && !sscanf(argv[3], STRETCH_FLOAT_SCAN, &stretch->shift))
     {
-	fail(STRETCH_USAGE "\n\terror while parsing shift ratio");
+	st_fail(STRETCH_USAGE "\n\terror while parsing shift ratio");
 	return ST_EOF;
     }
 
     if (stretch->shift > ONE || stretch->shift <= ZERO)
     {
-	fail(STRETCH_USAGE "\n\terror with shift ratio value");
+	st_fail(STRETCH_USAGE "\n\terror with shift ratio value");
 	return ST_EOF;
     }
 
@@ -191,13 +191,13 @@
 
     if (n>4 && !sscanf(argv[4], STRETCH_FLOAT_SCAN, &stretch->fading))
     {
-	fail(STRETCH_USAGE "\n\terror while parsing fading ratio");
+	st_fail(STRETCH_USAGE "\n\terror while parsing fading ratio");
 	return ST_EOF;
     }
 
     if (stretch->fading > HALF || stretch->fading < ZERO)
     {
-	fail(STRETCH_USAGE "\n\terror with fading ratio value");
+	st_fail(STRETCH_USAGE "\n\terror with fading ratio value");
 	return ST_EOF;
     }
 
@@ -216,7 +216,7 @@
     /* not necessary. taken care by effect processing? */
     if (effp->outinfo.channels != effp->ininfo.channels)
     {
-	fail("STRETCH cannot handle different channels (in=%d, out=%d)"
+	st_fail("STRETCH cannot handle different channels (in=%d, out=%d)"
 	     " use avg or pan", effp->ininfo.channels, effp->outinfo.channels);
 	return ST_EOF;
     }
@@ -223,7 +223,7 @@
 
     if (effp->outinfo.rate != effp->ininfo.rate)
     {
-	fail("STRETCH cannot handle different rates (in=%ld, out=%ld)"
+	st_fail("STRETCH cannot handle different rates (in=%ld, out=%ld)"
 	     " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
 	return ST_EOF;
     }
@@ -261,7 +261,7 @@
 	
     if (!stretch->ibuf || !stretch->obuf || !stretch->fbuf) 
     {
-	fail("some malloc failed");
+	st_fail("some malloc failed");
 	return ST_EOF;
     }
 
@@ -434,7 +434,7 @@
     free(stretch->fbuf);
 
     if (stretch->clipped)
-	warn("STRETCH clipped %d values...", stretch->clipped);
+	st_warn("STRETCH clipped %d values...", stretch->clipped);
 
     return ST_SUCCESS;
 }
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -52,7 +52,7 @@
     ft->file.eof = 0;
     ft->file.size = 1024;
     if ((ft->file.buf = malloc (ft->file.size)) == NULL) {
-	fail("unable to allocate input buffer of size %d", ft->file.size);
+	st_fail("unable to allocate input buffer of size %d", ft->file.size);
 	return ST_EOF;
     }
 
@@ -63,10 +63,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) {
-	fail("Unable to get device information.");
+	st_fail("Unable to get device information.");
 	return(ST_EOF);
     }
-    report("Hardware detected:  %s\n",audio_dev.name);
+    st_report("Hardware detected:  %s\n",audio_dev.name);
     if (strcmp("SUNW,am79c30",audio_dev.name) == 0)
     {
 	simple_hw = 1;
@@ -81,13 +81,13 @@
 	    if (ft->info.encoding != ST_ENCODING_ULAW && 
 		ft->info.encoding != ST_ENCODING_ALAW)
 	    {
-		report("Warning: Detected simple hardware.  Forcing output to ULAW");
+		st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
 		ft->info.encoding = ST_ENCODING_ULAW;
 	    }
 	}
 	else if (ft->info.size == ST_SIZE_WORD)
 	{
-	    report("Warning: Detected simple hardware.  Forcing output to ULAW");
+	    st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
 	    ft->info.size = ST_SIZE_BYTE;
 	    ft->info.encoding = ST_ENCODING_ULAW;
 	}
@@ -98,12 +98,12 @@
 	if (ft->info.encoding != ST_ENCODING_ULAW &&
 	    ft->info.encoding != ST_ENCODING_ALAW &&
 	    ft->info.encoding != ST_ENCODING_SIGN2) {
-	    fail("Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
+	    st_fail("Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
 	}
 	if ((ft->info.encoding == ST_ENCODING_ULAW || 
 	     ft->info.encoding == ST_ENCODING_ALAW) && ft->info.channels == 2)
 	{
-	    report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono");
+	    st_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono");
 	    ft->info.channels = 2;
 	}
     }
@@ -110,28 +110,28 @@
     else if (ft->info.size == ST_SIZE_WORD) {
 	samplesize = 16;
 	if (ft->info.encoding != ST_ENCODING_SIGN2) {
-	    fail("Sun Audio driver only supports Signed Linear for words.");
+	    st_fail("Sun Audio driver only supports Signed Linear for words.");
 	    return(ST_EOF);
 	}
     }
     else {
-	fail("Sun Audio driver only supports bytes and words");
+	st_fail("Sun Audio driver only supports bytes and words");
 	return(ST_EOF);
     }
 
     if (ft->info.channels == -1) ft->info.channels = 1;
     else if (ft->info.channels > 1) {
-	report("Warning: some sun audio devices can not play stereo");
-	report("at all or sometime only with signed words.  If the");
-	report("sound seems sluggish then this is probably the case.");
-	report("Try forcing output to signed words or use the avg");
-	report("filter to reduce the number of channels.");
+	st_report("Warning: some sun audio devices can not play stereo");
+	st_report("at all or sometime 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.");
 	ft->info.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) {
-	fail("Unable to initialize /dev/audio");
+	st_fail("Unable to initialize /dev/audio");
 	return(ST_EOF);
     }
     audio_if.record.precision = samplesize;
@@ -147,19 +147,19 @@
     
     ioctl(fileno(ft->fp), AUDIO_SETINFO, &audio_if);
     if (audio_if.record.precision != samplesize) {
-        fail("Unable to initialize sample size for /dev/audio");
+        st_fail("Unable to initialize sample size for /dev/audio");
 	return(ST_EOF);
     }
     if (audio_if.record.channels != ft->info.channels) {
-	fail("Unable to initialize number of channels for /dev/audio");
+	st_fail("Unable to initialize number of channels for /dev/audio");
 	return(ST_EOF);
     }
     if (audio_if.record.sample_rate != ft->info.rate) {
-	fail("Unable to initialize rate for /dev/audio");
+	st_fail("Unable to initialize rate for /dev/audio");
 	return(ST_EOF);
     }
     if (audio_if.record.encoding != encoding) {
-	fail("Unable to initialize encoding for /dev/audio");
+	st_fail("Unable to initialize encoding for /dev/audio");
 	return(ST_EOF);
     }
     /* Change to non-buffered I/O*/
@@ -185,7 +185,7 @@
     ft->file.eof = 0;
     ft->file.size = 1024;
     if ((ft->file.buf = malloc (ft->file.size)) == NULL) {
-	fail("unable to allocate output buffer of size %d", ft->file.size);
+	st_fail("unable to allocate output buffer of size %d", ft->file.size);
 	return(ST_EOF);
     }
 
@@ -192,10 +192,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) {
-	fail("Unable to get device information.");
+	st_fail("Unable to get device information.");
 	return(ST_EOF);
     }
-    report("Hardware detected:  %s\n",audio_dev.name);
+    st_report("Hardware detected:  %s\n",audio_dev.name);
     if (strcmp("SUNW,am79c30",audio_dev.name) == 0)
     {
 	simple_hw = 1;
@@ -209,13 +209,13 @@
 	    if (ft->info.encoding != ST_ENCODING_ULAW && 
 		ft->info.encoding != ST_ENCODING_ALAW)
 	    {
-		report("Warning: Detected simple hardware.  Forcing output to ULAW");
+		st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
 		ft->info.encoding = ST_ENCODING_ULAW;
 	    }
 	}
 	else if (ft->info.size == ST_SIZE_WORD)
 	{
-	    report("Warning: Detected simple hardware.  Forcing output to ULAW");
+	    st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
 	    ft->info.size = ST_SIZE_BYTE;
 	    ft->info.encoding = ST_ENCODING_ULAW;
 	}
@@ -230,14 +230,14 @@
 	if (ft->info.encoding != ST_ENCODING_ULAW &&
 	    ft->info.encoding != ST_ENCODING_ALAW &&
 	    ft->info.encoding != ST_ENCODING_SIGN2) {
-	    report("Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
-	    report("Forcing to ULAW");
+	    st_report("Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
+	    st_report("Forcing to ULAW");
 	    ft->info.encoding = ST_ENCODING_ULAW;
 	}
 	if ((ft->info.encoding == ST_ENCODING_ULAW || 
 	     ft->info.encoding == ST_ENCODING_ALAW) && ft->info.channels == 2)
 	{
-	    report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono");
+	    st_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono");
 	    ft->info.channels = 2;
 	}
 
@@ -245,13 +245,13 @@
     else if (ft->info.size == ST_SIZE_WORD) {
 	samplesize = 16;
 	if (ft->info.encoding != ST_ENCODING_SIGN2) {
-	    report("Sun Audio driver only supports Signed Linear for words.");
-	    report("Forcing to Signed Linear");
+	    st_report("Sun Audio driver only supports Signed Linear for words.");
+	    st_report("Forcing to Signed Linear");
 	    ft->info.encoding = ST_ENCODING_SIGN2;
 	}
     }
     else {
-	report("Sun Audio driver only supports bytes and words");
+	st_report("Sun Audio driver only supports bytes and words");
 	ft->info.size = ST_SIZE_WORD;
 	samplesize = 16;
     }
@@ -261,7 +261,7 @@
 
     /* Read in old values, change to what we need and then send back */
     if (ioctl(fileno(ft->fp), AUDIO_GETINFO, &audio_if) < 0) {
-	fail("Unable to initialize /dev/audio");
+	st_fail("Unable to initialize /dev/audio");
 	return(ST_EOF);
     }
     audio_if.play.precision = samplesize;
@@ -277,19 +277,19 @@
     
     ioctl(fileno(ft->fp), AUDIO_SETINFO, &audio_if);
     if (audio_if.play.precision != samplesize) {
-	fail("Unable to initialize sample size for /dev/audio");
+	st_fail("Unable to initialize sample size for /dev/audio");
 	return(ST_EOF);
     }
     if (audio_if.play.channels != ft->info.channels) {
-	fail("Unable to initialize number of channels for /dev/audio");
+	st_fail("Unable to initialize number of channels for /dev/audio");
 	return(ST_EOF);
     }
     if (audio_if.play.sample_rate != ft->info.rate) {
-	fail("Unable to initialize rate for /dev/audio");
+	st_fail("Unable to initialize rate for /dev/audio");
 	return(ST_EOF);
     }
     if (audio_if.play.encoding != encoding) {
-	fail("Unable to initialize encoding for /dev/audio");
+	st_fail("Unable to initialize encoding for /dev/audio");
 	return(ST_EOF);
     }
     /* Change to non-buffered I/O */
--- a/src/swap.c
+++ b/src/swap.c
@@ -34,11 +34,16 @@
     swap->order[0] = swap->order[1] = swap->order[2] = swap->order[3] = 0;
     if (n)
     {
-	if (n != 4)
+	if (n != 2 && n != 4)
 	{
-	    fail("Usage: swap [1 2 3 4]");
+	    st_fail("Usage: swap [1 2 | 1 2 3 4]");
 	    return (ST_EOF);
 	}
+	else if (n == 2)
+	{
+	    sscanf(argv[0],"%d",&swap->order[0]);
+	    sscanf(argv[1],"%d",&swap->order[1]);
+	}
 	else
 	{
 	    sscanf(argv[0],"%d",&swap->order[0]);
@@ -46,6 +51,27 @@
 	    sscanf(argv[2],"%d",&swap->order[2]);
 	    sscanf(argv[3],"%d",&swap->order[3]);
 	}
+
+	/* Some basic error checking */
+	if (swap->order[0] < 1 || swap->order[0] > 4)
+	    swap->order[0] = 1;
+	if (swap->order[1] < 1 || swap->order[1] > 4)
+	    swap->order[1] = 1;
+
+	/* If 2 and 3 weren't specified, this logic still forces
+	 * it to equal 0 (our default)
+	 */
+	if (swap->order[2] < 1 || swap->order[2] > 4)
+	    swap->order[2] = 1;
+	if (swap->order[3] < 1 || swap->order[3] > 4)
+	    swap->order[3] = 1;
+
+	/* Convert to array offsets */
+	swap->order[0]--;
+	swap->order[1]--;
+        swap->order[2]--;
+	swap->order[3]--;
+
     }
     return (ST_SUCCESS);
 }
@@ -57,11 +83,42 @@
 int st_swap_start(effp)
 eff_t effp;
 {
+    swap_t swap = (swap_t) effp->priv;
+
     if (effp->outinfo.channels == 1)
     {
-	fail("Can't swap channels on mono data.");
+	st_fail("Can't swap channels on mono data.");
 	return (ST_EOF);
     }
+
+    if (effp->outinfo.channels == 2)
+    {
+	if (swap->order[2] || swap->order[3])
+        {
+	    st_fail("invalid swap channel options used");
+        }
+	if (swap->order[0] != 0 && swap->order[0] != 1)
+	    st_fail("invalid swap channel options used");
+	if (swap->order[1] != 0 && swap->order[1] != 1)
+	    st_fail("invalid swap channel options used");
+    }
+
+    if (effp->outinfo.channels == 4)
+    {
+	if (!swap->order[2] && !swap->order[3])
+	    st_fail("invalid swap channel options used");
+    }
+
+    /* If nothing set then default to the following order */
+    if (!swap->order[0] && !swap->order[1] &&
+        !swap->order[2] && !swap->order[3])
+    {
+        swap->order[0] = 1;
+        swap->order[1] = 0;
+        swap->order[2] = 3;
+        swap->order[3] = 2;
+    }
+
     return (ST_SUCCESS);
 }
 
@@ -87,8 +144,8 @@
 	len = ((*isamp > *osamp) ? *osamp : *isamp) / 2;
 	for(done = 0; done < len; done++)
 	{
-	    obuf[0] = ibuf[1];
-	    obuf[1] = ibuf[0];
+	    obuf[0] = ibuf[swap->order[0]];
+	    obuf[1] = ibuf[swap->order[1]];
 	    /* Advance buffer by 2 samples */
 	    ibuf += 2;
 	    obuf += 2;
@@ -100,15 +157,6 @@
 	break;
 	
     case 4:
-	/* If nothing set then default to the following order */
-	if (!swap->order[0] && !swap->order[1] &&
-	    !swap->order[2] && !swap->order[3])
-	{
-	    swap->order[0] = 1;
-	    swap->order[1] = 0;
-	    swap->order[2] = 3;
-	    swap->order[3] = 2;
-	}
 	/* Length to process will be buffer length / 4 since we
 	 * work with four samples at a time.
 	 */
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -90,7 +90,7 @@
   /* If you need to seek around the input file. */
   if (! ft->seekable)
   {
-    fail("txw input file must be a file, not a pipe");
+    st_fail("txw input file must be a file, not a pipe");
     return(ST_EOF);
   }
 
@@ -124,10 +124,10 @@
    */
 
   /* Check to make sure we got a good filetype ID from file */
-  report("Found header filetype %s",filetype);
+  st_report("Found header filetype %s",filetype);
   if(strcmp(filetype,"LM8953"))
   {
-    fail("Invalid filetype ID in input file header, != LM8953");
+    st_fail("Invalid filetype ID in input file header, != LM8953");
     return(ST_EOF);
   }
   /*
@@ -167,11 +167,11 @@
       break;
     }
     if ( blewIt ) {
-      report("Invalid sample rate identifier found %d", (int)sample_rate);
+      st_report("Invalid sample rate identifier found %d", (int)sample_rate);
       ft->info.rate = 33000;
     }
   }
-  report("Sample rate = %ld",ft->info.rate);
+  st_report("Sample rate = %ld",ft->info.rate);
 
   ft->info.channels = 1 ; /* not sure about stereo sample data yet ??? */
   ft->info.size = ST_SIZE_WORD; /* this is close enough */
@@ -254,13 +254,13 @@
 {
   struct WaveHeader_ WH;
 
-  report("tx16w selected output");
+  st_report("tx16w selected output");
 
   if (ft->info.channels != 1)
-      report("tx16w is overriding output format to 1 channel.");
+      st_report("tx16w is overriding output format to 1 channel.");
   ft->info.channels = 1 ; /* not sure about stereo sample data yet ??? */
   if (ft->info.size != ST_SIZE_WORD || ft->info.encoding != ST_ENCODING_SIGN2)
-      report("tx16w is overriding output format to size Signed Word format.");
+      st_report("tx16w is overriding output format to size Signed Word format.");
   ft->info.size = ST_SIZE_WORD; /* this is close enough */
   ft->info.encoding = ST_ENCODING_SIGN2;
   
@@ -267,7 +267,7 @@
   /* If you have to seek around the output file */
   if (! ft->seekable)
   {
-      fail("Output .txw file must be a file, not a pipe");
+      st_fail("Output .txw file must be a file, not a pipe");
       return(ST_EOF);
   }
 
@@ -314,7 +314,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. */
     
-    report("tx16w:output finished");
+    st_report("tx16w:output finished");
     
     strncpy(WH.filetype,"LM8953",6);
     for (i=0;i<10;i++) WH.nulls[i]=0;
--- a/src/util.c
+++ b/src/util.c
@@ -38,7 +38,7 @@
 char *myname = 0;
 
 void
-report(const char *fmt, ...) 
+st_report(const char *fmt, ...) 
 {
 	va_list args;
 
@@ -54,7 +54,7 @@
 
 
 void
-warn(const char *fmt, ...) 
+st_warn(const char *fmt, ...) 
 {
 	va_list args;
 
@@ -67,7 +67,7 @@
 }
 
 void
-fail(const char *fmt, ...) 
+st_fail(const char *fmt, ...) 
 {
 	va_list args;
 	extern void cleanup();
@@ -87,7 +87,7 @@
  * go over the array limit ourself!
  */
 void
-st_fail(ft_t ft, int errno, const char *fmt, ...)
+st_fail_errno(ft_t ft, int errno, const char *fmt, ...)
 {
 	va_list args;
 
@@ -117,7 +117,7 @@
 	int i;
 
 	if (! formp->filetype)
-fail("Must give file type for %s file, either as suffix or with -t option",
+st_fail("Must give file type for %s file, either as suffix or with -t option",
 formp->filename);
 	for(i = 0; st_formats[i].names; i++) {
 		for(list = st_formats[i].names; *list; list++) {
@@ -133,16 +133,16 @@
 	}
 	if (! strcmpcase(formp->filetype, "snd")) {
 		verbose = 1;
-		report("File type '%s' is used to name several different formats.", formp->filetype);
-		report("If the file came from a Macintosh, it is probably");
-		report("a .ub file with a sample rate of 11025 (or possibly 5012 or 22050).");
-		report("Use the sequence '-t .ub -r 11025 file.snd'");
-		report("If it came from a PC, it's probably a Soundtool file.");
-		report("Use the sequence '-t .sndt file.snd'");
-		report("If it came from a NeXT, it's probably a .au file.");
-		fail("Use the sequence '-t .au file.snd'\n");
+		st_report("File type '%s' is used to name several different formats.", formp->filetype);
+		st_report("If the file came from a Macintosh, it is probably");
+		st_report("a .ub file with a sample rate of 11025 (or possibly 5012 or 22050).");
+		st_report("Use the sequence '-t .ub -r 11025 file.snd'");
+		st_report("If it came from a PC, it's probably a Soundtool file.");
+		st_report("Use the sequence '-t .sndt file.snd'");
+		st_report("If it came from a NeXT, it's probably a .au file.");
+		st_fail("Use the sequence '-t .au file.snd'\n");
 	}
-	fail("File type '%s' of %s file is not known!",
+	st_fail("File type '%s' of %s file is not known!",
 		formp->filetype, formp->filename);
 }
 
@@ -170,7 +170,7 @@
 	for (i = 1; st_effects[i].name; i++)
 		fprintf(stderr, "%s ", st_effects[i].name);
 	fprintf(stderr, "\n");
-	fail("Effect '%s' is not known!", effp->name);
+	st_fail("Effect '%s' is not known!", effp->name);
 }
 
 /*
@@ -228,18 +228,18 @@
 ft_t ft;
 {
 	if (ft->info.rate == 0)
-		fail("Sampling rate for %s file was not given\n", ft->filename);
+		st_fail("Sampling rate for %s file was not given\n", ft->filename);
 	if ((ft->info.rate < 100) || (ft->info.rate > 999999L))
-		fail("Sampling rate %lu for %s file is bogus\n", 
+		st_fail("Sampling rate %lu for %s file is bogus\n", 
 			ft->info.rate, ft->filename);
 	if (ft->info.size == -1)
-		fail("Data size was not given for %s file\nUse one of -b/-w/-l/-f/-d/-D", ft->filename);
+		st_fail("Data size was not given for %s file\nUse one of -b/-w/-l/-f/-d/-D", ft->filename);
 	if (ft->info.encoding == -1 && ft->info.size != ST_SIZE_FLOAT)
-		fail("Data encoding was not given for %s file\nUse one of -s/-u/-U/-A", ft->filename);
+		st_fail("Data encoding was not given for %s file\nUse one of -s/-u/-U/-A", ft->filename);
 	/* it's so common, might as well default */
 	if (ft->info.channels == -1)
 		ft->info.channels = 1;
-	/*	fail("Number of output channels was not given for %s file",
+	/*	st_fail("Number of output channels was not given for %s file",
 			ft->filename); */
 }
 
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -52,13 +52,13 @@
 	if ((n == 0) || !sscanf(argv[0], "%f", &vibro->speed) ||
 		((n == 2) && !sscanf(argv[1], "%f", &vibro->depth)))
 	{
-		fail("Usage: vibro speed [ depth ]");
+		st_fail("Usage: vibro speed [ depth ]");
 		return (ST_EOF);
 	}
 	if ((vibro->speed <= 0.001) || (vibro->speed > 30.0) || 
 			(vibro->depth < 0.0) || (vibro->depth > 1.0))
 	{
-		fail("Vibro: speed must be < 30.0, 0.0 < depth < 1.0");
+		st_fail("Vibro: speed must be < 30.0, 0.0 < depth < 1.0");
 		return (ST_EOF);
 	}
 	return (ST_SUCCESS);
@@ -94,7 +94,7 @@
 	vibro->length = effp->ininfo.rate / vibro->speed;
 	if (! (vibro->sinetab = (short*) malloc(vibro->length * sizeof(short))))
 	{
-		fail("Vibro: Cannot malloc %d bytes",
+		st_fail("Vibro: Cannot malloc %d bytes",
 			vibro->length * sizeof(short));
 		return (ST_EOF);
 	}
--- a/src/voc.c
+++ b/src/voc.c
@@ -191,17 +191,17 @@
 
 	if (! ft->seekable)
 	{
-		fail("VOC input file must be a file, not a pipe");
+		st_fail("VOC input file must be a file, not a pipe");
 		return(ST_EOF);
 	}
 	if (fread(header, 1, 20, ft->fp) != 20)
 	{
-		fail("unexpected EOF in VOC header");
+		st_fail("unexpected EOF in VOC header");
 		return(ST_EOF);
 	}
 	if (strncmp(header, "Creative Voice File\032", 19))
 	{
-		fail("VOC file header incorrect");
+		st_fail("VOC file header incorrect");
 		return(ST_EOF);
 	}
 
@@ -216,7 +216,7 @@
 	    return rc;
 	if (v->rate == -1)
 	{
-		fail("Input .voc file had no sound!");
+		st_fail("Input .voc file had no sound!");
 		return(ST_EOF);
 	}
 
@@ -260,7 +260,7 @@
 			{
 			    case ST_SIZE_BYTE:
 				if (st_readb(ft, &uc) == ST_EOF) {
-				    warn("VOC input: short file");
+				    st_warn("VOC input: short file");
 				    v->rest = 0;
 				    return done;
 				}
@@ -271,7 +271,7 @@
 				st_readw(ft, &us);
 				if (feof(ft->fp))
 				{
-				    warn("VOC input: short file");
+				    st_warn("VOC input: short file");
 				    v->rest = 0;
 				    return done;
 				}
@@ -319,7 +319,7 @@
 
 	if (! ft->seekable)
 	{
-		fail("Output .voc file must be a file, not a pipe");
+		st_fail("Output .voc file must be a file, not a pipe");
 		return(ST_EOF);
 	}
 
@@ -420,12 +420,12 @@
 		        if (!v->extended) {
 			  if (uc == 0)
 			  {
-			    fail("File %s: Sample rate is zero?");
+			    st_fail("File %s: Sample rate is zero?");
 			    return(ST_EOF);
 			  }
 			  if ((v->rate != -1) && (uc != v->rate))
 			  {
-			    fail("File %s: sample rate codes differ: %d != %d",
+			    st_fail("File %s: sample rate codes differ: %d != %d",
 				 ft->filename,v->rate, uc);
 			    return(ST_EOF);
 			  }
@@ -436,7 +436,7 @@
 			st_readb(ft, &uc);
 			if (uc != 0)
 			{
-			  fail("File %s: only interpret 8-bit data!",
+			  st_fail("File %s: only interpret 8-bit data!",
 			       ft->filename);
 			  return(ST_EOF);
 			}
@@ -448,12 +448,12 @@
 			st_readdw(ft, &new_rate_long);
 			if (new_rate_long == 0)
 			{
-			    fail("File %s: Sample rate is zero?",ft->filename);
+			    st_fail("File %s: Sample rate is zero?",ft->filename);
 			    return(ST_EOF);
 			}
 			if ((v->rate != -1) && (new_rate_long != v->rate))
 			{
-			    fail("File %s: sample rate codes differ: %d != %d",
+			    st_fail("File %s: sample rate codes differ: %d != %d",
 				ft->filename, v->rate, new_rate_long);
 			    return(ST_EOF);
 			}
@@ -465,7 +465,7 @@
 			    case 8:	v->size = ST_SIZE_BYTE; break;
 			    case 16:	v->size = ST_SIZE_WORD; break;
 			    default:	
-					fail("Don't understand size %d", uc);
+					st_fail("Don't understand size %d", uc);
 					return(ST_EOF);
 			}
 			st_readb(ft, &(v->channels));
@@ -488,7 +488,7 @@
 			st_readb(ft, &uc);
 			if (uc == 0)
 			{
-				fail("File %s: Silence sample rate is zero");
+				st_fail("File %s: Silence sample rate is zero");
 				return(ST_EOF);
 			}
 			/* 
@@ -518,7 +518,7 @@
 			continue;	/* get next block */
 		case VOC_LOOP:
 		case VOC_LOOPEND:
-			report("File %s: skipping repeat loop");
+			st_report("File %s: skipping repeat loop");
 			for(i = 0; i < sblen; i++)
 			    st_readb(ft, (unsigned char *)&trash);
 			break;
@@ -531,12 +531,12 @@
 			st_readw(ft, &new_rate_short);
 			if (new_rate_short == 0)
 			{
-			   fail("File %s: Sample rate is zero?");
+			   st_fail("File %s: Sample rate is zero?");
 			   return(ST_EOF);
 			}
 			if ((v->rate != -1) && (new_rate_short != v->rate))
 			{
-			   fail("File %s: sample rate codes differ: %d != %d",
+			   st_fail("File %s: sample rate codes differ: %d != %d",
 					ft->filename, v->rate, new_rate_short);
 			   return(ST_EOF);
 			}
@@ -544,7 +544,7 @@
 			st_readb(ft, &uc);
 			if (uc != 0)
 			{
-				fail("File %s: only interpret 8-bit data!",
+				st_fail("File %s: only interpret 8-bit data!",
 					ft->filename);
 				return(ST_EOF);
 			}
@@ -559,7 +559,7 @@
 			/* can be grabed.				*/
 			continue;
 		default:
-			report("File %s: skipping unknown block code %d",
+			st_report("File %s: skipping unknown block code %d",
 				ft->filename, block);
 			for(i = 0; i < sblen; i++)
 			    st_readb(ft, (unsigned char *)&trash);
--- a/src/vol.c
+++ b/src/vol.c
@@ -51,7 +51,7 @@
     
     if (n && (!sscanf(argv[0], VOL_FLOAT_SCAN, &vol->gain)))
     {
-	fail(VOL_USAGE);
+	st_fail(VOL_USAGE);
 	return ST_EOF;
     }
 
@@ -91,13 +91,13 @@
     
     if (effp->outinfo.channels != effp->ininfo.channels)
     {
-	warn("VOL cannot handle different channels (in=%d, out=%d)"
+	st_warn("VOL cannot handle different channels (in=%d, out=%d)"
 	     " use avg or pan", effp->ininfo.channels, effp->outinfo.channels);
     }
 
     if (effp->outinfo.rate != effp->ininfo.rate)
     {
-	fail("VOL cannot handle different rates (in=%ld, out=%ld)"
+	st_fail("VOL cannot handle different rates (in=%ld, out=%ld)"
 	     " use resample or rate", effp->ininfo.rate, effp->outinfo.rate);
 	return ST_EOF;
     }
@@ -165,7 +165,7 @@
     vol_t vol = (vol_t) effp->priv;
     if (vol->clipped) 
     {
-	warn("VOL clipped %d values, amplitude gain=%f too high...", 
+	st_warn("VOL clipped %d values, amplitude gain=%f too high...", 
 	     vol->clipped, vol->gain);
     }
     return ST_SUCCESS;
--- a/src/wav.c
+++ b/src/wav.c
@@ -144,7 +144,7 @@
 	samplesThisBlock = ImaSamplesIn(0, ft->info.channels, bytesRead, 0);
 	if (samplesThisBlock == 0) 
 	{
-	    warn ("Premature EOF on .wav input file");
+	    st_warn("Premature EOF on .wav input file");
 	    return 0;
 	}
     }
@@ -186,7 +186,7 @@
 	samplesThisBlock = AdpcmSamplesIn(0, ft->info.channels, bytesRead, 0);
 	if (samplesThisBlock == 0) 
 	{
-	    warn ("Premature EOF on .wav input file");
+	    st_warn("Premature EOF on .wav input file");
 	    return 0;
 	}
     }
@@ -194,7 +194,7 @@
     errmsg = AdpcmBlockExpandI(ft->info.channels, wav->nCoefs, wav->iCoefs, wav->packet, wav->samples, samplesThisBlock);
 
     if (errmsg)
-	warn((char*)errmsg);
+	st_warn((char*)errmsg);
 
     return samplesThisBlock;
 }
@@ -225,7 +225,7 @@
 	/* write the compressed packet */
 	if (fwrite(wav->packet, wav->blockAlign, 1, ft->fp) != 1)
 	{
-	    fail("write error");
+	    st_fail("write error");
 	    return (ST_EOF);
 	}
 	/* update lengths and samplePtr */
@@ -254,18 +254,18 @@
     wav->gsmhandle=gsm_create();
     if (!wav->gsmhandle)
     {
-	fail("cannot create GSM object");
+	st_fail("cannot create GSM object");
 	return (ST_EOF);
     }
 	
     if(gsm_option(wav->gsmhandle,GSM_OPT_WAV49,&valueP) == -1){
-	fail("error setting gsm_option for WAV49 format. Recompile gsm library with -DWAV49 option and relink sox");
+	st_fail("error setting gsm_option for WAV49 format. Recompile gsm library with -DWAV49 option and relink sox");
 	return (ST_EOF);
     }
 
     wav->gsmsample=malloc(sizeof(gsm_signal)*160*2);
     if (wav->gsmsample == NULL){
-	fail("error allocating memory for gsm buffer");
+	st_fail("error allocating memory for gsm buffer");
 	return (ST_EOF);
     }
     wav->gsmindex=0;
@@ -301,19 +301,19 @@
 	if (bytes <=0)
 	    return done;
 	if (bytes<65) {
-	    warn("invalid wav gsm frame size: %d bytes",bytes);
+	    st_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)
 	{
-	    fail("error during gsm decode");
+	    st_fail("error during gsm decode");
 	    return 0;
 	}
 	/* decode the short 32 byte half */
 	if(gsm_decode(wav->gsmhandle,frame+33, wav->gsmsample+160)<0)
 	{
-	    fail("error during gsm decode");
+	    st_fail("error during gsm decode");
 	    return 0;
 	}
 
@@ -342,7 +342,7 @@
     gsm_encode(wav->gsmhandle, wav->gsmsample+160, frame+32);
     if (fwrite(frame, 1, 65, ft->fp) != 65)
     {
-	fail("write error");
+	st_fail("write error");
 	return (ST_EOF);
     }
     wav->gsmbytecount += 65;
@@ -353,7 +353,7 @@
 	/* pad output to an even number of bytes */
 	if(st_writeb(ft, 0))
 	{
-	    fail("write error");
+	    st_fail("write error");
 	    return (ST_EOF);
 	}
 	wav->gsmbytecount += 1;
@@ -417,7 +417,7 @@
     {
 	if (st_reads(ft, magic, 4) == ST_EOF)
 	{
-	    fail("WAVE file has missing %s chunk", Label);
+	    st_fail("WAVE file has missing %s chunk", Label);
 	    return 0;
 	}
 	st_readdw(ft, &len);
@@ -464,7 +464,7 @@
 
     if (st_reads(ft, magic, 4) == ST_EOF || strncmp("RIFF", magic, 4))
     {
-	fail("WAVE: RIFF header not found");
+	st_fail("WAVE: RIFF header not found");
 	return ST_EOF;
     }
 
@@ -472,7 +472,7 @@
 
     if (st_reads(ft, magic, 4) == ST_EOF || strncmp("WAVE", magic, 4))
     {
-	fail("WAVE header not found");
+	st_fail("WAVE header not found");
 	return ST_EOF;
     }
 
@@ -482,7 +482,7 @@
     
     if (wFmtSize < 16)
     {
-	fail("WAVE file fmt chunk is too short");
+	st_fail("WAVE file fmt chunk is too short");
 	return ST_EOF;
     }
 
@@ -497,7 +497,7 @@
     switch (wav->formatTag)
     {
     case WAVE_FORMAT_UNKNOWN:
-	fail("WAVE file is in unsupported Microsoft Official Unknown format.");
+	st_fail("WAVE file is in unsupported Microsoft Official Unknown format.");
 	return ST_EOF;
 	
     case WAVE_FORMAT_PCM:
@@ -504,7 +504,7 @@
 	/* Default (-1) depends on sample size.  Set that later on. */
 	if (ft->info.encoding != -1 && ft->info.encoding != ST_ENCODING_UNSIGNED &&
 	    ft->info.encoding != ST_ENCODING_SIGN2)
-	    warn("User options overriding encoding read in .wav header");
+	    st_warn("User options overriding encoding read in .wav header");
 
 	/* Needed by rawread() functions */
         rc = st_rawstartread(ft);
@@ -517,7 +517,7 @@
 	if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_IMA_ADPCM)
 	    ft->info.encoding = ST_ENCODING_IMA_ADPCM;
 	else
-	    warn("User options overriding encoding read in .wav header");
+	    st_warn("User options overriding encoding read in .wav header");
 	break;
 
     case WAVE_FORMAT_ADPCM:
@@ -524,11 +524,11 @@
 	if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_ADPCM)
 	    ft->info.encoding = ST_ENCODING_ADPCM;
 	else
-	    warn("User options overriding encoding read in .wav header");
+	    st_warn("User options overriding encoding read in .wav header");
 	break;
 
     case WAVE_FORMAT_IEEE_FLOAT:
-	fail("Sorry, this WAV file is in IEEE Float format.");
+	st_fail("Sorry, this WAV file is in IEEE Float format.");
 	return ST_EOF;
 	
     case WAVE_FORMAT_ALAW:
@@ -535,7 +535,7 @@
 	if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_ALAW)
 	    ft->info.encoding = ST_ENCODING_ALAW;
 	else
-	    warn("User options overriding encoding read in .wav header");
+	    st_warn("User options overriding encoding read in .wav header");
 	break;
 	
     case WAVE_FORMAT_MULAW:
@@ -542,20 +542,20 @@
 	if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_ULAW)
 	    ft->info.encoding = ST_ENCODING_ULAW;
 	else
-	    warn("User options overriding encoding read in .wav header");
+	    st_warn("User options overriding encoding read in .wav header");
 	break;
 	
     case WAVE_FORMAT_OKI_ADPCM:
-	fail("Sorry, this WAV file is in OKI ADPCM format.");
+	st_fail("Sorry, this WAV file is in OKI ADPCM format.");
 	return ST_EOF;
     case WAVE_FORMAT_DIGISTD:
-	fail("Sorry, this WAV file is in Digistd format.");
+	st_fail("Sorry, this WAV file is in Digistd format.");
 	return ST_EOF;
     case WAVE_FORMAT_DIGIFIX:
-	fail("Sorry, this WAV file is in Digifix format.");
+	st_fail("Sorry, this WAV file is in Digifix format.");
 	return ST_EOF;
     case WAVE_FORMAT_DOLBY_AC2:
-	fail("Sorry, this WAV file is in Dolby AC2 format.");
+	st_fail("Sorry, this WAV file is in Dolby AC2 format.");
 	return ST_EOF;
     case WAVE_FORMAT_GSM610:
 #ifdef HAVE_LIBGSM
@@ -562,37 +562,37 @@
 	if (ft->info.encoding == -1 || ft->info.encoding == ST_ENCODING_GSM )
 	    ft->info.encoding = ST_ENCODING_GSM;
 	else
-	    warn("User options overriding encoding read in .wav header");
+	    st_warn("User options overriding encoding read in .wav header");
 	break;
 #else
-	fail("Sorry, this WAV file is in GSM6.10 format and no GSM support present, recompile sox with gsm library");
+	st_fail("Sorry, this WAV file is in GSM6.10 format and no GSM support present, recompile sox with gsm library");
 	return ST_EOF;
 #endif
     case WAVE_FORMAT_ROCKWELL_ADPCM:
-	fail("Sorry, this WAV file is in Rockwell ADPCM format.");
+	st_fail("Sorry, this WAV file is in Rockwell ADPCM format.");
 	return ST_EOF;
     case WAVE_FORMAT_ROCKWELL_DIGITALK:
-	fail("Sorry, this WAV file is in Rockwell DIGITALK format.");
+	st_fail("Sorry, this WAV file is in Rockwell DIGITALK format.");
 	return ST_EOF;
     case WAVE_FORMAT_G721_ADPCM:
-	fail("Sorry, this WAV file is in G.721 ADPCM format.");
+	st_fail("Sorry, this WAV file is in G.721 ADPCM format.");
 	return ST_EOF;
     case WAVE_FORMAT_G728_CELP:
-	fail("Sorry, this WAV file is in G.728 CELP format.");
+	st_fail("Sorry, this WAV file is in G.728 CELP format.");
 	return ST_EOF;
     case WAVE_FORMAT_MPEG:
-	fail("Sorry, this WAV file is in MPEG format.");
+	st_fail("Sorry, this WAV file is in MPEG format.");
 	return ST_EOF;
     case WAVE_FORMAT_MPEGLAYER3:
-	fail("Sorry, this WAV file is in MPEG Layer 3 format.");
+	st_fail("Sorry, this WAV file is in MPEG Layer 3 format.");
 	return ST_EOF;
     case WAVE_FORMAT_G726_ADPCM:
-	fail("Sorry, this WAV file is in G.726 ADPCM format.");
+	st_fail("Sorry, this WAV file is in G.726 ADPCM format.");
 	return ST_EOF;
     case WAVE_FORMAT_G722_ADPCM:
-	fail("Sorry, this WAV file is in G.722 ADPCM format.");
+	st_fail("Sorry, this WAV file is in G.722 ADPCM format.");
 	return ST_EOF;
-    default:	fail("WAV file has unknown format type of %x",wav->formatTag);
+    default:	st_fail("WAV file has unknown format type of %x",wav->formatTag);
 		return ST_EOF;
     }
 
@@ -600,12 +600,12 @@
     if (ft->info.channels == -1 || ft->info.channels == wChannels)
 	ft->info.channels = wChannels;
     else
-	warn("User options overriding channels read in .wav header");
+	st_warn("User options overriding channels read in .wav header");
 
     if (ft->info.rate == 0 || ft->info.rate == wSamplesPerSecond)
 	ft->info.rate = wSamplesPerSecond;
     else
-	warn("User options overriding rate read in .wav header");
+	st_warn("User options overriding rate read in .wav header");
     
 
     wav->iCoefs = NULL;
@@ -618,13 +618,13 @@
 	    st_readw(ft, &wExtSize);
 	    len -= 2;
 	} else {
-	    warn("wave header missing FmtExt chunk");
+	    st_warn("wave header missing FmtExt chunk");
 	}
     }
 
     if (wExtSize > len)
     {
-	fail("wave header error: wExtSize inconsistent with wFmtLen");
+	st_fail("wave header error: wExtSize inconsistent with wFmtLen");
 	return ST_EOF;
     }
 
@@ -634,7 +634,7 @@
     case WAVE_FORMAT_ADPCM:
 	if (wExtSize < 4)
 	{
-	    fail("format[%s]: expects wExtSize >= %d",
+	    st_fail("format[%s]: expects wExtSize >= %d",
 			wav_format_str(wav->formatTag), 4);
 	    return ST_EOF;
 	}
@@ -641,7 +641,7 @@
 
 	if (wBitsPerSample != 4)
 	{
-	    fail("Can only handle 4-bit MS ADPCM in wav files");
+	    st_fail("Can only handle 4-bit MS ADPCM in wav files");
 	    return ST_EOF;
 	}
 
@@ -649,7 +649,7 @@
 	bytesPerBlock = AdpcmBytesPerBlock(ft->info.channels, wav->samplesPerBlock);
 	if (bytesPerBlock > wav->blockAlign)
 	{
-	    fail("format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
+	    st_fail("format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
 		wav_format_str(wav->formatTag), wav->samplesPerBlock, wav->blockAlign);
 	    return ST_EOF;
 	}
@@ -656,13 +656,13 @@
 
 	st_readw(ft, &(wav->nCoefs));
 	if (wav->nCoefs < 7 || wav->nCoefs > 0x100) {
-	    fail("ADPCM file nCoefs (%.4hx) makes no sense\n", wav->nCoefs);
+	    st_fail("ADPCM file nCoefs (%.4hx) makes no sense\n", wav->nCoefs);
 	    return ST_EOF;
 	}
 	wav->packet = (unsigned char *)malloc(wav->blockAlign);
 	if (!wav->packet)
 	{
-	    fail("Unable to alloc resources");
+	    st_fail("Unable to alloc resources");
 	    return ST_EOF;
 	}
 
@@ -670,7 +670,7 @@
 
 	if (wExtSize < 4 + 4*wav->nCoefs)
 	{
-	    fail("wave header error: wExtSize(%d) too small for nCoefs(%d)", wExtSize, wav->nCoefs);
+	    st_fail("wave header error: wExtSize(%d) too small for nCoefs(%d)", wExtSize, wav->nCoefs);
 	    return ST_EOF;
 	}
 
@@ -677,7 +677,7 @@
 	wav->samples = (short *)malloc(wChannels*wav->samplesPerBlock*sizeof(short));
 	if (!wav->samples)
 	{
-	    fail("Unable to alloc resources");
+	    st_fail("Unable to alloc resources");
 	    return ST_EOF;
 	}
 
@@ -685,7 +685,7 @@
 	wav->iCoefs = (short *)malloc(wav->nCoefs * 2 * sizeof(short));
 	if (!wav->iCoefs)
 	{
-	    fail("Unable to alloc resources");
+	    st_fail("Unable to alloc resources");
 	    return ST_EOF;
 	}
 	{
@@ -696,7 +696,7 @@
 		if (i<14) errct += (wav->iCoefs[i] != iCoef[i/2][i%2]);
 		/* fprintf(stderr,"iCoefs[%2d] %4d\n",i,wav->iCoefs[i]); */
 	    }
-	    if (errct) warn("base iCoefs differ in %d/14 positions",errct);
+	    if (errct) st_warn("base iCoefs differ in %d/14 positions",errct);
 	}
 
 	bytespersample = ST_SIZE_WORD;  /* AFTER de-compression */
@@ -705,7 +705,7 @@
     case WAVE_FORMAT_IMA_ADPCM:
 	if (wExtSize < 2)
 	{
-	    fail("format[%s]: expects wExtSize >= %d",
+	    st_fail("format[%s]: expects wExtSize >= %d",
 		    wav_format_str(wav->formatTag), 2);
 	    return ST_EOF;
 	}
@@ -712,7 +712,7 @@
 
 	if (wBitsPerSample != 4)
 	{
-	    fail("Can only handle 4-bit IMA ADPCM in wav files");
+	    st_fail("Can only handle 4-bit IMA ADPCM in wav files");
 	    return ST_EOF;
 	}
 
@@ -720,7 +720,7 @@
 	bytesPerBlock = ImaBytesPerBlock(ft->info.channels, wav->samplesPerBlock);
 	if (bytesPerBlock > wav->blockAlign || wav->samplesPerBlock%8 != 1)
 	{
-	    fail("format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
+	    st_fail("format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
 		wav_format_str(wav->formatTag), wav->samplesPerBlock, wav->blockAlign);
 	    return ST_EOF;
 	}
@@ -728,7 +728,7 @@
 	wav->packet = (unsigned char *)malloc(wav->blockAlign);
 	if (!wav->packet)
 	{
-	    fail("Unable to alloc resources");
+	    st_fail("Unable to alloc resources");
 	    return ST_EOF;
 	}
 	len -= 2;
@@ -736,7 +736,7 @@
 	wav->samples = (short *)malloc(wChannels*wav->samplesPerBlock*sizeof(short));
 	if (!wav->samples)
 	{
-	    fail("Unable to alloc resources");
+	    st_fail("Unable to alloc resources");
 	    return ST_EOF;
 	}
 
@@ -748,7 +748,7 @@
     case WAVE_FORMAT_GSM610:
 	if (wExtSize < 2)
 	{
-	    fail("format[%s]: expects wExtSize >= %d",
+	    st_fail("format[%s]: expects wExtSize >= %d",
 		    wav_format_str(wav->formatTag), 2);
 	    return ST_EOF;
 	}
@@ -756,13 +756,13 @@
 	bytesPerBlock = 65;
 	if (wav->blockAlign != 65)
 	{
-	    fail("format[%s]: expects blockAlign(%d) = %d",
+	    st_fail("format[%s]: expects blockAlign(%d) = %d",
 		    wav_format_str(wav->formatTag), wav->blockAlign, 65);
 	    return ST_EOF;
 	}
 	if (wav->samplesPerBlock != 320)
 	{
-	    fail("format[%s]: expects samplesPerBlock(%d) = %d",
+	    st_fail("format[%s]: expects samplesPerBlock(%d) = %d",
 		    wav_format_str(wav->formatTag), wav->samplesPerBlock, 320);
 	    return ST_EOF;
 	}
@@ -784,7 +784,7 @@
 	if (ft->info.size == -1 || ft->info.size == ST_SIZE_BYTE)
 	    ft->info.size = ST_SIZE_BYTE;
 	else
-	    warn("User options overriding size read in .wav header");
+	    st_warn("User options overriding size read in .wav header");
 
 	/* Now we have enough information to set default encodings. */
 	if (ft->info.encoding == -1)
@@ -795,7 +795,7 @@
 	if (ft->info.size == -1 || ft->info.size == ST_SIZE_WORD)
 	    ft->info.size = ST_SIZE_WORD;
 	else
-	    warn("User options overriding size read in .wav header");
+	    st_warn("User options overriding size read in .wav header");
 
 	/* Now we have enough information to set default encodings. */
 	if (ft->info.encoding == -1)
@@ -806,7 +806,7 @@
 	if (ft->info.size == -1 || ft->info.size == ST_SIZE_DWORD)
 	    ft->info.size = ST_SIZE_DWORD;
 	else
-	    warn("User options overriding size read in .wav header");
+	    st_warn("User options overriding size read in .wav header");
 
 	/* Now we have enough information to set default encodings. */
 	if (ft->info.encoding == -1)
@@ -814,7 +814,7 @@
 	break;
 	
     default:
-	fail("Sorry, don't understand .wav size");
+	st_fail("Sorry, don't understand .wav size");
 	return ST_EOF;
     }
 
@@ -834,7 +834,7 @@
     case WAVE_FORMAT_ADPCM:
 	wav->numSamples = 
 	    AdpcmSamplesIn(wDataLength, ft->info.channels, wav->blockAlign, wav->samplesPerBlock);
-	/*report("datalen %d, numSamples %d",wDataLength, wav->numSamples);*/
+	/*st_report("datalen %d, numSamples %d",wDataLength, wav->numSamples);*/
 	wav->blockSamplesRemaining = 0;	       /* Samples left in buffer */
 	break;
 
@@ -843,7 +843,7 @@
 	   are samplesPerBlock samples to read. */
 	wav->numSamples = 
 	    ImaSamplesIn(wDataLength, ft->info.channels, wav->blockAlign, wav->samplesPerBlock);
-	/*report("datalen %d, numSamples %d",wDataLength, wav->numSamples);*/
+	/*st_report("datalen %d, numSamples %d",wDataLength, wav->numSamples);*/
 	wav->blockSamplesRemaining = 0;	       /* Samples left in buffer */
 	initImaTable();
 	break;
@@ -860,10 +860,10 @@
 
     }
 
-    report("Reading Wave file: %s format, %d channel%s, %d samp/sec",
+    st_report("Reading Wave file: %s format, %d channel%s, %d samp/sec",
 	   wav_format_str(wav->formatTag), ft->info.channels,
 	   wChannels == 1 ? "" : "s", wSamplesPerSecond);
-    report("        %d byte/sec, %d block align, %d bits/samp, %u data bytes",
+    st_report("        %d byte/sec, %d block align, %d bits/samp, %u data bytes",
 	   wAvgBytesPerSec, wav->blockAlign, wBitsPerSample, wDataLength);
 
     /* Can also report extended fmt information */
@@ -870,18 +870,18 @@
     switch (wav->formatTag)
     {
     case WAVE_FORMAT_ADPCM:
-	report("        %d Extsize, %d Samps/block, %d bytes/block %d Num Coefs",
+	st_report("        %d Extsize, %d Samps/block, %d bytes/block %d Num Coefs",
 		wExtSize,wav->samplesPerBlock,bytesPerBlock,wav->nCoefs);
 	break;
 
     case WAVE_FORMAT_IMA_ADPCM:
-	report("        %d Extsize, %d Samps/block, %d bytes/block",
+	st_report("        %d Extsize, %d Samps/block, %d bytes/block",
 		wExtSize,wav->samplesPerBlock,bytesPerBlock);
 	break;
 
 #ifdef HAVE_LIBGSM
     case WAVE_FORMAT_GSM610:
-	report("GSM .wav: %d Extsize, %d Samps/block,  %d samples",
+	st_report("GSM .wav: %d Extsize, %d Samps/block,  %d samples",
 		wExtSize,wav->samplesPerBlock,wav->numSamples);
 	break;
 #endif
@@ -972,7 +972,7 @@
 
 	    done = wavgsmread(ft, buf, len);
 	    if (done == 0 && wav->numSamples != 0)
-		warn("Premature EOF on .wav input file");
+		st_warn("Premature EOF on .wav input file");
 	break;
 #endif
 	default: /* assume PCM encoding */
@@ -983,7 +983,7 @@
 	    /* If software thinks there are more samples but I/O */
 	    /* says otherwise, let the user know about this.     */
 	    if (done == 0 && wav->numSamples != 0)
-		warn("Premature EOF on .wav input file");
+		st_warn("Premature EOF on .wav input file");
 	}
 
 	wav->numSamples -= done;
@@ -1035,7 +1035,7 @@
 	wav->numSamples = 0;
 	wav->dataLength = 0;
 	if (!ft->seekable)
-		warn("Length in output .wav header will be wrong since can't seek to fix it");
+		st_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;
@@ -1057,7 +1057,7 @@
 	    wav->samples = (short *)malloc(sbsize*sizeof(short));
 	    if (!wav->packet || !wav->samples)
 	    {
-		fail("Unable to alloc resources");
+		st_fail("Unable to alloc resources");
 		return ST_EOF;
 	    }
 	    wav->sampleTop = wav->samples + sbsize;
@@ -1179,7 +1179,7 @@
 			    ft->info.encoding != ST_ENCODING_ALAW &&
 			    ft->info.encoding != ST_ENCODING_GSM)
 			{
-				warn("Do not support %s with 8-bit data.  Forcing to unsigned",st_encodings_str[ft->info.encoding]);
+				st_warn("Do not support %s with 8-bit data.  Forcing to unsigned",st_encodings_str[ft->info.encoding]);
 				ft->info.encoding = ST_ENCODING_UNSIGNED;
 			}
 			break;
@@ -1187,7 +1187,7 @@
 			wBitsPerSample = 16;
 			if (ft->info.encoding != ST_ENCODING_SIGN2)
 			{
-				warn("Do not support %s with 16-bit data.  Forcing to Signed.",st_encodings_str[ft->info.encoding]);
+				st_warn("Do not support %s with 16-bit data.  Forcing to Signed.",st_encodings_str[ft->info.encoding]);
 				ft->info.encoding = ST_ENCODING_SIGN2;
 			}
 			break;
@@ -1195,13 +1195,13 @@
 			wBitsPerSample = 32;
 			if (ft->info.encoding != ST_ENCODING_SIGN2)
 			{
-				warn("Do not support %s with 16-bit data.  Forcing to Signed.",st_encodings_str[ft->info.encoding]);
+				st_warn("Do not support %s with 16-bit data.  Forcing to Signed.",st_encodings_str[ft->info.encoding]);
 				ft->info.encoding = ST_ENCODING_SIGN2;
 			}
 
 			break;
 		default:
-			warn("Do not support %s in WAV files.  Forcing to Signed Words.",st_sizes_str[ft->info.size]);
+			st_warn("Do not support %s in WAV files.  Forcing to Signed Words.",st_sizes_str[ft->info.size]);
 			ft->info.encoding = ST_ENCODING_SIGN2;
 			ft->info.size = ST_SIZE_WORD;
 			wBitsPerSample = 16;
@@ -1238,7 +1238,7 @@
 		case ST_ENCODING_IMA_ADPCM:
 			if (wChannels>16)
 			{
-			    fail("Channels(%d) must be <= 16\n",wChannels);
+			    st_fail("Channels(%d) must be <= 16\n",wChannels);
 			    return ST_EOF;
 			}
 			wFormatTag = WAVE_FORMAT_IMA_ADPCM;
@@ -1250,7 +1250,7 @@
 		case ST_ENCODING_ADPCM:
 			if (wChannels>16)
 			{
-			    fail("Channels(%d) must be <= 16\n",wChannels);
+			    st_fail("Channels(%d) must be <= 16\n",wChannels);
 			    return ST_EOF;
 			}
 			wFormatTag = WAVE_FORMAT_ADPCM;
@@ -1263,7 +1263,7 @@
 #ifdef HAVE_LIBGSM
 		    if (wChannels!=1)
 		    {
-			fail("Channels(%d) must be == 1\n",wChannels);
+			st_fail("Channels(%d) must be == 1\n",wChannels);
 			return ST_EOF;
 		    }
 		    wFormatTag = WAVE_FORMAT_GSM610;
@@ -1273,7 +1273,7 @@
 		    wExtSize=2;        /* length of format extension */
 		    wSamplesPerBlock = 320;
 #else
-		    fail("sorry, no GSM6.10 support, recompile sox with gsm library");
+		    st_fail("sorry, no GSM6.10 support, recompile sox with gsm library");
 		    return ST_EOF;
 #endif
 		    break;
@@ -1371,20 +1371,20 @@
 	st_writedw(ft, wDataLength);		/* data chunk size */
 
 	if (!second_header) {
-		report("Writing Wave file: %s format, %d channel%s, %d samp/sec",
+		st_report("Writing Wave file: %s format, %d channel%s, %d samp/sec",
 	        	wav_format_str(wFormatTag), wChannels,
 	        	wChannels == 1 ? "" : "s", wSamplesPerSecond);
-		report("        %d byte/sec, %d block align, %d bits/samp",
+		st_report("        %d byte/sec, %d block align, %d bits/samp",
 	                wAvgBytesPerSec, wBlockAlign, wBitsPerSample);
 	} else {
-		report("Finished writing Wave file, %u data bytes %u samples\n",
+		st_report("Finished writing Wave file, %u data bytes %u samples\n",
 			wDataLength,wav->numSamples);
 #ifdef HAVE_LIBGSM
 		if (wFormatTag == WAVE_FORMAT_GSM610){
-		    report("GSM6.10 format: %u blocks %u padded samples %u padded data bytes\n",
+		    st_report("GSM6.10 format: %u blocks %u padded samples %u padded data bytes\n",
 			blocksWritten, wSamplesWritten, wDataLength);
 		    if (wav->gsmbytecount != wDataLength)
-			warn("help ! internal inconsistency - data_written %u gsmbytecount %u",
+			st_warn("help ! internal inconsistency - data_written %u gsmbytecount %u",
 				wDataLength, wav->gsmbytecount);
 
 		}
@@ -1470,7 +1470,7 @@
 
 	if (fseek(ft->fp, 0L, SEEK_SET) != 0)
 	{
-		fail("Sorry, can't rewind output file to rewrite .wav header.");
+		st_fail("Sorry, can't rewind output file to rewrite .wav header.");
 		return ST_EOF;
 	}
 	wavwritehdr(ft, 1);
--- a/src/wve.c
+++ b/src/wve.c
@@ -52,11 +52,11 @@
 	/* Check the magic word (null-terminated) */
         st_reads(ft, magic, 16);
 	if (strncmp(magic, PSION_MAGIC, 15)==0) {
-		report("Found Psion magic word");
+		st_report("Found Psion magic word");
 	}
 	else
 	{
-		fail("Psion header doesn't start with magic word\nTry the '.al' file type with '-t al -r 8000 filename'");
+		st_fail("Psion header doesn't start with magic word\nTry the '.al' file type with '-t al -r 8000 filename'");
 		return (ST_EOF);
 	}
 
@@ -70,15 +70,15 @@
 		 * it doesn't hurt.
 		 */
 		ft->swap = ft->swap ? 0 : 1;
-		report("Found inverted PSION magic word.  Swapping bytes.");
+		st_report("Found inverted PSION magic word.  Swapping bytes.");
 	}
 	else if (version == PSION_VERSION)
 	{
-	    report("Found PSION magic word");
+	    st_report("Found PSION magic word");
 	}
 	else
 	{
-	    fail("Wrong version in Psion header");
+	    st_fail("Wrong version in Psion header");
 	    return(ST_EOF);
 	}
 
@@ -166,14 +166,13 @@
 {
 	if (!ft->seekable)
 	{
-	    warn("Header will be have invalid file length since file is not seekable");
+	    st_warn("Header will be have invalid file length since file is not seekable");
 	    return ST_SUCCESS;
 	}
 
 	if (fseek(ft->fp, 0L, 0) != 0)
 	{
-		fail("Can't rewind output file to rewrite Psion header.");
-		return(ST_EOF);
+		st_fail("Can't rewind output file to rewrite Psion header.");		return(ST_EOF);
 	}
 	wvewriteheader(ft);