comparison testdata/evaluation/run-singleinstrumenttest.sh @ 210:2b3c6d53c1f1

Some single-instrument tests
author Chris Cannam
date Mon, 30 Jun 2014 11:38:12 +0100
parents
children 7cb021e40732
comparison
equal deleted inserted replaced
209:d315e946c5fc 210:2b3c6d53c1f1
1 #!/bin/sh
2
3 trios_path="/home/cannam/Music/TRIOS_dataset"
4 yc="/home/cannam/code/may/bin/yc"
5
6 if [ ! -d "$trios_path" ]; then
7 echo "TRIOS dataset directory $trios_path not found, giving up"
8 exit 1
9 fi
10
11 if ! "$yc" -v ; then
12 echo "Failed to run Yeti compiler yc at $yc_path, giving up";
13 fi
14
15 if ! sonic-annotator -v ; then
16 echo "Failed to run sonic-annotator (not in PATH?), giving up"
17 exit 1
18 fi
19
20 rdffile="../../silvet.n3"
21 if [ ! -f "$rdffile" ] ; then
22 echo "Failed to find plugin RDF file at $rdffile, giving up"
23 exit 1
24 fi
25
26 case "$trios_path" in
27 *\ *) echo "TRIOS dataset path $trios_path has a space in it, this script won't handle that"; exit 1;;
28 esac
29
30 ( cd ../.. ; make -f Makefile.linux ) || exit 1
31
32 VAMP_PATH=../..
33 export VAMP_PATH
34
35 outfile="/tmp/$$"
36
37 tmpwav="/tmp/$$norm.wav"
38
39 instfile="/tmp/$$instruments.txt"
40
41 transfile="/tmp/$$transform.ttl"
42
43 trap 'rm -f "$outfile" "$tmpwav" "$instfile" "$transfile" "$outfile.lab"' 0
44
45 # Use the single-instrument monophonic non-synthetic files for a
46 # (varied) subset of the TRIOS dataset. We take only those instruments
47 # for which we have a preset available
48 infiles="$trios_path/lussier/bassoon.wav $trios_path/take_five/saxophone.wav $trios_path/schubert/violin.wav $trios_path/mozart/clarinet.wav"
49
50 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"
51
52 instrument_for() {
53 filename="$1"
54 base=`basename "$filename" .wav`
55 if [ "$base" = "saxophone" ]; then base="tenorsax"; fi
56 instrument_no=`grep "$base" "$instfile" | awk '{ print $1; }'`
57 if [ -z "$instrument_no" ] || [ -z "$base" ];
58 then echo 0
59 else echo "$instrument_no"
60 fi
61 }
62
63 echo
64 echo "Input files are:"
65 echo $infiles | fmt -1
66
67 time for infile in $infiles; do
68
69 echo
70 echo "Evaluating for file $infile..."
71
72 intended_instrument=`instrument_for "$infile"`
73 case "$intended_instrument" in
74 [0-9]*) ;;
75 *) echo "Instrument extraction failed for infile $infile -- not even default multi-instrument setting returned?"; exit 1;;
76 esac
77
78 piece=`basename \`dirname "$infile" \``
79 arrangement=`basename "$infile" .wav`
80
81 # We run this twice, once using the default instrument
82 # (i.e. "multiple or unknown") and once using the intended
83 # instrument preset (the solo one).
84
85 for instrument in $intended_instrument 0; do
86
87 echo
88 echo "For piece $piece, arrangement $arrangement, using instrument $instrument..."
89
90 sox "$infile" "$tmpwav" gain -n -6.020599913279624
91
92 # generate the transform by interpolating the instrument parameter
93 cat transform.ttl | sed "s/INSTRUMENT_PARAMETER/$instrument/" > "$transfile"
94
95 sonic-annotator \
96 --writer csv \
97 --csv-one-file "$outfile" \
98 --csv-force \
99 --transform "$transfile" \
100 "$tmpwav"
101
102 cat "$outfile" | \
103 sed 's/^[^,]*,//' | \
104 while IFS=, read start duration frequency level label; do
105 end=`echo "$start $duration + p" | dc`
106 echo -e "$start\t$end\t$frequency"
107 done > "$outfile.lab"
108
109 for ms in 50 100; do
110 mark=""
111 if [ "$ms" = "50" ]; then mark=" <-- main $piece/$arrangement"; fi;
112 echo
113 echo "Validating against ground truth at $ms ms:"
114 "$yc" ./evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "$outfile.lab" | sed 's,$,'"$mark"','
115 echo
116 echo "Validating against MIREX submission at $ms ms:"
117 "$yc" ./evaluate_lab.yeti "$ms" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab" "$outfile.lab"
118 echo
119 echo "Validating MIREX against ground truth at $ms ms":
120 "$yc" ./evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab"
121 done;
122
123 echo
124 done
125 done