shithub: sox

Download patch

ref: 4018ddfbd16b7c53a8fb5a6f4d65b6c2665d74de
parent: a91ca20565bdd9bcd4ac57b88ed2c7fde4e4958b
author: robs <robs>
date: Sat Apr 11 08:15:12 EDT 2009

these days, #bits is more user friendly than #bytes

--- a/sox.1
+++ b/sox.1
@@ -1098,11 +1098,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.s2 trimmed.s2 trim 2
+	sox -B audio.s16 trimmed.s16 trim 2
 .EE
-trimmed.s2 will be created as little-endian;
+trimmed.s16 will be created as little-endian;
 .EX
-	sox -B audio.s2 -B trimmed.s2 trim 2
+	sox -B audio.s16 -B trimmed.s16 trim 2
 .EE
 must be used to preserve big-endianness in the output file.
 .SP
--- a/soxformat.7
+++ b/soxformat.7
@@ -58,16 +58,11 @@
 `AUDIO FILE FORMATS' or `AUDIO DEVICE DRIVERS'.
 .SS SOX FORMATS & DEVICE DRIVERS
 \&\fB.raw\fR (also with \fB\-t sndfile\fR),
+\&\fB.f32\fR, \fB.f64\fR,
+\&\fB.s8\fR, \fB.s16\fR, \fB.s24\fR, \fB.s32\fR,
 .br
-\&\fB.f4\fR, \fB.f8\fR,
-.br
-\&\fB.s1\fR, \fB.s2\fR, \fB.s3\fR, \fB.s4\fR,
-.br
-\&\fB.u1\fR, \fB.u2\fR, \fB.u3\fR, \fB.u4\fR,
-.br
-\&\fB.ul\fR, \fB.al\fR, \fB.lu\fR, \fB.la\fR,
-.br
-\&\fB.sb\fR, \fB.sw\fR, \fB.ub\fR, \fB.uw\fR
+\&\fB.u8\fR, \fB.u16\fR, \fB.u24\fR, \fB.u32\fR,
+\&\fB.ul\fR, \fB.al\fR, \fB.lu\fR, \fB.la\fR
 .if t .sp -.5
 .if n .sp -1
 .TP
@@ -77,20 +72,18 @@
 the sample rate and the data encoding must be given using command-line
 format options; for the other listed types, the sample rate defaults to
 8kHz (but may be overridden), and the data encoding is defined by the
-given suffix.  Thus \fBf4\fR and \fBf8\fR indicate files encoded as 4
-and 8-byte (IEEE single and double precision) floating point PCM
-respectively; \fBs1\fR, \fBs2\fR, \fBs3\fR, and \fBs4\fR indicate 1,
-2, 3, and 4-byte signed integer PCM respectively; \fBu1\fR, \fBu2\fR,
-\fBu3\fR, and \fBu4\fR indicate 1, 2, 3, and 4-byte unsigned integer
-PCM respectively; \fBul\fR indicates `\(*m-law' (byte), \fBal\fR
-indicates `A-law' (byte), and \fBlu\fR and \fBla\fR are inverse bit
-order `\(*m-law' and inverse bit order `A-law' respectively.  \fBsb\fR,
-\fBsw\fR, \fBub\fR, \fBuw\fR, and \fBsl\fR are aliases for \fBs1\fR,
-\fBs2\fR, \fBu1\fR, \fBu2\fR, and \fBs4\fR respectively.  For all raw
+given suffix.  Thus \fBf32\fR and \fBf64\fR indicate files encoded as 32
+and 64-bit (IEEE single and double precision) floating point PCM
+respectively; \fBs8\fR, \fBs16\fR, \fBs24\fR, and \fBs32\fR indicate 8,
+16, 24, and 32-bit signed integer PCM respectively; \fBu8\fR, \fBu16\fR,
+\fBu24\fR, and \fBu32\fR indicate 8, 16, 24, and 32-bit unsigned integer
+PCM respectively; \fBul\fR indicates `\(*m-law' (8-bit), \fBal\fR
+indicates `A-law' (8-bit), and \fBlu\fR and \fBla\fR are inverse bit
+order `\(*m-law' and inverse bit order `A-law' respectively.  For all raw
 formats, the number of channels defaults to 1 (but may be overridden).
 .SP
 Headerless audio files on a SPARC computer are likely to be of format
