test script updates

master
Rob Sykes 2015-08-19 17:04:32 +01:00
parent 91455fc7c0
commit 18c2829a75
4 changed files with 151 additions and 15 deletions

View File

@ -4,6 +4,10 @@ set -e
# SoX Resampler Library Copyright (c) 2007-14 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# Exercise each example programme:
len=8
#vg="valgrind --leak-check=full --show-reachable=yes"
@ -32,19 +36,9 @@ rm *.f32
# Check conversion between differing I/O types, but no rate-change:
for i in 1 2 3; do
prev=""
sox -n -c $i 0.f32 synth $len gain -.1
./3-options-input-fn 1 1 $i 0 2 < 0.f32 | ./3-options-input-fn 1 1 $i 2 0 > 1.f32
cmp [01].f32
done
rm *.f32
# Exercise VR making sure that varied internal stage reconfigurations occur:
rm -f ?.png
rm -f v?.png
for n in 0 1 2 3; do
$vg ./5-variable-rate $n | sox -tf32 -r44100 -c1 - -n spectrogram -z130 -hwd -o $n.png -X 50
$vg ./5-variable-rate $n | sox -tf32 -r44100 -c1 - -n spectrogram -z130 -hwd -o v$n.png -X 50
vg=""
done

View File

@ -1,7 +1,13 @@
#!/bin/bash
set -e
# SoX Resampler Library Copyright (c) 2007-13 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# Tests IO
ir=96000
or=44100
len=16
@ -13,13 +19,13 @@ types=(f32 f64 s32 s16)
do_one() {
$ex $ir $or $c $1 $2 $3 < $c.${types[$1]} |
sox -t ${types[$2]} -r $or -c $c - -n spectrogram -X50 -hwk -z180 -o io$n$c.png
sox -t ${types[$2]} -r $or -c $c - -n spectrogram -X50 -hwk -z180 -o io$c$n.png
n=`expr $n + 1`
}
rm io??.png
rm -f io??.png
j=2; test z$1 != z && j=$1
j=3; test z$1 != z && j=$1
for c in `seq 1 $j`; do
for n in `seq 0 3`; do
@ -38,3 +44,15 @@ for c in `seq 1 $j`; do
done
rm ?.[sf][0-9][0-9]
# Check conversion between differing I/O types, but no rate-change:
for i in 1 2 3; do
prev=""
sox -n -c $i 0.f32 synth $len gain -.1
$ex 1 1 $i 0 2 < 0.f32 | $ex 1 1 $i 2 0 > 1.f32
cmp [01].f32
done
rm *.f32

37
tests/phase-test 100755
View File

@ -0,0 +1,37 @@
#!/bin/bash
set -e
# SoX Resampler Library Copyright (c) 2007-14 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# Tests varying phase-response.
rm -f ph-*.png
tool=./3-options-input-fn
spec="spectrogram -z180 -Z-20 -wd -ho"
ext=f32; e=0
rate1=48000
rate2=44100
for n in 1 2; do
sox -r $rate1 -n 0.$ext synth 1s sq pad .03 .03 gain -1
for q in `seq 0 7`; do
f=ph-$rate2-q$q
$tool $rate1 $rate2 1 $e $e $q'6' < 0.$ext | sox -c1 -r$rate2 -t $ext - -n $spec $f.png -X 2000
done
for q in `seq 0 10`; do
f=ph-$rate2-p`printf %02u $q`
$tool $rate1 $rate2 1 $e $e 46 0 0 0 $q'0' < 0.$ext | sox -c1 -r$rate2 -t $ext - -n $spec $f.png -X 2000
done
r=$rate1; rate1=$rate2; rate2=$r
done
rm 0.$ext

87
tests/q-test 100755
View File

@ -0,0 +1,87 @@
#!/bin/bash
set -e
# SoX Resampler Library Copyright (c) 2007-14 robs@users.sourceforge.net
# Licence for this file: LGPL v2.1 See LICENCE for details.
# Tests rate conversion time and generates spectrograms for qualities 0..7 & variable-rate.
rm -f *.png *.wav
tool=./3-options-input-fn
spec="spectrogram -z180 -Z-20 -wd -ho"
ext=f32; e=0
ext=f64; e=1
c=2
q1=4; q2=4
q1=0; q2=7
rates=48000
rates="48000 77773 96000"
for rate0 in $rates; do
rate1=$rate0
rate2=44100
for n in 1 2; do
rate1n=`expr $rate1 / 2`
# Measure time to convert a 5-minute file:
#: << :
sox -r $rate1 -n -c $c 0.$ext synth 5: sin 0:$rate1n gain -1
for q in `seq $q1 $q2`; do
echo $rate1 '-->' $rate2 c=$c q=$q
time $tool $rate1 $rate2 $c $e $e $q < 0.$ext > /dev/null;
done
echo $rate1 '-->' $rate2 c=$c q=v
time $tool $rate1 $rate2 $c $e $e 4 20 < 0.$ext > /dev/null
:
# Convert sweep, for spectrogram:
sox -r $rate1 -n -c $c 0.$ext synth 8 sin 0:$rate1n gain -1
for q in `seq $q1 $q2`; do
f=$rate1-$rate2-a-$q
$tool $rate1 $rate2 $c $e $e $q 0 < 0.$ext | sox -c$c -r$rate2 -t $ext - -n $spec $f.png
done
f=$rate1-$rate2-a-v
$tool $rate1 $rate2 $c $e $e 4 20 < 0.$ext | sox -c$c -r$rate2 -t $ext - -n $spec $f.png
# Convert impulse, for spectrogram:
#: << :
sox -r $rate1 -n 0.$ext synth 1s sq pad .03 .03 gain -1
for q in `seq $q1 $q2`; do
f=$rate1-$rate2-b-$q
$tool $rate1 $rate2 1 $e $e $q 0 < 0.$ext | sox -c1 -r$rate2 -t $ext - $f.wav $spec $f.png -X 2000
done
f=$rate1-$rate2-b-v
$tool $rate1 $rate2 1 $e $e 4 20 < 0.$ext | sox -c1 -r$rate2 -t $ext - $f.wav $spec $f.png -X 2000
# Combine impuse responses into multi-channel file (for inspection in Audacity):
sox -M $rate1-$rate2-b-?.wav $rate1-$rate2.wav
rm $rate1-$rate2-b-?.wav
:
rate1=44100
rate2=$rate0
done
done
rm 0.$ext