annotate constant-q-cpp/test/test-inverse.sh @ 372:af71cbdab621 tip

Update bqvec code
author Chris Cannam
date Tue, 19 Nov 2019 10:13:32 +0000
parents 5d0a2ebb4d17
children
rev   line source
Chris@366 1 #!/bin/bash
Chris@366 2
Chris@366 3 # Test that the forward-inverse CQ transform produces the same output
Chris@366 4 # (to a given noise level, and within the appropriate frequency range)
Chris@366 5 # as its input.
Chris@366 6 #
Chris@366 7 # This requires the program "processfile" to be compiled and in the
Chris@366 8 # same directory, and an audio file filtered-whitenoise-480-14600.wav
Chris@366 9 # to be in the subdir "data". The audio file contains white noise
Chris@366 10 # band-limited to the 480-14600Hz range. This is fed as input to a
Chris@366 11 # forward-inverse CQ chain restricted to the range 465-14700 Hz (5
Chris@366 12 # octaves); the processfile program calculates the output and performs
Chris@366 13 # a sample-by-sample diff against the input. We then check that the
Chris@366 14 # diff is below a suitable noise floor.
Chris@366 15
Chris@366 16 mydir=`dirname "$0"`
Chris@366 17
Chris@366 18 process="$mydir/processfile"
Chris@366 19 if [ ! -x "$process" ]; then
Chris@366 20 echo "ERROR: $mydir/processfile not found or not executable"
Chris@366 21 exit 1
Chris@366 22 fi
Chris@366 23 infile="$mydir/data/filtered-whitenoise-480-14600.wav"
Chris@366 24 if [ ! -f "$infile" ]; then
Chris@366 25 echo "ERROR: Test file $infile not found"
Chris@366 26 exit 1
Chris@366 27 fi
Chris@366 28
Chris@366 29 outfile="/tmp/$$.out.wav"
Chris@366 30 difffile="/tmp/$$.diff.wav"
Chris@366 31 logfile="/tmp/$$.log.txt"
Chris@366 32 trap "rm -f ${outfile} ${difffile} ${logfile}" 0
Chris@366 33
Chris@366 34 "$process" -x 14700 -n 465 -b 36 "$infile" "$outfile" "$difffile" 2>&1 | tee "$logfile" || exit 1
Chris@366 35
Chris@366 36 int_db=`grep 'max diff' "$logfile" | sed 's/^[^(]*(//' | sed 's/[^0-9-].*//'`
Chris@366 37 good=`expr "$int_db" "<" "-20"`
Chris@366 38 if [ "$good" == "1" ]; then
Chris@366 39 echo "Forward-inverse process is satisfactory"
Chris@366 40 exit 0
Chris@366 41 else
Chris@366 42 echo "Forward-inverse not OK: Rounded dB value $int_db is too high -- should be < -20"
Chris@366 43 exit 1
Chris@366 44 fi
Chris@366 45