3 # SoX Regression Test script: Lossless file conversion
9 if [ -f .
/sox.exe
] ; then
15 # Set options & allow user to override paths. Useful for testing an
17 while [ $# -ne 0 ]; do
28 -a) # Perform each test up to 3 times with different #s of
29 all
=all
# channels; probably enough coverage without this though.
33 bindir
=`echo $1 | sed 's/.*=//'`
42 builddir
=`echo $1 | sed 's/.*=//'`
51 srcdir
=`echo $1 | sed 's/.*=//'`
67 formatExt
=$1; formatText
=$1; formatFlags
=""
69 al
) formatText
="alaw" ;;
70 ul
) formatText
="ulaw" ;;
71 wavu8
)formatText
="u8 in wav"; formatFlags
="-u -1"; formatExt
="wav" ;;
72 s1X
) formatText
="s8 (swap bits)"; formatExt
="s8"; formatFlags
="-X" ;;
73 s1N
) formatText
="s8 (swap nibbles)"; formatExt
="s8"; formatFlags
="-N" ;;
74 s1XN
) formatText
="s8 (swap nibbles & bits)"; formatExt
="s8"; formatFlags
="-X -N" ;;
79 if [ "${echo}x" != "x" ] ; then
89 if [ "${skip}x" != "x" ] ; then
90 format1_skip
=`echo ${skip} | grep ${format1}`
91 from_skip
=`echo ${skip} | grep ${1}`
93 if [ "${format1_skip}x" = "x" -a "${from_skip}x" = "x" ] ; then
94 getFormat
${format1}; format1Ext
=$formatExt; format1Text
=$formatText; format1Flags
=$formatFlags
95 getFormat
$1; format2Ext
=$formatExt; format2Text
=$formatText; format2Flags
=$formatFlags
96 execute
${bindir}/sox
${EXEEXT} $verbose -RD -r $rate -c $channels -n $format1Flags input.
$format1Ext synth
$samples's' sin
300-3300 noise trapezium
97 execute
${bindir}/sox
${EXEEXT} $verbose -RD -r $rate -c $channels $format1Flags input.
$format1Ext $format2Flags intermediate.
$format2Ext
98 execute
${bindir}/sox
${EXEEXT} $verbose -RD -r $rate -c $channels $format2Flags intermediate.
$format2Ext $format1Flags output.
$format1Ext
99 intermediateReference
=vectors
/intermediate
`echo "$channels $rate $format1Flags $format1Ext $format2Flags"|tr " " "_"`.
$format2Ext
101 # Uncomment to generate new reference files
102 # N.B. new reference files must be manually checked for correctness
103 #cp -i intermediate.$format2Ext $intermediateReference
105 if test -f $intermediateReference
107 cmp -s $intermediateReference intermediate.
$format2Ext
110 echo "*FAIL vector* channels=$channels \"$format1Text\" ---> \"$format2Text\"."
111 exit 1 # This allows failure inspection.
113 vectors
=`expr $vectors + 1`
116 if cmp -s input.
$format1Ext output.
$format1Ext
118 echo "ok channels=$channels \"$format1Text\" <--> \"$format2Text\"."
120 echo "*FAIL* channels=$channels \"$format1Text\" <--> \"$format2Text\"."
121 exit 1 # This allows failure inspection.
123 rm -f input.
$format1Ext intermediate.
$format2Ext output.
$format1Ext
129 do_multichannel_formats
() {
131 convertToAndFrom s8 u8 s16 u16 s24 u24 s32 u32 f32 f64 dat au wav aiff aifc flac caf sph wv sox
134 convertToAndFrom s16 u16 s24 u24 s32 u32 f32 f64 dat au wav aiff aifc flac caf sph wv sox
137 convertToAndFrom s24 u24 s32 u32 f32 f64 wav aiff aifc flac sph wv sox
138 (samples
=23500; convertToAndFrom paf
) ||
exit 1
141 convertToAndFrom s32 u32 f64 wav aiff aifc caf sph wv mat4 mat5 sox
144 convertToAndFrom al s16 u16 s32 f32 f64 dat aiff aifc flac caf w64
147 convertToAndFrom ul s16 u16 s32 f32 f64 dat aiff aifc flac caf sph
150 convertToAndFrom wavu8 aiff aifc au dat sf flac caf sph
153 do_twochannel_formats
() {
155 convertToAndFrom avr maud
156 (rate
=8000; convertToAndFrom voc
) ||
exit 1 # Fixed rate
157 (samples
=23492; convertToAndFrom
8svx
) ||
exit 1 # Even number of samples only
160 do_singlechannel_formats
() {
162 convertToAndFrom vox s16 u16 s24 u24 s32 u32 f32 f64 dat au wav aiff aifc flac caf sox
165 convertToAndFrom ima s16 u16 s24 u24 s32 u32 f32 f64 dat au aiff aifc flac caf
# FIXME: wav
168 convertToAndFrom smp s8 s1X s1N s1XN sndt sndr
169 #(rate=50000; convertToAndFrom txw) || exit 1 # FIXME
170 (rate
=11025; convertToAndFrom hcom
) ||
exit 1 # Fixed rates
173 (rate
=8000; convertToAndFrom al s16 u16 s32 f32 f64 dat
) ||
exit 1 # Fixed rate
176 (rate
=8000; convertToAndFrom al s16 u16 s32 f32 f64 dat
) ||
exit 1 # Fixed rate
180 egrep -v "^real |^user |^sys " $1 1>&2
181 grep "^user " $1 |
sed "s/^user //"
184 # Reading and writing performance test
185 time="/usr/bin/time -p"
187 $time ${bindir}/sox
${EXEEXT} -c $channels -r $rate -n tmp.sox synth
$samples's' saw
0:`expr $rate / 2` noise brown vol
.9 2> tmp.
write
188 echo TIME synth channels
=$channels samples
=$samples `stderr_time tmp.write`s
189 if [ `uname` != SunOS
]; then
190 while [ $# != 0 ]; do
191 if [ "${skip}x" != "x" ] ; then
192 from_skip
=`echo ${skip} | grep ${1}`
194 if [ "${from_skip}x" = "x" ] ; then
196 ($time ${bindir}/sox
${EXEEXT} $verbose -D tmp.sox
$formatFlags -t $1 - 2> tmp.
read) | \
197 ($time ${bindir}/sox
${EXEEXT} $verbose -t $1 -c $channels -r $rate - -t sox
/dev
/null
2> tmp.
write)
198 echo "TIME `printf %4s $formatText` write=`stderr_time tmp.write`s read=`stderr_time tmp.read`s"
203 rm -f tmp.sox tmp.
write tmp.
read
206 # Don't try to test un-built formats
208 while [ $# -ne 0 ]; do
209 ${bindir}/sox
${EXEEXT} --help|
grep "^AUDIO FILE.*\<$1\>">/dev
/null || skip
="$1 $skip"
217 ${builddir}/sox_sample_test
${EXEEXT} ||
exit 1
219 skip_check caf flac mat4 mat5 paf w64 wv
227 do_multichannel_formats
230 if [ "$all" = "all" ]; then
231 do_multichannel_formats
233 do_twochannel_formats
234 format1
=cdda
# 2-channel only
235 convertToAndFrom s16 u24 aiff
238 if [ "$all" = "all" ]; then
239 do_multichannel_formats
240 do_twochannel_formats
242 do_singlechannel_formats
244 if false
; then # needs skip & dir work for general use
245 ${srcdir}/test-comments
246 if [ $?
-eq 0 ]; then
249 echo "*FAIL* comments"
254 ${bindir}/sox
${EXEEXT} -c 1 -r 44100 -n output.u8 synth
.01 vol
.5
255 if [ `wc -c <output.u8` = 441 ]; then
258 echo "*FAIL* synth size"
262 echo "Checked $vectors vectors"
266 timeIO s8 u8 s16 u16 s24 u24 s32 u32 f32 f64 au wav aiff aifc sph
# FIXME?: caf flac dat
268 test -n "$skip" && echo "Skipped: $skip"
270 # Run one last command so return code is not error
271 # when $skip is empty.