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