-\fBul\fR;  on a Mac, they're likely to be \fBu1\fR but with a
+\fBul\fR;  on a Mac, they're likely to be \fBu8\fR but with a
 sample rate of 11025 or 22050\ Hz.
 .SP
 See
@@ -98,17 +91,34 @@
 and
 .B .vox
 for raw ADPCM formats.
+.PP
+\&\fB.f4\fR, \fB.f8\fR,
+\&\fB.s1\fR, \fB.s2\fR, \fB.s3\fR, \fB.s4\fR,
+.br
+\&\fB.u1\fR, \fB.u2\fR, \fB.u3\fR, \fB.u4\fR,
+\&\fB.sb\fR, \fB.sw\fR, \fB.sl\fR, \fB.ub\fR, \fB.uw\fR
+.if t .sp -.5
+.if n .sp -1
 .TP
+\ 
+Deprecated aliases for
+\fBf32\fR, \fBf64\fR, \fBs8\fR, \fBs16\fR, \fBs24\fR, \fBs32\fR,
+.br
+\fBu8\fR, \fBu16\fR, \fBu24\fR, \fBu32\fR,
+\fBs8\fR, \fBs16\fR, \fBs32\fR, \fBu8\fR, and \fBu16\fR
+respectively.
+.TP
 \&\fB.8svx\fR (also with \fB\-t sndfile\fR)
 Amiga 8SVX musical instrument description format.
 .TP
 \&\fB.aiff\fR, \fB.aif\fR (also with \fB\-t sndfile\fR)
-AIFF files used on Apple Macs as well as older Apple IIc/IIgs and SGI.
-Currently, SoX's AIFF support does not include multiple audio chunks,
+AIFF files as used on old Apple Macs, Apple IIc/IIgs and SGI.
+SoX's AIFF support does not include multiple audio chunks,
 or the 8SVX musical instrument description format.
 AIFF files are multimedia archives and
-can have multiple audio and picture chunks.
-You may need a separate archiver to work with them.
+can have multiple audio and picture chunks\*m
+you may need a separate archiver to work with them.
+With Mac OS X, AIFF has been superseded by CAF.
 .TP
 \&\fB.aiffc\fR, \fB.aifc\fR (also with \fB\-t sndfile\fR)
 AIFF-C is a format based on AIFF that was created to allow
@@ -311,7 +321,7 @@
 .TP
 .B .fssd
 An alias for the
-.B .u1
+.B .u8
 format.
 .TP
 \&\fB.gsm\fR (optional; also with \fB\-t sndfile\fR)
@@ -514,7 +524,7 @@
 .TP
 .B .sou
 An alias for the
-.B .u1
+.B .u8
 raw format.
 .TP
 .B .sox
--- a/src/f4-fmt.c
+++ b/src/f4-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT(f4, 32, 0, FLOAT)
+RAW_FORMAT1(f4, "f32", 32, 0, FLOAT)
--- a/src/f8-fmt.c
+++ b/src/f8-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT(f8, 64, 0, FLOAT)
+RAW_FORMAT1(f8, "f64", 64, 0, FLOAT)
--- a/src/raw.h
+++ b/src/raw.h
@@ -48,3 +48,7 @@
 #define RAW_FORMAT3(id, alt1, alt2, alt3, size, flags, encoding) \
   static char const *names[] = {#id, alt1, alt2, alt3, NULL}; \
   RAW_FORMAT0(id, size, flags, encoding)
+
+#define RAW_FORMAT4(id, alt1, alt2, alt3, alt4, size, flags, encoding) \
+  static char const *names[] = {#id, alt1, alt2, alt3, alt4, NULL}; \
+  RAW_FORMAT0(id, size, flags, encoding)
--- a/src/s1-fmt.c
+++ b/src/s1-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT1(s1, "sb", 8, 0, SIGN2)
+RAW_FORMAT2(s1, "s8", "sb", 8, 0, SIGN2)
--- a/src/s2-fmt.c
+++ b/src/s2-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT1(s2, "sw", 16, 0, SIGN2)
+RAW_FORMAT2(s2, "s16", "sw", 16, 0, SIGN2)
--- a/src/s3-fmt.c
+++ b/src/s3-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT(s3, 24, 0, SIGN2)
+RAW_FORMAT1(s3, "s24", 24, 0, SIGN2)
--- a/src/s4-fmt.c
+++ b/src/s4-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT1(s4, "sl", 32, 0, SIGN2)
+RAW_FORMAT2(s4, "s32", "sl", 32, 0, SIGN2)
--- a/src/tests.sh
+++ b/src/tests.sh
@@ -62,10 +62,10 @@
   case $1 in
     al )  formatText="alaw" ;;
     ul )  formatText="ulaw" ;;
