Chris@247: #!/bin/sh Chris@247: Chris@247: trios_path="/home/cannam/Music/TRIOS_dataset" Chris@247: yc="/home/cannam/code/may/bin/yc" Chris@247: Chris@247: if [ ! -d "$trios_path" ]; then Chris@247: echo "TRIOS dataset directory $trios_path not found, giving up" Chris@247: exit 1 Chris@247: fi Chris@247: Chris@247: if ! "$yc" -v ; then Chris@247: echo "Failed to run Yeti compiler yc at $yc_path, giving up"; Chris@247: fi Chris@247: Chris@247: if ! sonic-annotator -v ; then Chris@247: echo "Failed to run sonic-annotator (not in PATH?), giving up" Chris@247: exit 1 Chris@247: fi Chris@247: Chris@247: rdffile="../../silvet.n3" Chris@247: if [ ! -f "$rdffile" ] ; then Chris@247: echo "Failed to find plugin RDF file at $rdffile, giving up" Chris@247: exit 1 Chris@247: fi Chris@247: Chris@247: case "$trios_path" in Chris@247: *\ *) echo "TRIOS dataset path $trios_path has a space in it, this script won't handle that"; exit 1;; Chris@247: esac Chris@247: Chris@247: ( cd ../.. ; make -f Makefile.linux ) || exit 1 Chris@247: Chris@247: VAMP_PATH=../.. Chris@247: export VAMP_PATH Chris@247: Chris@247: outfile="/tmp/$$" Chris@247: Chris@247: tmpwav="/tmp/$$norm.wav" Chris@247: Chris@247: instfile="/tmp/$$instruments.txt" Chris@247: Chris@247: transfile="/tmp/$$transform.ttl" Chris@247: Chris@247: trap 'rm -f "$outfile" "$tmpwav" "$instfile" "$transfile" "$outfile.lab"' 0 Chris@247: Chris@247: # Use the mix and single-instrument non-synthetic files for a (varied) Chris@247: # subset of the TRIOS dataset. Omit percussion (but we still use the Chris@247: # Take Five example, even though it's largely percussion, because it's Chris@247: # a good test of how we do with other instruments in the presence of Chris@247: # percussion). Chris@247: 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@247: Chris@247: 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@247: Chris@247: instrument_for() { Chris@247: filename="$1" Chris@247: base=`basename "$filename" .wav` Chris@247: if [ "$base" = "saxophone" ]; then base="tenorsax"; fi Chris@247: instrument_no=`grep "$base" "$instfile" | awk '{ print $1; }'` Chris@247: if [ -z "$instrument_no" ] || [ -z "$base" ]; Chris@247: then echo 0 Chris@247: else echo "$instrument_no" Chris@247: fi Chris@247: } Chris@247: Chris@247: echo Chris@247: echo "Input files are:" Chris@247: echo $infiles | fmt -1 Chris@247: Chris@247: time for infile in $infiles; do Chris@247: Chris@247: echo Chris@247: echo "Evaluating for file $infile..." Chris@247: Chris@247: instrument=`instrument_for "$infile"` Chris@247: case "$instrument" in Chris@247: [0-9]*) ;; Chris@247: *) echo "Instrument extraction failed for infile $infile -- not even default multi-instrument setting returned?"; exit 1;; Chris@247: esac Chris@247: Chris@247: piece=`basename \`dirname "$infile" \`` Chris@247: arrangement=`basename "$infile" .wav` Chris@247: Chris@269: for mode in 1 0; do Chris@269: Chris@269: echo Chris@269: echo "For piece $piece, arrangement $arrangement, mode $mode, using instrument $instrument..." Chris@247: Chris@269: # unlike run.sh we don't normalise the input here Chris@269: cp "$infile" "$tmpwav" Chris@247: Chris@269: # generate the transform by interpolating the instrument parameter Chris@269: cat transform.ttl | \ Chris@269: sed "s/INSTRUMENT_PARAMETER/$instrument/" | \ Chris@269: sed "s/MODE_PARAMETER/$mode/" > "$transfile" Chris@247: Chris@269: sonic-annotator \ Chris@269: --writer csv \ Chris@269: --csv-one-file "$outfile" \ Chris@269: --csv-force \ Chris@269: --transform "$transfile" \ Chris@269: "$tmpwav" Chris@247: Chris@269: cat "$outfile" | \ Chris@269: sed 's/^[^,]*,//' | \ Chris@269: while IFS=, read start duration frequency level label; do Chris@247: end=`echo "$start $duration + p" | dc` Chris@247: echo -e "$start\t$end\t$frequency" Chris@269: done > "$outfile.lab" Chris@247: Chris@269: for ms in 50 100; do Chris@269: mark="" Chris@269: if [ "$ms" = "50" ]; then mark=" <-- main $piece/$arrangement"; fi; Chris@269: echo Chris@269: echo "Validating against ground truth at $ms ms:" Chris@269: "$yc" ../scripts/evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "$outfile.lab" | sed 's,$,'"$mark"',' Chris@269: echo Chris@269: echo "Validating against MIREX submission at $ms ms:" Chris@269: "$yc" ../scripts/evaluate_lab.yeti "$ms" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab" "$outfile.lab" Chris@269: echo Chris@269: echo "Validating MIREX against ground truth at $ms ms": Chris@269: "$yc" ../scripts/evaluate_lab.yeti "$ms" "../TRIOS-groundtruth/$piece/$arrangement.lab" "../TRIOS-mirex2012-matlab/$piece/$arrangement.lab" Chris@269: done; Chris@269: Chris@247: echo Chris@269: done Chris@247: done