annotate testdata/evaluation/run.sh @ 204:544b45e92ef5

Translate saxophone instrument to tenorsax; call make before running!
author Chris Cannam
date Wed, 04 Jun 2014 12:24:47 +0100
parents 607c3c92822f
children 7cb021e40732
rev   line source
Chris@72 1 #!/bin/sh
Chris@72 2
Chris@72 3 trios_path="/home/cannam/Music/TRIOS_dataset"
Chris@139 4 yc="/home/cannam/code/may/bin/yc"
Chris@72 5
Chris@72 6 if [ ! -d "$trios_path" ]; then
Chris@72 7 echo "TRIOS dataset directory $trios_path not found, giving up"
Chris@72 8 exit 1
Chris@72 9 fi
Chris@72 10
Chris@139 11 if ! "$yc" -v ; then
Chris@139 12 echo "Failed to run Yeti compiler yc at $yc_path, giving up";
Chris@139 13 fi
Chris@139 14
Chris@72 15 if ! sonic-annotator -v ; then
Chris@72 16 echo "Failed to run sonic-annotator (not in PATH?), giving up"
Chris@72 17 exit 1
Chris@72 18 fi
Chris@72 19
Chris@194 20 rdffile="../../silvet.n3"
Chris@193 21 if [ ! -f "$rdffile" ] ; then
Chris@194 22 echo "Failed to find plugin RDF file at $rdffile, giving up"
Chris@194 23 exit 1
Chris@194 24 fi
Chris@193 25
Chris@193 26 case "$trios_path" in
Chris@194 27 *\ *) echo "TRIOS dataset path $trios_path has a space in it, this script won't handle that"; exit 1;;
Chris@193 28 esac
Chris@193 29
Chris@204 30 ( cd ../.. ; make -f Makefile.linux ) || exit 1
Chris@204 31
Chris@72 32 VAMP_PATH=../..
Chris@72 33 export VAMP_PATH
Chris@72 34
Chris@139 35 outfile="/tmp/$$"
Chris@139 36
Chris@149 37 tmpwav="/tmp/$$norm.wav"
Chris@149 38
Chris@193 39 instfile="/tmp/$$instruments.txt"
Chris@149 40
Chris@197 41 transfile="/tmp/$$transform.ttl"
Chris@197 42
Chris@197 43 trap 'rm -f "$outfile" "$tmpwav" "$instfile" "$transfile" "$outfile.lab"' 0
Chris@142 44
Chris@193 45 # Use the mix and single-instrument non-synthetic files for a (varied)
Chris@195 46 # subset of the TRIOS dataset. Omit percussion (but we still use the
Chris@195 47 # Take Five example, even though it's largely percussion, because it's
Chris@195 48 # a good test of how we do with other instruments in the presence of
Chris@195 49 # percussion).
Chris@195 50 infiles=`find "$trios_path" -name \*.wav -print | egrep '(mozart|lussier|take_five)' | grep -v _syn.wav | grep -v kick.wav | grep -v ride.wav | grep -v snare.wav`
Chris@72 51
Chris@193 52 grep Piano "$rdffile" | sed 's/^.*( *//' | sed 's/ *).*$//' | sed 's/ "/\n/g' | sed 's/"//g' | tr '[A-Z]' '[a-z]' | tail -n +2 | cat -n > "$instfile"
Chris@193 53
Chris@193 54 instrument_for() {
Chris@194 55 filename="$1"
Chris@193 56 base=`basename "$filename" .wav`
Chris@204 57 if [ "$base" = "saxophone" ]; then base="tenorsax"; fi
Chris@193 58 instrument_no=`grep "$base" "$instfile" | awk '{ print $1; }'`
Chris@194 59 if [ -z "$instrument_no" ] || [ -z "$base" ];
Chris@193 60 then echo 0
Chris@193 61 else echo "$instrument_no"
Chris@193 62 fi
Chris@193 63 }
Chris@193 64
Chris@194 65 echo
Chris@194 66 echo "Input files are:"
Chris@194 67 echo $infiles | fmt -1
Chris@194 68
Chris@195 69 time for infile in $infiles; do
Chris@193 70
Chris@193 71 echo
Chris@193 72 echo "Evaluating for file $infile..."
Chris@193 73
Chris@193 74 instrument=`instrument_for "$infile"`
Chris@193 75 case "$instrument" in
Chris@193 76 [0-9]*) ;;
Chris@193 77 *) echo "Instrument extraction failed for infile $infile -- not even default multi-instrument setting returned?"; exit 1;;
Chris@193 78 esac
Chris@194 79
Chris@194 80 piece=`basename \`dirname "$infile" \``
Chris@194 81 arrangement=`basename "$infile" .wav`
Chris@193 82
Chris@193 83 echo
Chris@194 84 echo "For piece $piece, arrangement $arrangement, using instrument $instrument..."
Chris@193 85
Chris@193 86 sox "$infile" "$tmpwav" gain -n -6.020599913279624
Chris@193 87
Chris@197 88 # generate the transform by interpolating the instrument parameter
Chris@197 89 cat transform.ttl | sed "s/INSTRUMENT_PARAMETER/$instrument/" > "$transfile"
Chris@193 90
Chris@194 91 sonic-annotator \
Chris@193 92 --writer csv \
Chris@193 93 --csv-one-file "$outfile" \
Chris@193 94 --csv-force \
Chris@197 95 --transform "$transfile" \
Chris@193 96 "$tmpwav"
Chris@193 97
Chris@193 98 cat "$outfile" | \
Chris@193 99 sed 's/^[^,]*,//' | \
Chris@193 100 while IFS=, read start duration frequency level label; do
Chris@193 101 end=`echo "$start $duration + p" | dc`
Chris@193 102 echo -e "$start\t$end\t$frequency"
Chris@139 103 done > "$outfile.lab"
Chris@139 104
Chris@193 105 for ms in 50 100; do
Chris@195 106 mark=""
Chris@201 107 if [ "$ms" = "50" ]; then mark=" <-- main $piece/$arrangement"; fi;
Chris@193 108 echo
Chris@193 109 echo "Validating against ground truth at $ms ms:"
Chris@201 110 "$yc" ./evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "$outfile.lab" | sed 's,$,'"$mark"','
Chris@193 111 echo
Chris@193 112 echo "Validating against MIREX submission at $ms ms:"
Chris@193 113 "$yc" ./evaluate_lab.yeti "$ms" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab" "$outfile.lab"
Chris@193 114 echo
Chris@193 115 echo "Validating MIREX against ground truth at $ms ms":
Chris@193 116 "$yc" ./evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab"
Chris@193 117 done;
Chris@193 118
Chris@139 119 echo
Chris@193 120 done