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