shithub: sox

Download patch

ref: c8db526e46b42874a96c3d6f7324f2ffa62962c6
parent: c5ec8339bbe78ae56cd99dc43072d9bff0e0fb96
author: robs <robs>
date: Thu Jun 26 03:57:36 EDT 2008

more tests

--- a/src/test-srcs
+++ b/src/test-srcs
@@ -1,8 +1,8 @@
 #!/bin/sh
 
-# Sample rate conversion tests.  Create a 30s sweep of 0-48kHz @ 96kHz sampling
-# rate, then use each resampler to convert it to 44.1kHz.  Display the results
-# in a PNG file for each converter.
+# 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
@@ -9,9 +9,6 @@
 SSRC_PATH=/usr/local/bin         # Path to the two ssrc executables
 
 RANGE=180
-if [ "$1" -ne "" ]; then
-  RANGE="$1"
-fi
 
 # Temporary files
 IN=/tmp/$0-in-$$.wav
@@ -18,32 +15,37 @@
 OUT=/tmp/$0-out-$$.wav
 TIME=/tmp/$0-time-$$.wav
 
-# Create input file
-$SOX -r96k -n -twavpcm $IN synth 30 sin 0~48k gain -1 
+test_converters () {
+  # Create input file
+  $SOX -r $1 -n -twavpcm $IN synth 20 sin 0~`expr $1 / 2` gain -2 
+  for src in \
+      "polyphase" \
+      "rabbit -c0" \
+      "rabbit -c1" \
+      "rate -h" \
+      "rate -v" \
+      "resample -q" \
+      "resample -ql" \
+      "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 each one
-for src in \
-    "polyphase" \
-    "rabbit -c0" \
-    "rabbit -c1" \
-    "rate -h" \
-    "rate -v" \
-    "resample -q" \
-    "resample -ql" \
-    "ssrc" \
-    "ssrc_hp" \
-    ; do
-  echo $src
-  case "$src" in
-    ssrc*) time -f %U -o $TIME $SSRC_PATH/$src --quiet --rate 44100 $IN $OUT;;
-    *)     time -f %U -o $TIME $SOX $IN -r 44.1k $OUT $src;;
-  esac
-  t=`cat $TIME`
-  $SOX $OUT -n spectrogram \
-    -x 20 -z $RANGE -w kaiser \
-    -t " $src " -c "${t}s user time" \
-    -o "spectrogram-`echo $src | tr ' ' '_'`.png"
-done
-
-# Clean up
-rm -f $IN $OUT $TIME
+test_converters 11025 48000
+test_converters 22000 96100
+test_converters 44100 96000
+test_converters 96000 44100
+#test_converters 96000 8000 # rabbit hangs