Mercurial > hg > silvet
comparison testdata/TRIOS-silvet/calculate.sh @ 68:4ea3ef5c696a
Simplify naming, handle files individually, scale inputs
author | Chris Cannam |
---|---|
date | Tue, 29 Apr 2014 10:42:53 +0100 |
parents | 0607b9fce963 |
children | 9c7e6086192d |
comparison
equal
deleted
inserted
replaced
66:2af20708fcb8 | 68:4ea3ef5c696a |
---|---|
18 if ! sonic-annotator -v ; then | 18 if ! sonic-annotator -v ; then |
19 echo "Failed to run sonic-annotator (not in PATH?), giving up" | 19 echo "Failed to run sonic-annotator (not in PATH?), giving up" |
20 exit 1 | 20 exit 1 |
21 fi | 21 fi |
22 | 22 |
23 if ! sox --version ; then | |
24 echo "Failed to run sox (not in PATH?), giving up" | |
25 exit 1 | |
26 fi | |
27 | |
23 for d in brahms lussier mozart schubert take_five; do | 28 for d in brahms lussier mozart schubert take_five; do |
24 dir="$trios_path/$d" | 29 dir="$trios_path/$d" |
25 outdir="$outbase/$d" | 30 outdir="$outbase/$d" |
26 if [ ! -d "$dir" ]; then | 31 if [ ! -d "$dir" ]; then |
27 echo "TRIOS subdir $dir not found, skipping it" | 32 echo "TRIOS subdir $dir not found, skipping it" |
28 else | 33 else |
29 mkdir -p "$outdir" | 34 mkdir -p "$outdir" |
30 VAMP_PATH=../.. sonic-annotator \ | 35 for w in "$dir"/*.wav; do |
31 --writer csv \ | 36 wbase=`basename "$w" .wav` |
32 --csv-basedir "$outdir" \ | 37 outlab="$outdir/$wbase.lab" |
33 --csv-force \ | 38 echo "Processing wav file $w, writing to lab file $outlab" |
34 --default vamp:silvet:silvet:notes \ | 39 # The MATLAB method starts by normalising to a peak 0.5 |
35 --recursive \ | 40 # (approx -3dBFS amplitude or -6dB power). We can't do |
36 "$dir" | 41 # that in the plugin, so must do it here |
42 tmpwav="$outdir/$wbase.norm.wav" | |
43 sox "$w" "$tmpwav" gain -n -6.020599913279624 | |
44 VAMP_PATH=../.. sonic-annotator \ | |
45 --writer csv \ | |
46 --csv-stdout \ | |
47 --csv-force \ | |
48 --default vamp:silvet:silvet:notes \ | |
49 "$tmpwav" | \ | |
50 while IFS=, read start duration frequency level label; do | |
51 end=`echo "$start $duration + p" | dc` | |
52 echo -e "$start\t$end\t$frequency" | |
53 done > "$outlab" | |
54 rm "$tmpwav" | |
55 done | |
37 fi | 56 fi |
38 echo "Converting to lab files..." | |
39 for csv in "$outdir"/*.csv; do | |
40 cbase=`basename "$csv" .csv` | |
41 cat "$csv" | while IFS=, read start duration frequency level label; do | |
42 end=`echo "$start $duration + p" | dc` | |
43 echo -e "$start\t$end\t$frequency" | |
44 done > "$outdir/$cbase.lab" | |
45 rm "$csv" | |
46 done | |
47 done | 57 done |
48 | 58 |