annotate testdata/TRIOS-silvet/calculate.sh @ 167:416b555df3b2 finetune

More on returning fine tuning (but we're treating different shifts of the same pitch as different notes at the moment which is not right)
author Chris Cannam
date Tue, 20 May 2014 17:49:07 +0100
parents 9c7e6086192d
children
rev   line source
Chris@61 1 #!/bin/bash
Chris@61 2
Chris@61 3 # Run this from the directory that contains it
Chris@61 4
Chris@61 5 trios_path="/home/cannam/Music/TRIOS_dataset"
Chris@61 6
Chris@61 7 if [ ! -d "$trios_path" ]; then
Chris@61 8 echo "TRIOS dataset directory $trios_path not found, giving up"
Chris@61 9 exit 1
Chris@61 10 fi
Chris@61 11
Chris@61 12 outbase="`pwd`"
Chris@61 13 echo "Will read TRIOS files from $trios_path"
Chris@61 14 echo "Will write output files below $outbase"
Chris@61 15 echo "If either of these is incorrect, hit ctrl-C now!"
Chris@61 16 sleep 8
Chris@61 17
Chris@61 18 if ! sonic-annotator -v ; then
Chris@61 19 echo "Failed to run sonic-annotator (not in PATH?), giving up"
Chris@61 20 exit 1
Chris@61 21 fi
Chris@61 22
Chris@68 23 if ! sox --version ; then
Chris@68 24 echo "Failed to run sox (not in PATH?), giving up"
Chris@68 25 exit 1
Chris@68 26 fi
Chris@68 27
Chris@62 28 for d in brahms lussier mozart schubert take_five; do
Chris@62 29 dir="$trios_path/$d"
Chris@62 30 outdir="$outbase/$d"
Chris@62 31 if [ ! -d "$dir" ]; then
Chris@62 32 echo "TRIOS subdir $dir not found, skipping it"
Chris@62 33 else
Chris@62 34 mkdir -p "$outdir"
Chris@68 35 for w in "$dir"/*.wav; do
Chris@68 36 wbase=`basename "$w" .wav`
Chris@68 37 outlab="$outdir/$wbase.lab"
Chris@68 38 echo "Processing wav file $w, writing to lab file $outlab"
Chris@68 39 # The MATLAB method starts by normalising to a peak 0.5
Chris@68 40 # (approx -3dBFS amplitude or -6dB power). We can't do
Chris@68 41 # that in the plugin, so must do it here
Chris@68 42 tmpwav="$outdir/$wbase.norm.wav"
Chris@68 43 sox "$w" "$tmpwav" gain -n -6.020599913279624
Chris@68 44 VAMP_PATH=../.. sonic-annotator \
Chris@68 45 --writer csv \
Chris@68 46 --csv-stdout \
Chris@68 47 --default vamp:silvet:silvet:notes \
Chris@68 48 "$tmpwav" | \
Chris@69 49 sed 's/^[^,]*,//' | \
Chris@68 50 while IFS=, read start duration frequency level label; do
Chris@68 51 end=`echo "$start $duration + p" | dc`
Chris@68 52 echo -e "$start\t$end\t$frequency"
Chris@68 53 done > "$outlab"
Chris@68 54 rm "$tmpwav"
Chris@68 55 done
Chris@62 56 fi
Chris@62 57 done
Chris@61 58