c@142: #!/bin/bash c@143: c@143: # Test that the forward-inverse CQ transform produces the same output c@143: # (to a given noise level, and within the appropriate frequency range) c@143: # as its input. c@143: # c@143: # This requires the program "processfile" to be compiled and in the c@143: # same directory, and an audio file filtered-whitenoise-480-14600.wav c@143: # to be in the subdir "data". The audio file contains white noise c@143: # band-limited to the 480-14600Hz range. This is fed as input to a c@143: # forward-inverse CQ chain restricted to the range 465-14700 Hz (5 c@143: # octaves); the processfile program calculates the output and performs c@143: # a sample-by-sample diff against the input. We then check that the c@143: # diff is below a suitable noise floor. c@143: c@142: mydir=`dirname "$0"` c@143: c@142: process="$mydir/processfile" c@142: if [ ! -x "$process" ]; then c@142: echo "ERROR: $mydir/processfile not found or not executable" c@142: exit 1 c@142: fi c@142: infile="$mydir/data/filtered-whitenoise-480-14600.wav" c@142: if [ ! -f "$infile" ]; then c@142: echo "ERROR: Test file $infile not found" c@142: exit 1 c@142: fi c@143: c@142: outfile="/tmp/$$.out.wav" c@142: difffile="/tmp/$$.diff.wav" c@142: logfile="/tmp/$$.log.txt" c@142: trap "rm -f ${outfile} ${difffile} ${logfile}" 0 c@143: c@142: "$process" -x 14700 -n 465 -b 36 "$infile" "$outfile" "$difffile" 2>&1 | tee "$logfile" || exit 1 c@143: c@142: int_db=`grep 'max diff' "$logfile" | sed 's/^[^(]*(//' | sed 's/[^0-9-].*//'` c@142: good=`expr "$int_db" "<" "-20"` c@142: if [ "$good" == "1" ]; then c@142: echo "Forward-inverse process is satisfactory" c@142: exit 0 c@142: else c@142: echo "Forward-inverse not OK: Rounded dB value $int_db is too high -- should be < -20" c@142: exit 1 c@142: fi c@142: