To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
The primary repository for this project is hosted at https://github.com/cannam/constant-q-cpp/ .
This repository is a read-only copy which is updated automatically every hour.
root / test / test-inverse.sh
History | View | Annotate | Download (1.5 KB)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
|
| 3 |
# Test that the forward-inverse CQ transform produces the same output |
| 4 |
# (to a given noise level, and within the appropriate frequency range) |
| 5 |
# as its input. |
| 6 |
# |
| 7 |
# This requires the program "processfile" to be compiled and in the |
| 8 |
# same directory, and an audio file filtered-whitenoise-480-14600.wav |
| 9 |
# to be in the subdir "data". The audio file contains white noise |
| 10 |
# band-limited to the 480-14600Hz range. This is fed as input to a |
| 11 |
# forward-inverse CQ chain restricted to the range 465-14700 Hz (5 |
| 12 |
# octaves); the processfile program calculates the output and performs |
| 13 |
# a sample-by-sample diff against the input. We then check that the |
| 14 |
# diff is below a suitable noise floor. |
| 15 |
|
| 16 |
mydir=`dirname "$0"` |
| 17 |
|
| 18 |
process="$mydir/processfile" |
| 19 |
if [ ! -x "$process" ]; then |
| 20 |
echo "ERROR: $mydir/processfile not found or not executable" |
| 21 |
exit 1 |
| 22 |
fi |
| 23 |
infile="$mydir/data/filtered-whitenoise-480-14600.wav" |
| 24 |
if [ ! -f "$infile" ]; then |
| 25 |
echo "ERROR: Test file $infile not found" |
| 26 |
exit 1 |
| 27 |
fi |
| 28 |
|
| 29 |
outfile="/tmp/$$.out.wav" |
| 30 |
difffile="/tmp/$$.diff.wav" |
| 31 |
logfile="/tmp/$$.log.txt" |
| 32 |
trap "rm -f ${outfile} ${difffile} ${logfile}" 0
|
| 33 |
|
| 34 |
"$process" -x 14700 -n 465 -b 36 "$infile" "$outfile" "$difffile" 2>&1 | tee "$logfile" || exit 1 |
| 35 |
|
| 36 |
int_db=`grep 'max diff' "$logfile" | sed 's/^[^(]*(//' | sed 's/[^0-9-].*//'` |
| 37 |
good=`expr "$int_db" "<" "-20"` |
| 38 |
if [ "$good" == "1" ]; then |
| 39 |
echo "Forward-inverse process is satisfactory" |
| 40 |
exit 0 |
| 41 |
else |
| 42 |
echo "Forward-inverse not OK: Rounded dB value $int_db is too high -- should be < -20" |
| 43 |
exit 1 |
| 44 |
fi |
| 45 |
|