To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / doChordID-simple.sh @ 0:4182672fd6f8

History | View | Annotate | Download (1.45 KB)

1
#!/bin/bash
2

    
3
if [ $# -lt 2 ] ; then
4
echo "Usage: $0 [-s] LISTFILENAME OUTPUTDIR"
5
exit 1
6
fi
7

    
8
retainstructure=0
9

    
10
while [ $# -gt 2 ] ; do
11
case $1 in
12
-d) retainstructure=1 ; shift 1 ; echo here;;
13
*) shift 1 ;;
14
esac
15
done
16

    
17
listfile="$1"
18
echo listfile "$listfile"
19
outputdir="$2"
20

    
21

    
22
while read infile; do
23
	if [ "$infile" -a -f "$infile" ]; then
24
		before="$(date +%s)"
25
		echo "_____________________________________________________"
26
		echo " "
27
		echo Processing file "$infile"
28
		echo " "
29
		if [ $retainstructure -eq 0 ]; then
30
			pathandfile=`basename "$infile"`
31
		else
32
			pathandfile="`echo "$infile" | egrep -o '[^/]*/[^/]*/[^/]*$'`"
33
			echo pathandfile "$pathandfile"
34
		fi
35
		outfile="$outputdir"/"$pathandfile".txt
36
		
37
		logfile=_logfiles/"$pathandfile".log
38
		chromafile=_chromadata/"$pathandfile".csv
39
		
40
		mkdir -p "`dirname "$outfile"`"
41
		
42
		echo "[sonic annotator] ..."
43
		helper=n		
44
		VAMP_PATH=. ./sonic-annotator-unix -d vamp:matthiasm:nnls_chroma:simplechord -w csv --csv-stdout "$infile" | cut -d ',' -f 2- |
45
		while read line; do			
46
			# echo "$line"
47
			if [ $helper = y ]; then
48
				echo "$oldstart" `echo "$line" | cut -d ',' -f 1` "$oldchord"
49
			fi
50
			oldstart=`echo "$line" | cut -d ',' -f 1`
51
			oldchord=`echo "$line" | cut -d ',' -f 2 | sed 's/"//g'`
52
			helper=y
53
		done > "$outfile"
54
		after="$(date +%s)"
55
		elapsed_seconds="$(expr $after - $before)"
56
		echo "  -->" time elapsed: $elapsed_seconds seconds
57
		echo " "
58
	else if [ ! "$infile" ]; then echo ...; fi
59
	fi		
60
done < "$listfile"