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@303
|
82
|
Chris@363
|
83 # Change this to the processing mode you want to test (e.g. 0 for live)
|
Chris@269
|
84 mode=1
|
Chris@193
|
85
|
Chris@193
|
86 echo
|
Chris@194
|
87 echo "For piece $piece, arrangement $arrangement, using instrument $instrument..."
|
Chris@193
|
88
|
Chris@193
|
89 sox "$infile" "$tmpwav" gain -n -6.020599913279624
|
Chris@193
|
90
|
Chris@197
|
91 # generate the transform by interpolating the instrument parameter
|
Chris@269
|
92 cat transform.ttl | \
|
Chris@269
|
93 sed "s/INSTRUMENT_PARAMETER/$instrument/" | \
|
Chris@269
|
94 sed "s/MODE_PARAMETER/$mode/" > "$transfile"
|
Chris@193
|
95
|
Chris@194
|
96 sonic-annotator \
|
Chris@193
|
97 --writer csv \
|
Chris@193
|
98 --csv-one-file "$outfile" \
|
Chris@193
|
99 --csv-force \
|
Chris@197
|
100 --transform "$transfile" \
|
Chris@325
|
101 "$tmpwav" 2>/dev/null
|
Chris@193
|
102
|
Chris@193
|
103 cat "$outfile" | \
|
Chris@193
|
104 sed 's/^[^,]*,//' | \
|
Chris@193
|
105 while IFS=, read start duration frequency level label; do
|
Chris@193
|
106 end=`echo "$start $duration + p" | dc`
|
Chris@193
|
107 echo -e "$start\t$end\t$frequency"
|
Chris@139
|
108 done > "$outfile.lab"
|
Chris@139
|
109
|
Chris@193
|
110 for ms in 50 100; do
|
Chris@195
|
111 mark=""
|
Chris@201
|
112 if [ "$ms" = "50" ]; then mark=" <-- main $piece/$arrangement"; fi;
|
Chris@193
|
113 echo
|
Chris@193
|
114 echo "Validating against ground truth at $ms ms:"
|
Chris@233
|
115 "$yc" ../scripts/evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "$outfile.lab" | sed 's,$,'"$mark"','
|
Chris@193
|
116 echo
|
Chris@193
|
117 echo "Validating against MIREX submission at $ms ms:"
|
Chris@233
|
118 "$yc" ../scripts/evaluate_lab.yeti "$ms" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab" "$outfile.lab"
|
Chris@193
|
119 echo
|
Chris@193
|
120 echo "Validating MIREX against ground truth at $ms ms":
|
Chris@233
|
121 "$yc" ../scripts/evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab"
|
Chris@193
|
122 done;
|
Chris@193
|
123
|
Chris@139
|
124 echo
|
Chris@193
|
125 done
|