#!/bin/sh# Sample rate conversion tests. Create a 20s sweep at the input sampling rate,# then use each resampler to convert it to the output rate. Display the results# in a PNG file for each conversion.# Set up the following two before running the script:SOX=./sox # The actual sox executableSSRC_PATH=/usr/local/bin # Path to the two ssrc executablesRANGE=180# Temporary filesBASE=`basename $0`IN=/tmp/$BASE-in-$$.wavOUT=/tmp/$BASE-out-$$.wavTIME=/tmp/$BASE-time-$$.wavtest_converters () { # Create input file max=`expr $1 / 2` $SOX -r $1 -n -twavpcm $IN synth 20 sin 0:$max sin $max:0 gain -2 for src in \ "rate -h" \ "rate -v" \ "ssrc" \ "ssrc_hp" \ ; do echo $src case "$src" in ssrc*) time -f %U -o $TIME $SSRC_PATH/$src --quiet --rate $2 $IN $OUT;; *) time -f %U -o $TIME $SOX $IN -r $2 $OUT $src;; esac t=`cat $TIME` $SOX $OUT -n spectrogram \ -X 30 -z $RANGE -w kaiser \ -t "$1->$2: $src" -c "${t}s user time" \ -o "$1_$2_`echo $src | tr ' ' '_'`.png" done rm -f $IN $OUT $TIME # Clean up}test_converters 11025 48000test_converters 22000 96100test_converters 44100 96000test_converters 96000 44100test_converters 96000 8000 # rabbit 0.1.3 hangs, 0.1.4 is okay
#!/bin/sh
# Sample rate conversion tests. Create a 20s sweep at the input sampling rate,
# then use each resampler to convert it to the output rate. Display the results
# in a PNG file for each conversion.
# Set up the following two before running the script:
SOX=./sox # The actual sox executable
SSRC_PATH=/usr/local/bin # Path to the two ssrc executables
RANGE=180
# Temporary files
BASE=`basename $0`
IN=/tmp/$BASE-in-$$.wav
OUT=/tmp/$BASE-out-$$.wav
TIME=/tmp/$BASE-time-$$.wav
test_converters () {
# Create input file
max=`expr $1 / 2`
$SOX -r $1 -n -twavpcm $IN synth 20 sin 0:$max sin $max:0 gain -2
for src in \
"rate -h" \
"rate -v" \
"ssrc" \
"ssrc_hp" \
; do
echo $src
case "$src" in
ssrc*) time -f %U -o $TIME $SSRC_PATH/$src --quiet --rate $2 $IN $OUT;;
*) time -f %U -o $TIME $SOX $IN -r $2 $OUT $src;;
esac
t=`cat $TIME`
$SOX $OUT -n spectrogram \
-X 30 -z $RANGE -w kaiser \
-t "$1->$2: $src" -c "${t}s user time" \
-o "$1_$2_`echo $src | tr ' ' '_'`.png"
done
rm -f $IN $OUT $TIME # Clean up
}
test_converters 11025 48000
test_converters 22000 96100
test_converters 44100 96000
test_converters 96000 44100
test_converters 96000 8000 # rabbit 0.1.3 hangs, 0.1.4 is okay