Chris@11: Chris@11: mydir=`dirname "$0"` Chris@11: infile="$1" Chris@11: outfile="$2" Chris@11: Chris@11: if [ t"$infile" = "t" ] || [ t"$outfile" = "t" ]; then Chris@11: echo "Usage: $0 infile.wav outfile.txt" Chris@11: exit 2 Chris@11: fi Chris@11: Chris@11: mkdir -p "$mydir"/out || exit 1 Chris@11: Chris@11: echo "Processing input WAV file $infile, writing results to $outfile..." 1>&2 Chris@11: Chris@11: # We want output like Chris@11: # Chris@11: # Bbminor Chris@11: # Chris@11: # Our Sonic Annotator output gives us something like that for each Chris@11: # detected key change (the feature label, in column 4), but we want Chris@11: # the modal key (modal in the statistical rather than the musical Chris@11: # sense!) and Sonic Annotator doesn't retain labels for summaries. So Chris@11: # let's write to a temporary file, retrieve the modal value, then pick Chris@11: # the label (from earlier in the file) whose value corresponds to it. Chris@11: Chris@11: VAMP_PATH="$mydir" sonic-annotator \ Chris@11: -t "$mydir"/qm-keydetector.ttl \ Chris@11: -w csv --csv-separator ";" \ Chris@11: --csv-basedir "$mydir/out" \ Chris@11: --csv-force \ Chris@11: -S mode \ Chris@11: "$infile" || exit 1 Chris@11: Chris@11: inbase=`basename "$infile"` Chris@11: inbase=${inbase%.*} Chris@11: tempfile="out/${inbase}_vamp_qm-vamp-plugins_qm-keydetector_key.csv" Chris@11: if [ ! -f "$tempfile" ]; then Chris@11: echo "Key output file $tempfile not found! bailing out"; exit 1 Chris@11: fi Chris@11: Chris@11: mode=`grep ';mode;' "$tempfile" | awk -F';' '{ print $4; }'` Chris@11: Chris@11: cat "$tempfile" | \ Chris@11: awk -F';' '{ print $2, $3 }' | \ Chris@11: grep "^$mode \"" | \ Chris@11: head -n 1 | \ Chris@11: sed -e 's/^[^"]*"//' -e 's/"[^"]*$//' -e 's,/ [^ ]* ,,' -e 's/ /\t/' \ Chris@11: > "$outfile" Chris@11: Chris@11: Chris@11: Chris@11: