annotate test/test-inverse.sh @ 196:da283326bcd3 tip master

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