shithub: sox

Download patch

ref: d72859bd2a4f920574f0cd63fe6dacbc5c15db97
parent: 7f4adf3dde5a16f802d503408456edd63d6bf07f
author: cbagwell <cbagwell>
date: Wed Sep 27 13:50:36 EDT 2000

Fixed a bug in mask effect and in detecting if output file is
seekable.

--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,14 @@
 This file contains a list of all changes starting after the release of
 sox-11gamma.
 
+sox-12.18
+---------
+  o Andreas Kies fixed a bug were we were not detecting correctly
+    if an output file was seekable.
+  o Fixed a bug in the mask effect introduced in 12.17.  If the libc
+    version of rand() returned more then 15-bit values then it would
+    trash your data.  Reported by Friedhel Mehnert.
+
 sox-12.17
 ---------
   o Sox can now read and write w98 compatible gsm .wav files,
--- a/sox.1
+++ b/sox.1
@@ -515,12 +515,13 @@
 of the sample file must be given.
 The number of channels defaults to 1.
 .TP 10
-.B ".ub, .sb, .uw, .sw, .ul, .sl"
+.B ".ub, .sb, .uw, .sw, .ul, .al, .sl"
 These are several suffices which serve as
 a shorthand for raw files with a given size and encoding.
 Thus, \fBub, sb, uw, sw, ul\fR and \fBsl\fR
 correspond to "unsigned byte", "signed byte",
-"unsigned word", "signed word", "ulaw" (byte), and "signed long".
+"unsigned word", "signed word", "ulaw" (byte), "alaw" (byte),
+and "signed long".
 The sample rate defaults to 8000 hz if not explicitly set,
 and the number of channels (as always) defaults to 1.
 There are lots of Sparc samples floating around in u-law format
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -50,7 +50,7 @@
 	  highp.o highpass.o lowp.o lowpass.o map.o mask.o pan.o \
 	  phaser.o pick.o pitch.o polyphas.o rate.o resample.o reverb.o \
 	  reverse.o speed.o split.o stat.o stretch.o swap.o trim.o \
-	  vibro.o vol.o trim.o
+	  vibro.o vol.o
 
 OSSOBJ_0    =
 OSSOBJ_1    = oss.o
--- a/src/mask.c
+++ b/src/mask.c
@@ -64,7 +64,8 @@
 		case ST_ENCODING_ULAW:
 		case ST_ENCODING_ALAW:
 			for(done = 0; done < len; done++) {
-				tri16 = (rand() + rand()) - 32767;
+				tri16 = 
+				  ((rand()%32768L) + (rand()%32768L)) - 32767;
 
 				l = *ibuf++ + tri16*16*HALFABIT;  /* 2^4.5 */
 				*obuf++ = l;
@@ -74,7 +75,8 @@
 		switch (effp->outinfo.size) {
 			case ST_SIZE_BYTE:
 			for(done = 0; done < len; done++) {
-				tri16 = (rand() + rand()) - 32767;
+				tri16 = 
+				  ((rand()%32768L) + (rand()%32768L)) - 32767;
 
 				l = *ibuf++ + tri16*256*HALFABIT;  /* 2^8.5 */
 				*obuf++ = l;
@@ -82,7 +84,8 @@
 			break;
 			case ST_SIZE_WORD:
 			for(done = 0; done < len; done++) {
-				tri16 = (rand() + rand()) - 32767;
+				tri16 = 
+				  ((rand()%32768L) + (rand()%32768L)) - 32767;
 
 				l = *ibuf++ + tri16*HALFABIT;  /* 2^.5 */
 				*obuf++ = l;
--- a/src/misc.c
+++ b/src/misc.c
@@ -370,7 +370,7 @@
 
 int rand() {
 	rand_seed = (rand_seed * 1103515245L) + 12345L;
-	return ((ULONG)(rand_seed/65536L) % 32768L);
+	return ((unsigned int)(rand_seed/65536L) % 32768L);
 }
 
 void srand(seed) 
--- a/src/st.h
+++ b/src/st.h
@@ -274,7 +274,7 @@
  */
 #ifndef HAVE_RAND
 extern int rand(P0);
-extern void srand(P1(ULONG seed));
+extern void srand(P1(unsigned int seed));
 #endif
 extern void st_initrand(P0);