To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / featurescript.sh
History | View | Annotate | Download (3.56 KB)
| 1 | 0:4182672fd6f8 | Chris | #!/bin/bash |
|---|---|---|---|
| 2 | |||
| 3 | base=/import/c4dm-music-a/C4DM\ Music\ Collection |
||
| 4 | |||
| 5 | mine=`date '+%Y-%m-%d_%H.%M.%S'`_$$ |
||
| 6 | logfile="logs/$mine.log" |
||
| 7 | statusfile="logs/$mine.status" |
||
| 8 | matlogfile="logs/$mine.matlog" |
||
| 9 | mkdir -p logs |
||
| 10 | |||
| 11 | echo "base: $base" |
||
| 12 | echo "log file to $logfile" |
||
| 13 | echo "overall status reports to $statusfile" |
||
| 14 | |||
| 15 | report_failure() {
|
||
| 16 | echo "FAIL $@" >> "$statusfile" |
||
| 17 | } |
||
| 18 | report_success() {
|
||
| 19 | echo "WIN $@" >> "$statusfile" |
||
| 20 | } |
||
| 21 | report_existing() {
|
||
| 22 | echo "HAZ $@" >> "$statusfile" |
||
| 23 | } |
||
| 24 | report_busy() {
|
||
| 25 | echo "BUSY $@" >> "$statusfile" |
||
| 26 | } |
||
| 27 | |||
| 28 | find "$base" -type d | while read source; do |
||
| 29 | |||
| 30 | ls "$source" | fgrep -q .wav || continue |
||
| 31 | |||
| 32 | echo "source: $source" |
||
| 33 | dirname=${source#$base}
|
||
| 34 | dirname=${dirname#/}
|
||
| 35 | echo "dirname: $dirname" |
||
| 36 | [ -n "$dirname" ] || continue |
||
| 37 | |||
| 38 | for wavfilename in "$source/"*.wav; do # loop over songs |
||
| 39 | |||
| 40 | echo "$wavfilename" |
||
| 41 | |||
| 42 | songbasename=`basename "${wavfilename%.wav}"`
|
||
| 43 | echo .................. new song "$dirname/$songbasename" ............. |
||
| 44 | songdir="output/$dirname/$songbasename" # this is where all song-related features will go into |
||
| 45 | mkdir -p "$songdir" |
||
| 46 | |||
| 47 | ( if ! flock -en 200; then |
||
| 48 | echo "songdir $songdir is locked already, skipping it" |
||
| 49 | report_busy "$wavfilename" |
||
| 50 | exit |
||
| 51 | fi |
||
| 52 | |||
| 53 | echo "have lock on songdir $songdir" |
||
| 54 | |||
| 55 | if [ -s "$songdir/$songbasename""_vamp_matthiasm_nnls_chroma_bothchroma.csv" ]; then |
||
| 56 | echo "non-empty output file(s) exist -- not re-generating" |
||
| 57 | report_existing "$wavfilename" |
||
| 58 | exit |
||
| 59 | fi |
||
| 60 | |||
| 61 | echo oooooooooooooooooooooooooooooooooooooooooooooooo |
||
| 62 | echo low level feature extraction |
||
| 63 | echo oooooooooooooooooooooooooooooooooooooooooooooooo |
||
| 64 | VAMP_PATH=. ./sonic-annotator-unix \ |
||
| 65 | -d vamp:matthiasm:nnls_chroma:simplechord \ |
||
| 66 | -d vamp:matthiasm:nnls_chroma:bothchroma \ |
||
| 67 | -d vamp:matthiasm:nnls_chroma:localtuning \ |
||
| 68 | -d vamp:matthiasm:nnls_chroma:logfreqspec \ |
||
| 69 | -d vamp:matthiasm:nnls_chroma:semitonespectrum \ |
||
| 70 | -d vamp:matthiasm:nnls_chroma:tunedlogfreqspec \ |
||
| 71 | -d vamp:matthiasm:nnls_chroma:tuning \ |
||
| 72 | -w csv \ |
||
| 73 | --csv-basedir "$songdir/" \ |
||
| 74 | "$wavfilename" |
||
| 75 | matlab_infile=`echo "$wavfilename" | sed "s/'/''/g"` |
||
| 76 | matlab_chromafile=`echo "$songdir/$songbasename" | sed "s/'/''/g"`_vamp_matthiasm_nnls_chroma_bothchroma.csv |
||
| 77 | matlab_outbase=`echo "$songdir/$songbasename" | sed "s/'/''/g"` |
||
| 78 | matlab_segout="$matlab_outbase".seg |
||
| 79 | matlab_chordout="$matlab_outbase".chord |
||
| 80 | # matlab_keyout="$matlab_outbase".key # is still done in matlab |
||
| 81 | echo oooooooooooooooooooooooooooooooooooooooooooooooo |
||
| 82 | echo segmentation |
||
| 83 | echo oooooooooooooooooooooooooooooooooooooooooooooooo |
||
| 84 | echo "run_segmentation('$matlab_infile','$matlab_segout','$matlab_chromafile')" | matlab -nodisplay -nojvm 2>&1 >/dev/null | tee "$matlogfile"
|
||
| 85 | if grep -qi "error" "$matlogfile" ; then |
||
| 86 | report_failure "$wavfilename" |
||
| 87 | exit |
||
| 88 | else |
||
| 89 | rm "$matlogfile" |
||
| 90 | fi |
||
| 91 | echo oooooooooooooooooooooooooooooooooooooooooooooooo |
||
| 92 | echo DBN chord estimation |
||
| 93 | echo oooooooooooooooooooooooooooooooooooooooooooooooo |
||
| 94 | echo "run_chordandkey('$matlab_infile','$matlab_chordout','$matlab_chromafile')" | matlab -nodisplay -nojvm 2>&1 >/dev/null | tee "$matlogfile"
|
||
| 95 | cat "$matlogfile" |
||
| 96 | if grep -qi "error" "$matlogfile" ; then |
||
| 97 | report_failure "$wavfilename" |
||
| 98 | exit |
||
| 99 | else |
||
| 100 | rm "$matlogfile" |
||
| 101 | fi |
||
| 102 | report_success "$wavfilename" |
||
| 103 | |||
| 104 | )200>"$songdir/.lock" |
||
| 105 | done |
||
| 106 | |||
| 107 | done > "$logfile" 2>&1 |
||
| 108 |