-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatch_audio.sh
executable file
·112 lines (83 loc) · 1.92 KB
/
match_audio.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
# run match.py for all audio files in the `data' directory
flags=""
pids=()
function clean_exit
{
echo "caught SIGINT, stopping processes..."
for pid in ${pids[@]}; do
kill $pid 2>/dev/null
done
exit 1
}
trap "clean_exit" 2 # catch SIGINT
if [ -n "$1" ]; then
echo "usage: $0"
exit 1
fi
dir=$(dirname "$0")
cd "$dir"
# setup log
outroot="output/muserc_sa_pre"
if [ ! -d "${outroot}" ]; then
mkdir "${outroot}"
fi
# setup log
outdir="output/muserc_sa_pre/muserc_sa"
if [ ! -d "${outdir}" ]; then
mkdir "${outdir}"
fi
log_base="$outdir/match_audio"
log="${log_base}.log"
i=0
while [ -e "$log" ]; do
i="`expr $i + 1`"
log="${log_base}_${i}.log"
done
touch "$log"
for f in data/muserc_sensor_audio_raw/data_*_audio ; do
# videos are processed in match_video.sh
grep -q "video" <<< $f && continue
base="${f%%_audio}"
file="`basename $base`"
tone="$(echo $file | sed 's/.*_//')"
exp="$(echo $file | sed 's/data_\([^_]*\)_.*/\1/')"
case "$tone" in
"d3")
midi="50"
;;
"dsharp3")
midi="51"
;;
"e3")
midi="52"
;;
"f3")
midi="53"
;;
"b3")
midi="59"
;;
"c4")
midi="60"
;;
"csharp4")
midi="61"
;;
*)
echo "Error: unrecognized input note in file name $file. Aborting..." >>$log
echo "Error: unrecognized input note in file name $file. Aborting..."
exit 1
esac
title="${exp}_${midi}"
mlog="${log%.log}_$title.log"
cutlist="-c ${base}_cutlist"
echo "starting $title ..."
echo "./match.py -v \"${base}_audio\" \"${base}_sync\" \"${base}_sensor\" \"$title\" \"$outdir\" $cutlist $flags >>$mlog 2>>$mlog &" >>$log
./match.py -v "${base}_audio" "${base}_sync" "${base}_sensor" "$title" "$outdir" $cutlist $flags >>$mlog 2>>$mlog &
pids+=($!)
done
echo "waiting for processes to finish..."
for pid in ${pids[@]}; do
wait $pid
done