Mercurial > hg > sonic-annotator
comparison tests/test-midi-destinations/test-midi-destinations.sh @ 147:1a6eab755c81 midi
Add MIDI destinations tests and fix feature writer bugs resulting from them
author | Chris Cannam |
---|---|
date | Tue, 14 Oct 2014 10:07:02 +0100 |
parents | tests/test-rdf-destinations/test-rdf-destinations.sh@7a31201dc42d |
children |
comparison
equal
deleted
inserted
replaced
146:45480b73f4af | 147:1a6eab755c81 |
---|---|
1 #!/bin/bash | |
2 | |
3 . ../include.sh | |
4 | |
5 infile1=$audiopath/3clicks8.wav | |
6 infile2=$audiopath/6clicks8.wav | |
7 | |
8 infile1dot=$audiopath/3.clicks.8.wav | |
9 | |
10 outfile1=3clicks8.mid | |
11 outfile2=6clicks8.mid | |
12 | |
13 outfile3=3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.mid | |
14 outfile4=3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.mid | |
15 outfile5=6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.mid | |
16 outfile6=6clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.mid | |
17 | |
18 outfile1dot=3.clicks.8.mid | |
19 | |
20 tmpmid=$mypath/tmp_1_$$.mid | |
21 | |
22 trap "rm -f $tmpmid $outfile1 $outfile2 $outfile3 $outfile4 $outfile5 $outfile6 $infile1dot $outfile1dot $audiopath/$outfile1 $audiopath/$outfile2 $audiopath/$outfile3 $audiopath/$outfile4 $audiopath/$outfile5 $audiopath/$outfile6 $audiopath/$outfile1dot" 0 | |
23 | |
24 transformdir=$mypath/transforms | |
25 | |
26 check_midi() { | |
27 test -f $1 || \ | |
28 fail "Fails to write output to expected location $1 for $2" | |
29 case $(strings $1 | head -2 | fmt -80) in | |
30 MThd\ MTrk) ;; | |
31 *) fail "MIDI output does not look like MIDI in $2";; | |
32 esac | |
33 rm -f $1 | |
34 } | |
35 | |
36 | |
37 ctx="onsets transform, one audio file, default MIDI writer destination" | |
38 | |
39 rm -f $audiopath/$outfile1 | |
40 | |
41 $r -t $transformdir/onsets.n3 -w midi $infile1 2>/dev/null || \ | |
42 fail "Fails to run with $ctx" | |
43 | |
44 check_midi $audiopath/$outfile1 "$ctx" | |
45 | |
46 | |
47 ctx="onsets transform, one audio file with dots in filename, default MIDI writer destination" | |
48 | |
49 rm -f $audiopath/$outfile1 | |
50 | |
51 cp $infile1 $infile1dot | |
52 | |
53 $r -t $transformdir/onsets.n3 -w midi $infile1dot 2>/dev/null || \ | |
54 fail "Fails to run with $ctx" | |
55 | |
56 check_midi $audiopath/$outfile1dot "$ctx" | |
57 | |
58 rm -f $infile1dot $audiopath/$outfile1dot | |
59 | |
60 | |
61 ctx="onsets and df transforms, one audio file, default MIDI writer destination" | |
62 | |
63 rm -f $audiopath/$outfile1 | |
64 | |
65 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi $infile1 2>/dev/null || \ | |
66 fail "Fails to run with $ctx" | |
67 | |
68 check_midi $audiopath/$outfile1 "$ctx" | |
69 | |
70 | |
71 ctx="onsets transform, two audio files, default MIDI writer destination" | |
72 | |
73 rm -f $audiopath/$outfile1 | |
74 rm -f $audiopath/$outfile2 | |
75 | |
76 $r -t $transformdir/onsets.n3 -w midi $infile1 $infile2 2>/dev/null || \ | |
77 fail "Fails to run with $ctx" | |
78 | |
79 check_midi $audiopath/$outfile1 "$ctx" | |
80 check_midi $audiopath/$outfile2 "$ctx" | |
81 | |
82 | |
83 ctx="onsets transform, two audio files, one-file MIDI writer" | |
84 | |
85 $r -t $transformdir/onsets.n3 -w midi --midi-one-file $tmpmid $infile1 $infile2 2>/dev/null || \ | |
86 fail "Fails to run with $ctx" | |
87 | |
88 check_midi $tmpmid "$ctx" | |
89 | |
90 | |
91 ctx="onsets transform, two audio files, stdout MIDI writer" | |
92 | |
93 # stdout writer is not supported for midi | |
94 | |
95 $r -t $transformdir/onsets.n3 -w midi --midi-stdout $infile1 $infile2 2>/dev/null >$tmpmid && \ | |
96 fail "Fails by completing successfully with $ctx" | |
97 | |
98 | |
99 ctx="onsets transform, one audio file, many-files MIDI writer" | |
100 | |
101 rm -f $audiopath/$outfile3 | |
102 | |
103 $r -t $transformdir/onsets.n3 -w midi --midi-many-files $infile1 2>/dev/null || \ | |
104 fail "Fails to run with $ctx" | |
105 | |
106 check_midi $audiopath/$outfile3 "$ctx" | |
107 | |
108 | |
109 ctx="onsets transform, two audio files, many-files MIDI writer" | |
110 | |
111 rm -f $audiopath/$outfile3 | |
112 rm -f $audiopath/$outfile5 | |
113 | |
114 $r -t $transformdir/onsets.n3 -w midi --midi-many-files $infile1 $infile2 2>/dev/null || \ | |
115 fail "Fails to run with $ctx" | |
116 | |
117 check_midi $audiopath/$outfile3 "$ctx" | |
118 check_midi $audiopath/$outfile5 "$ctx" | |
119 | |
120 | |
121 ctx="onsets and df transforms, two audio files, many-files MIDI writer" | |
122 | |
123 rm -f $audiopath/$outfile3 | |
124 rm -f $audiopath/$outfile4 | |
125 rm -f $audiopath/$outfile5 | |
126 rm -f $audiopath/$outfile6 | |
127 | |
128 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi --midi-many-files $infile1 $infile2 2>/dev/null || \ | |
129 fail "Fails to run with $ctx" | |
130 | |
131 check_midi $audiopath/$outfile3 "$ctx" | |
132 check_midi $audiopath/$outfile4 "$ctx" | |
133 check_midi $audiopath/$outfile5 "$ctx" | |
134 check_midi $audiopath/$outfile6 "$ctx" | |
135 | |
136 | |
137 ctx="output base directory" | |
138 | |
139 rm -f ./$outfile1 | |
140 | |
141 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi --midi-basedir . $infile1 2>/dev/null || \ | |
142 fail "Fails to run with $ctx" | |
143 | |
144 check_midi ./$outfile1 "$ctx" | |
145 | |
146 | |
147 ctx="output base directory and many-files" | |
148 | |
149 rm -f ./$outfile3 | |
150 rm -f ./$outfile5 | |
151 | |
152 $r -t $transformdir/onsets.n3 -w midi --midi-basedir . --midi-many-files $infile1 $infile2 2>/dev/null || \ | |
153 fail "Fails to run with $ctx" | |
154 | |
155 check_midi ./$outfile3 "$ctx" | |
156 check_midi ./$outfile5 "$ctx" | |
157 | |
158 | |
159 ctx="nonexistent output base directory" | |
160 | |
161 $r -t $transformdir/onsets.n3 -w midi --midi-basedir ./DOES_NOT_EXIST $infile1 2>/dev/null && \ | |
162 fail "Fails with $ctx by completing successfully (should refuse and bail out)" | |
163 | |
164 | |
165 ctx="existing output file and no --midi-force" | |
166 | |
167 touch $audiopath/$outfile1 | |
168 | |
169 $r -t $transformdir/onsets.n3 -w midi $infile1 2>/dev/null && \ | |
170 fail "Fails by completing successfully when output file already exists (should refuse and bail out)" | |
171 | |
172 | |
173 ctx="existing output file and --midi-force" | |
174 | |
175 touch $audiopath/$outfile1 | |
176 | |
177 $r -t $transformdir/onsets.n3 -w midi --midi-force $infile1 2>/dev/null || \ | |
178 fail "Fails to run with $ctx" | |
179 | |
180 check_midi $audiopath/$outfile1 "$ctx" | |
181 | |
182 | |
183 exit 0 |