-    wavu1)formatText="u1 in wav";  formatFlags="-u -1"; formatExt="wav" ;;
-    s1X ) formatText="s1 (swap bits)"; formatExt="s1"; formatFlags="-X" ;;
-    s1N ) formatText="s1 (swap nibbles)"; formatExt="s1"; formatFlags="-N" ;;
-    s1XN) formatText="s1 (swap nibbles & bits)"; formatExt="s1"; formatFlags="-X -N" ;;
+    wavu8)formatText="u8 in wav";  formatFlags="-u -1"; formatExt="wav" ;;
+    s1X ) formatText="s8 (swap bits)"; formatExt="s8"; formatFlags="-X" ;;
+    s1N ) formatText="s8 (swap nibbles)"; formatExt="s8"; formatFlags="-N" ;;
+    s1XN) formatText="s8 (swap nibbles & bits)"; formatExt="s8"; formatFlags="-X -N" ;;
   esac
 }
   
@@ -121,31 +121,31 @@
 }
 
 do_multichannel_formats () {
-  format1=u1
-  convertToAndFrom s1 u1 s2 u2 s3 u3 s4 u4 f4 f8 dat au wav aiff aifc flac caf sph wv sox
+  format1=u8
+  convertToAndFrom s8 u8 s16 u16 s24 u24 s32 u32 f32 f64 dat au wav aiff aifc flac caf sph wv sox
 
-  format1=s2
-  convertToAndFrom s2 u2 s3 u3 s4 u4 f4 f8 dat au wav aiff aifc flac caf sph wv sox
+  format1=s16
+  convertToAndFrom s16 u16 s24 u24 s32 u32 f32 f64 dat au wav aiff aifc flac caf sph wv sox
 
-  format1=u3
-  convertToAndFrom s3 u3 s4 u4 f4 f8 wav aiff aifc flac sph wv sox
+  format1=u24
+  convertToAndFrom s24 u24 s32 u32 f32 f64 wav aiff aifc flac sph wv sox
   (samples=23500; convertToAndFrom paf) || exit 1
 
-  format1=s4
-  convertToAndFrom s4 u4 f8 wav aiff aifc caf sph wv mat4 mat5 sox
+  format1=s32
+  convertToAndFrom s32 u32 f64 wav aiff aifc caf sph wv mat4 mat5 sox
 
   format1=al
-  convertToAndFrom al s2 u2 s4 f4 f8 dat aiff aifc flac caf w64
+  convertToAndFrom al s16 u16 s32 f32 f64 dat aiff aifc flac caf w64
 
   format1=ul
-  convertToAndFrom ul s2 u2 s4 f4 f8 dat aiff aifc flac caf sph
+  convertToAndFrom ul s16 u16 s32 f32 f64 dat aiff aifc flac caf sph
 
-  format1=wavu1
-  convertToAndFrom wavu1 aiff aifc au dat sf flac caf sph
+  format1=wavu8
+  convertToAndFrom wavu8 aiff aifc au dat sf flac caf sph
 }
 
 do_twochannel_formats () {
-  format1=wavu1
+  format1=wavu8
   convertToAndFrom avr maud
   (rate=8000; convertToAndFrom voc) || exit 1      # Fixed rate
   (samples=23492; convertToAndFrom 8svx) || exit 1 # Even number of samples only
@@ -153,21 +153,21 @@
 
 do_singlechannel_formats () {
   format1=vox
-  convertToAndFrom vox s2 u2 s3 u3 s4 u4 f4 f8 dat au wav aiff aifc flac caf sox
+  convertToAndFrom vox s16 u16 s24 u24 s32 u32 f32 f64 dat au wav aiff aifc flac caf sox
 
   format1=ima
-  convertToAndFrom ima s2 u2 s3 u3 s4 u4 f4 f8 dat au aiff aifc flac caf # FIXME: wav
+  convertToAndFrom ima s16 u16 s24 u24 s32 u32 f32 f64 dat au aiff aifc flac caf # FIXME: wav
 
-  format1=wavu1
-  convertToAndFrom smp s1 s1X s1N s1XN sndt sndr
+  format1=wavu8
+  convertToAndFrom smp s8 s1X s1N s1XN sndt sndr
   #(rate=50000; convertToAndFrom txw) || exit 1     # FIXME
   (rate=11025; convertToAndFrom hcom) || exit 1     # Fixed rates
 
   format1=wve
-  (rate=8000; convertToAndFrom al s2 u2 s4 f4 f8 dat) || exit 1 # Fixed rate
+  (rate=8000; convertToAndFrom al s16 u16 s32 f32 f64 dat) || exit 1 # Fixed rate
 
   format1=prc
-  (rate=8000; convertToAndFrom al s2 u2 s4 f4 f8 dat) || exit 1 # Fixed rate
+  (rate=8000; convertToAndFrom al s16 u16 s32 f32 f64 dat) || exit 1 # Fixed rate
 }
 
 stderr_time () {
@@ -224,7 +224,7 @@
 fi
 do_twochannel_formats
 format1=cdda         # 2-channel only
-convertToAndFrom s2 u3 aiff
+convertToAndFrom s16 u24 aiff
 
 channels=1 
 if [ "$all" = "all" ]; then
@@ -243,19 +243,19 @@
 fi
 fi
 
-${bindir}/sox -c 1 -r 44100 -n output.u1 synth .01 vol .5
-if [ `wc -c <output.u1` = 441 ]; then
+${bindir}/sox -c 1 -r 44100 -n output.u8 synth .01 vol .5
+if [ `wc -c <output.u8` = 441 ]; then
   echo "ok     synth size"
 else
   echo "*FAIL* synth size"
 fi
-rm output.u1
+rm output.u8
 
 echo "Checked $vectors vectors"
 
 channels=2
 samples=1e7
-timeIO s1 u1 s2 u2 s3 u3 s4 u4 f4 f8 au wav aiff aifc sph # FIXME?: caf flac dat
+timeIO s8 u8 s16 u16 s24 u24 s32 u32 f32 f64 au wav aiff aifc sph # FIXME?: caf flac dat
 
 test -n "$skip" && echo "Skipped: $skip"
 
--- a/src/u1-fmt.c
+++ b/src/u1-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT3(u1, "ub", "sou", "fssd", 8, 0, UNSIGNED)
+RAW_FORMAT4(u1, "u8", "ub", "sou", "fssd", 8, 0, UNSIGNED)
--- a/src/u2-fmt.c
+++ b/src/u2-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT1(u2, "uw", 16, 0, UNSIGNED)
+RAW_FORMAT2(u2, "u16", "uw", 16, 0, UNSIGNED)
--- a/src/u3-fmt.c
+++ b/src/u3-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT(u3, 24, 0, UNSIGNED)
+RAW_FORMAT1(u3, "u24", 24, 0, UNSIGNED)
--- a/src/u4-fmt.c
+++ b/src/u4-fmt.c
@@ -18,4 +18,4 @@
 #include "sox_i.h"
 #include "raw.h"
 
-RAW_FORMAT(u4, 32, 0, UNSIGNED)
+RAW_FORMAT1(u4, "u32", 32, 0, UNSIGNED)