ref: d329019a4e48bc361c4f2700b32785af8bb76050
parent: bacd7d0b627d69143f6aae85fd0c0322670d396b
author: robs <robs>
date: Tue Mar 18 17:25:43 EDT 2008
tidying up a few things
--- a/sox.1
+++ b/sox.1
@@ -51,14 +51,14 @@
sources, synthesise audio, and, on many systems, act as a general
purpose audio player or a multi-track audio recorder.
.SP
-Almost all SoX functionality is available using just the `sox' command,
+Almost all SoX functionality is available using just the \fBsox\fR command,
however, to simplify playing and recording audio, if SoX is invoked as
-`play', the output file is automatically set to be the default sound
-device and if invoked as `rec', the default sound device is used as an
+\fBplay\fR the output file is automatically set to be the default sound
+device and if invoked as \fBrec\fR the default sound device is used as an
input source.
The
.BR soxi (1)
-command provides a convenient way to query audio file header information.
+command provides a convenient way to just query audio file header information.
.SP
The heart of SoX is a library called libSoX. Those interested in
extending SoX or using it in other programs should refer to the libSoX
@@ -341,8 +341,8 @@
If clipping occurs at any point during processing, then
SoX will display a warning message to that effect.
.SS Input File Combining
-SoX's input combiner can combine multiple files using one of five
-different methods: `concatenate', `sequence', `mix', `merge', or `multiply'.
+SoX's input combiner can combine multiple files using any of the
+following methods: `concatenate', `sequence', `mix', or `merge'.
The default method is `sequence' for
.BR play ,
and `concatenate' for
@@ -388,11 +388,6 @@
first and second mono files would become the left and right channels of
the stereo file.
.SP
-The `multiply' combining method (selected with \fB-T\fR) works in the
-same way as mix combining except that the audio signals are multiplied
-instead of added together. This can be useful for applications such as
-F.M. synthesis.
-.SP
When combining input files, SoX applies any specified effects
(including, for example, the
.B vol
@@ -729,11 +724,11 @@
bit ordering) of the input file is not automatically used for the output
file; so, for example, when the following is run on a little-endian system:
.EX
- sox -B audio.uw trimmed.uw trim 2
+ sox -B audio.s2 trimmed.s2 trim 2
.EE
-trimmed.uw will be created as little-endian;
+trimmed.s2 will be created as little-endian;
.EX
- sox -B audio.uw -B trimmed.uw trim 2
+ sox -B audio.s2 -B trimmed.s2 trim 2
.EE
must be used to preserve big-endianness in the output file.
.SP
--- a/src/aifc-fmt.c
+++ b/src/aifc-fmt.c
@@ -27,7 +27,7 @@
static sox_format_handler_t const sox_aifc_format = {
SOX_LIB_VERSION_CODE,
"AIFF-C (not compressed, linear), defined in DAVIC 1.4 Part 9 Annex B",
- names, SOX_FILE_LOOPS | SOX_FILE_BIG_END,
+ names, SOX_FILE_BIG_END,
sox_aiffstartread, sox_aiffread, sox_aiffstopread,
sox_aifcstartwrite, sox_aiffwrite, sox_aifcstopwrite,
sox_aiffseek, write_encodings, NULL
--- a/src/aiff-fmt.c
+++ b/src/aiff-fmt.c
@@ -27,7 +27,7 @@
static sox_format_handler_t const sox_aiff_format = {
SOX_LIB_VERSION_CODE,
"AIFF files used on Apple IIc/IIgs and SGI",
- names, SOX_FILE_LOOPS | SOX_FILE_BIG_END,
+ names, SOX_FILE_BIG_END,
sox_aiffstartread, sox_aiffread, sox_aiffstopread,
sox_aiffstartwrite, sox_aiffwrite, sox_aiffstopwrite,
sox_aiffseek, write_encodings, NULL
--- a/src/amr.h
+++ b/src/amr.h
@@ -32,13 +32,13 @@
static sox_size_t decode_1_frame(sox_format_t * ft)
{
amr_t amr = (amr_t) ft->priv;
- size_t block_size_1;
+ size_t n_1;
UWord8 coded[AMR_CODED_MAX];
- if (fread(coded, sizeof(coded[0]), 1, ft->fp) != 1)
+ if (sox_readbuf(ft, &coded[0], 1) != 1)
return AMR_FRAME;
- block_size_1 = block_size[(coded[0] >> 3) & 0x0F] - 1;
- if (fread(&coded[1], sizeof(coded[1]), block_size_1, ft->fp) != block_size_1)
+ n_1 = block_size[(coded[0] >> 3) & 0x0F] - 1;
+ if (sox_readbuf(ft, &coded[1], n_1) != n_1)
return AMR_FRAME;
D_IF_decode(amr->state, coded, amr->pcm, 0);
return 0;
@@ -49,7 +49,7 @@
amr_t amr = (amr_t) ft->priv;
UWord8 coded[AMR_CODED_MAX];
#include "amr1.h"
- sox_bool result = fwrite(coded, (unsigned)n, 1, ft->fp) == 1;
+ sox_bool result = sox_writebuf(ft, coded, (unsigned)n) == (unsigned)n;
if (!result)
sox_fail_errno(ft, errno, "write error");
return result;
@@ -63,10 +63,8 @@
amr->pcm_index = AMR_FRAME;
amr->state = D_IF_init();
- if (fread(buffer, sizeof(buffer), 1, ft->fp) != 1) {
- sox_fail_errno(ft, errno, "read error");
+ if (sox_readchars(ft, buffer, sizeof(buffer)))
return SOX_EOF;
- }
if (memcmp(buffer, magic, sizeof(buffer))) {
sox_fail_errno(ft, SOX_EHDR, "invalid magic number");
return SOX_EOF;
--- a/src/au.c
+++ b/src/au.c
@@ -22,10 +22,10 @@
/* Magic numbers used in Sun and NeXT audio files */
static struct {char str[4]; sox_bool reverse_bytes; char const * desc;} id[] = {
- {"\x2e\x73\x6e\x64", SOX_IS_LITTLEENDIAN, "Big-endian .snd"},
- {"\x64\x6e\x73\x2e", SOX_IS_BIGENDIAN , "Little-endian .snd"},
- {"\x00\x64\x73\x2e", SOX_IS_BIGENDIAN , "Little-endian '\0ds.' (for DEC)"},
- {"\x2e\x73\x64\x00", SOX_IS_LITTLEENDIAN, "Big-endian '\0ds.'"},
+ {"\x2e\x73\x6e\x64", SOX_IS_LITTLEENDIAN, "big-endian `.snd'"},
+ {"\x64\x6e\x73\x2e", SOX_IS_BIGENDIAN , "little-endian `.snd'"},
+ {"\x00\x64\x73\x2e", SOX_IS_BIGENDIAN , "little-endian `\\0ds.' (for DEC)"},
+ {"\x2e\x73\x64\x00", SOX_IS_LITTLEENDIAN, "big-endian `\\0ds.'"},
{" ", 0, NULL}
};
#define FIXED_HDR 24
--- a/src/example1.c
+++ b/src/example1.c
@@ -91,7 +91,7 @@
assert(e.handler.getopts(&e, 1, vol) == SOX_SUCCESS);
assert(sox_add_effect(chain, &e, &in->signal, &in->signal) == SOX_SUCCESS);
- sox_create_effect(&e, sox_find_effect("reverb"));
+ sox_create_effect(&e, sox_find_effect("flanger"));
assert(e.handler.getopts(&e, 0, NULL) == SOX_SUCCESS);
assert(sox_add_effect(chain, &e, &in->signal, &in->signal) == SOX_SUCCESS);
--- a/src/sf.c
+++ b/src/sf.c
@@ -23,13 +23,13 @@
/* Magic numbers used in IRCAM audio files */
static struct {char str[4]; sox_bool reverse_bytes; char const * desc;} id[] = {
- {"\144\243\001\0", SOX_IS_BIGENDIAN , "Little-endian VAX (native)"},
- {"\0\001\243\144", SOX_IS_LITTLEENDIAN, "Big-endian VAX"},
- {"\144\243\002\0", SOX_IS_LITTLEENDIAN, "Big-endian Sun (native)"},
- {"\0\002\243\144", SOX_IS_BIGENDIAN , "Little-endian Sun"},
- {"\144\243\003\0", SOX_IS_BIGENDIAN , "Little-endian MIPS (DEC)"},
- {"\0\003\243\144", SOX_IS_LITTLEENDIAN, "Big-endian MIPS (SGI)"},
- {"\144\243\004\0", SOX_IS_LITTLEENDIAN, "Big-endian NeXT"},
+ {"\144\243\001\0", SOX_IS_BIGENDIAN , "little-endian VAX (native)"},
+ {"\0\001\243\144", SOX_IS_LITTLEENDIAN, "big-endian VAX"},
+ {"\144\243\002\0", SOX_IS_LITTLEENDIAN, "big-endian Sun (native)"},
+ {"\0\002\243\144", SOX_IS_BIGENDIAN , "little-endian Sun"},
+ {"\144\243\003\0", SOX_IS_BIGENDIAN , "little-endian MIPS (DEC)"},
+ {"\0\003\243\144", SOX_IS_LITTLEENDIAN, "big-endian MIPS (SGI)"},
+ {"\144\243\004\0", SOX_IS_LITTLEENDIAN, "big-endian NeXT"},
{" ", 0, NULL}
};
#define FIXED_HDR 1024
--- a/src/smp.c
+++ b/src/smp.c
@@ -403,7 +403,7 @@
static sox_format_handler_t handler = {
SOX_LIB_VERSION_CODE,
"Turtle Beach SampleVision",
- names, SOX_FILE_LOOPS | SOX_FILE_LIT_END | SOX_FILE_MONO,
+ names, SOX_FILE_LIT_END | SOX_FILE_MONO,
sox_smpstartread, sox_smpread, NULL,
sox_smpstartwrite, sox_smpwrite, sox_smpstopwrite,
sox_smpseek, write_encodings, NULL
--- a/src/sox.c
+++ b/src/sox.c
@@ -1018,7 +1018,6 @@
"--replay-gain track|album|off default: off (sox, rec), track (play)",
"-R use default random numbers (same on each run of SoX)",
"-S, --show-progress display progress while processing audio data",
-"-T, --combine multiply multiply multiple input files (instead of concatenating)",
"--version display version number of SoX and exit",
"-V[LEVEL] increment or set verbosity level (default 2); levels are:",
" 1: failure messages",
--- a/src/sox.h
+++ b/src/sox.h
@@ -28,7 +28,7 @@
/* The following is the API version of libSoX. It is not meant
* to follow the version number of SoX but it has historically.
* Please do not count on these numbers being in sync.
- * The following is at 14.0.1
+ * The following is at 14.1.0
*/
#define SOX_LIB_VERSION_CODE 0x0e0100
#define SOX_LIB_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
@@ -63,7 +63,6 @@
#define SOX_INT16_MAX SOX_INT_MAX(16)
#define SOX_INT24_MAX SOX_INT_MAX(24)
#define SOX_INT32_MAX SOX_INT_MAX(32)
-#define SOX_INT64_MAX 0x7fffffffffffffffLL /* Not in use yet */
typedef int32_t sox_sample_t;
@@ -172,6 +171,12 @@
typedef double sox_rate_t;
+typedef struct { /* Signal parameters; 0 if unknown */
+ sox_rate_t rate; /* sampling rate */
+ unsigned channels; /* number of sound channels */
+ unsigned precision; /* in bits */
+} sox_signalinfo_t;
+
typedef enum {
SOX_ENCODING_UNKNOWN ,
@@ -203,17 +208,11 @@
SOX_ENCODINGS /* End of list marker */
} sox_encoding_t;
-typedef enum {sox_plot_off, sox_plot_octave, sox_plot_gnuplot} sox_plot_t;
+extern const char * const sox_encodings_str[];
+extern const char * const sox_encodings_short_str[];
+
typedef enum {SOX_OPTION_NO, SOX_OPTION_YES, SOX_OPTION_DEFAULT} sox_option_t;
-
-typedef struct { /* Signal parameters; 0 if unknown */
- sox_rate_t rate; /* sampling rate */
- unsigned channels; /* number of sound channels */
- unsigned precision; /* in bits */
-} sox_signalinfo_t;
-
-
typedef struct { /* Encoding parameters */
sox_encoding_t encoding; /* format of sample numbers */
unsigned bits_per_sample; /* 0 if unknown or variable; uncompressed value if lossless; compressed value if lossy */
@@ -321,49 +320,42 @@
* in memory in the optimal way for any structure to be cast over it. */
char priv[SOX_MAX_FILE_PRIVSIZE]; /* format's private data area */
- sox_signalinfo_t signal; /* signal specifications */
- sox_encodinginfo_t encoding; /* encoding specifications */
- sox_instrinfo_t instr; /* instrument specification */
+ sox_signalinfo_t signal; /* signal specifications */
+ sox_encodinginfo_t encoding; /* encoding specifications */
+ sox_instrinfo_t instr; /* instrument specification */
sox_loopinfo_t loops[SOX_MAX_NLOOPS];/* Looping specification */
- sox_bool seekable; /* can seek on this file */
- char mode; /* read or write mode */
- sox_size_t length; /* samples * channels in file; 0 if unknown */
- sox_size_t olength; /* samples * channels in file; 0 if unknown */
- sox_size_t clips; /* increment if clipping occurs */
- char *filename; /* file name */
- char *filetype; /* type of file */
- comments_t comments; /* comment strings */
- FILE *fp; /* File stream pointer */
- int sox_errno; /* Failure error codes */
- char sox_errstr[256]; /* Extend Failure text */
+ sox_bool seekable; /* can seek on this file */
+ char mode; /* read or write mode */
+ sox_size_t length; /* samples * chans in file; 0 if unknown */
+ sox_size_t olength; /* samples * chans in file; 0 if unknown */
+ sox_size_t clips; /* increment if clipping occurs */
+ char *filename; /* file name */
+ char *filetype; /* type of file */
+ comments_t comments; /* comment strings */
+ FILE *fp; /* File stream pointer */
+ int sox_errno; /* Failure error codes */
+ char sox_errstr[256]; /* Extend Failure text */
off_t tell;
off_t data_start;
sox_format_handler_t handler; /* format struct for this file */
};
-/* file flags field */
-#define SOX_FILE_LOOPS 1 /* does file format support loops? */
-#define SOX_FILE_INSTR 2 /* does file format support instrument specs? */
-#define SOX_FILE_NOSTDIO 8 /* does not use stdio routines */
-#define SOX_FILE_DEVICE 16 /* file is an audio device */
-#define SOX_FILE_PHONY 32 /* phony file/device */
-/* These two for use by the libSoX core or libSoX clients: */
-#define SOX_FILE_ENDIAN 64 /* is file format endian? */
-#define SOX_FILE_ENDBIG 128/* if so, is it big endian? */
-/* These two for use by libSoX handlers: */
-#define SOX_FILE_LIT_END (0 + 64)
-#define SOX_FILE_BIG_END (128 + 64)
-#define SOX_FILE_BIT_REV 0x0100
-#define SOX_FILE_NIB_REV 0x0200
-#define SOX_FILE_CHANS 0x1C00
-#define SOX_FILE_MONO 0x0400
-#define SOX_FILE_STEREO 0x0800
-#define SOX_FILE_QUAD 0x1000
-#define SOX_FILE_REWIND 0x2000
+/* File flags field */
+#define SOX_FILE_NOSTDIO 0x0001 /* Does not use stdio routines */
+#define SOX_FILE_DEVICE 0x0002 /* File is an audio device */
+#define SOX_FILE_PHONY 0x0004 /* Phony file/device */
+#define SOX_FILE_REWIND 0x0008 /* File should be rewound to write header */
+#define SOX_FILE_BIT_REV 0x0010 /* Is file bit-reversed? */
+#define SOX_FILE_NIB_REV 0x0020 /* Is file nibble-reversed? */
+#define SOX_FILE_ENDIAN 0x0040 /* Is file format endian? */
+#define SOX_FILE_ENDBIG 0x0080 /* If so, is it big endian? */
+#define SOX_FILE_MONO 0x0100 /* Do channel restrictions allow mono? */
+#define SOX_FILE_STEREO 0x0200 /* Do channel restrictions allow stereo? */
+#define SOX_FILE_QUAD 0x0400 /* Do channel restrictions allow quad? */
-/* declared in misc.c */
-extern const char * const sox_encodings_str[];
-extern const char * const sox_encodings_short_str[];
+#define SOX_FILE_CHANS (SOX_FILE_MONO | SOX_FILE_STEREO | SOX_FILE_QUAD)
+#define SOX_FILE_LIT_END (SOX_FILE_ENDIAN | 0)
+#define SOX_FILE_BIG_END (SOX_FILE_ENDIAN | SOX_FILE_ENDBIG)
int sox_format_init(void);
sox_format_t * sox_open_read(
@@ -412,6 +404,7 @@
typedef struct sox_effect sox_effect_t;
typedef struct sox_effects_globals sox_effects_globals_t;
+typedef enum {sox_plot_off, sox_plot_octave, sox_plot_gnuplot} sox_plot_t;
typedef struct {
char const * name;
--- a/src/soxio.c
+++ b/src/soxio.c
@@ -149,18 +149,27 @@
if (ft->encoding.opposite_endian)
ft->encoding.reverse_bytes = (ft->handler.flags & SOX_FILE_ENDIAN)?
!(ft->handler.flags & SOX_FILE_ENDBIG) != SOX_IS_BIGENDIAN : sox_true;
- if (ft->encoding.reverse_bytes == SOX_OPTION_DEFAULT)
+ else if (ft->encoding.reverse_bytes == SOX_OPTION_DEFAULT)
ft->encoding.reverse_bytes = (ft->handler.flags & SOX_FILE_ENDIAN)?
!(ft->handler.flags & SOX_FILE_ENDBIG) == SOX_IS_BIGENDIAN : sox_false;
+
+ if (ft->handler.flags & SOX_FILE_ENDIAN) {
+ if (ft->encoding.reverse_bytes ==
+ (!(ft->handler.flags & SOX_FILE_ENDBIG) != SOX_IS_BIGENDIAN))
+ sox_report("`%s': overriding file-type byte-order", ft->filename);
+ } else if (ft->encoding.reverse_bytes == sox_true)
+ sox_report("`%s': overriding machine byte-order", ft->filename);
+
if (ft->encoding.reverse_bits == SOX_OPTION_DEFAULT)
ft->encoding.reverse_bits = !!(ft->handler.flags & SOX_FILE_BIT_REV);
- else if (ft->encoding.reverse_bits != !!(ft->handler.flags & SOX_FILE_BIT_REV))
- sox_report("'%s': Format options overriding file-type bit-order", ft->filename);
+ else if (ft->encoding.reverse_bits == !(ft->handler.flags & SOX_FILE_BIT_REV))
+ sox_report("`%s': overriding file-type bit-order", ft->filename);
if (ft->encoding.reverse_nibbles == SOX_OPTION_DEFAULT)
ft->encoding.reverse_nibbles = !!(ft->handler.flags & SOX_FILE_NIB_REV);
- else if (ft->encoding.reverse_nibbles != !!(ft->handler.flags & SOX_FILE_NIB_REV))
- sox_report("'%s': Format options overriding file-type nibble-order", ft->filename);
+ else
+ if (ft->encoding.reverse_nibbles == !(ft->handler.flags & SOX_FILE_NIB_REV))
+ sox_report("`%s': overriding file-type nibble-order", ft->filename);
}
static int is_seekable(sox_format_t * ft)