Chris@73
|
1 #!/bin/bash
|
Chris@73
|
2
|
Chris@73
|
3 audio=$HOME/music
|
Chris@73
|
4 preferred=$audio/ogg/linux
|
Chris@73
|
5 list=audiofiles.txt
|
Chris@73
|
6 used=audiofiles-used.txt
|
Chris@73
|
7
|
Chris@73
|
8 sv-command quit
|
Chris@73
|
9
|
Chris@73
|
10 pick_file()
|
Chris@73
|
11 {
|
Chris@73
|
12 count=`wc -l "$list" 2>/dev/null | awk '{ print $1 }'`
|
Chris@73
|
13 if [ ! -f "$list" ] || [ "$count" -eq "0" ] ; then
|
Chris@73
|
14 find "$audio" -name \*.ogg -print >> "$list"
|
Chris@73
|
15 find "$audio" -name \*.mp3 -print >> "$list"
|
Chris@73
|
16 find "$audio" -name \*.wav -print >> "$list"
|
Chris@73
|
17 find "$preferred" -name \*.ogg -print >> "$list"
|
Chris@73
|
18 find "$preferred" -name \*.mp3 -print >> "$list"
|
Chris@73
|
19 find "$preferred" -name \*.wav -print >> "$list"
|
Chris@73
|
20 count=`wc -l "$list" 2>/dev/null | awk '{ print $1 }'`
|
Chris@73
|
21 fi
|
Chris@73
|
22 while [ -z "$file" ]; do
|
Chris@73
|
23 index=$((RANDOM % $count))
|
Chris@73
|
24 file=`tail +"$index" "$list" | head -1`
|
Chris@73
|
25 [ -f "$file" ] || continue
|
Chris@73
|
26 done
|
Chris@73
|
27 fgrep -v "$file" "$list" > "$list"_ && mv "$list"_ "$list"
|
Chris@73
|
28 echo "$file"
|
Chris@73
|
29 }
|
Chris@73
|
30
|
Chris@73
|
31 load_a_file()
|
Chris@73
|
32 {
|
Chris@73
|
33 file=`pick_file`
|
Chris@73
|
34 if ! sv-command open "$file"; then
|
Chris@73
|
35 pid="`pidof sonic-visualiser`"
|
Chris@73
|
36 if [ -z "$pid" ]; then
|
Chris@73
|
37 ( setsid ../sonic-visualiser & )
|
Chris@73
|
38 sleep 2
|
Chris@73
|
39 load_a_file
|
Chris@73
|
40 else
|
Chris@73
|
41 echo "ERROR: Unable to contact sonic-visualiser pid $pid" 1>&2
|
Chris@73
|
42 exit 1
|
Chris@73
|
43 fi
|
Chris@73
|
44 fi
|
Chris@73
|
45 }
|
Chris@73
|
46
|
Chris@73
|
47 show_stuff()
|
Chris@73
|
48 {
|
Chris@73
|
49 sv-command set overlays 2
|
Chris@73
|
50 sv-command set zoomwheels 1
|
Chris@73
|
51 sv-command set propertyboxes 1
|
Chris@73
|
52 }
|
Chris@73
|
53
|
Chris@73
|
54 hide_stuff()
|
Chris@73
|
55 {
|
Chris@73
|
56 sv-command set overlays 0
|
Chris@73
|
57 sv-command set zoomwheels 0
|
Chris@73
|
58 sv-command set propertyboxes 0
|
Chris@73
|
59 }
|
Chris@73
|
60
|
Chris@73
|
61 reset()
|
Chris@73
|
62 {
|
Chris@73
|
63 for pane in 1 2 3 4 5; do
|
Chris@73
|
64 for layer in 1 2 3 4 5 6 7 8 9 10; do
|
Chris@73
|
65 sv-command delete layer
|
Chris@73
|
66 done
|
Chris@73
|
67 sv-command delete pane
|
Chris@73
|
68 done
|
Chris@73
|
69 sv-command zoom default
|
Chris@73
|
70 sv-command add waveform
|
Chris@73
|
71 show_stuff
|
Chris@73
|
72 }
|
Chris@73
|
73
|
Chris@73
|
74 scroll_and_zoom()
|
Chris@73
|
75 {
|
Chris@73
|
76 sv-command set overlays 0
|
Chris@73
|
77 sv-command set zoomwheels 0
|
Chris@73
|
78 sv-command set propertyboxes 0
|
Chris@73
|
79 sv-command setcurrent 1 1
|
Chris@73
|
80 sv-command delete layer
|
Chris@73
|
81 sv-command setcurrent 1 1
|
Chris@73
|
82 sv-command set layer Colour Red
|
Chris@73
|
83 sleep 1
|
Chris@73
|
84 sv-command set pane Global-Zoom off
|
Chris@73
|
85 sv-command set pane Global-Scroll off
|
Chris@73
|
86 sv-command set pane Follow-Playback Scroll
|
Chris@73
|
87 for zoom in 950 900 850 800 750 700 650 600 550 512 450 400 350 300 256 192 160 128 96 64 48 32 24 16; do
|
Chris@73
|
88 sv-command zoom $zoom
|
Chris@73
|
89 sleep 0.1
|
Chris@73
|
90 done
|
Chris@73
|
91 }
|
Chris@73
|
92
|
Chris@73
|
93 play()
|
Chris@73
|
94 {
|
Chris@73
|
95 sv-command play "$@"
|
Chris@73
|
96 }
|
Chris@73
|
97
|
Chris@73
|
98 fade_in()
|
Chris@73
|
99 {
|
Chris@73
|
100 sv-command set gain 0
|
Chris@73
|
101 sleep 0.5
|
Chris@73
|
102 play "$@"
|
Chris@73
|
103 for gain in 0.001 0.01 0.05 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1; do
|
Chris@73
|
104 sv-command set gain $gain
|
Chris@73
|
105 sleep 0.1
|
Chris@73
|
106 done
|
Chris@73
|
107 }
|
Chris@73
|
108
|
Chris@73
|
109 fade_out()
|
Chris@73
|
110 {
|
Chris@73
|
111 for gain in 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.05 0.01 0.001; do
|
Chris@73
|
112 sv-command set gain $gain
|
Chris@73
|
113 sleep 0.1
|
Chris@73
|
114 done
|
Chris@73
|
115 stop
|
Chris@73
|
116 sv-command set gain 1
|
Chris@73
|
117 }
|
Chris@73
|
118
|
Chris@73
|
119 slow()
|
Chris@73
|
120 {
|
Chris@73
|
121 for speed in -1 -10 -20 -30 -40 -50 -60 -70 -80 -100 -140 -200 -250 -300 -400 -500 -700 -800 -900 -1000; do
|
Chris@73
|
122 sv-command set speedup "$speed"
|
Chris@73
|
123 sleep 1
|
Chris@73
|
124 done
|
Chris@73
|
125 }
|
Chris@73
|
126
|
Chris@73
|
127 stop()
|
Chris@73
|
128 {
|
Chris@73
|
129 sv-command stop "$@"
|
Chris@73
|
130 sv-command set speedup 0
|
Chris@73
|
131 }
|
Chris@73
|
132
|
Chris@73
|
133 quit()
|
Chris@73
|
134 {
|
Chris@73
|
135 sv-command quit
|
Chris@73
|
136 }
|
Chris@73
|
137
|
Chris@73
|
138 add_melodic_range_spectrogram()
|
Chris@73
|
139 {
|
Chris@73
|
140 sv-command set propertyboxes 1
|
Chris@73
|
141 sv-command add spectrogram
|
Chris@73
|
142 sv-command set layer Window-Size 4096
|
Chris@73
|
143 # sv-command set layer Window-Overlap 4
|
Chris@73
|
144 sv-command set layer Window-Overlap 3
|
Chris@73
|
145 sv-command set layer Frequency-Scale Log
|
Chris@73
|
146 sv-command set layer Colour-Scale Meter
|
Chris@73
|
147 }
|
Chris@73
|
148
|
Chris@73
|
149 zoom_in_spectrogram()
|
Chris@73
|
150 {
|
Chris@73
|
151 sv-command zoomvertical 43 8000
|
Chris@73
|
152 for x in 1 2 3 4 5 6; do
|
Chris@73
|
153 max=$((8000 - 1000*$x))
|
Chris@73
|
154 sv-command zoomvertical 43 "$max"
|
Chris@73
|
155 sleep 0.1
|
Chris@73
|
156 done
|
Chris@73
|
157 for x in 1 2 3 4 5; do
|
Chris@73
|
158 max=$((2000 - 100 * $x))
|
Chris@73
|
159 sv-command zoomvertical 43 "$max"
|
Chris@73
|
160 sleep 0.1
|
Chris@73
|
161 done
|
Chris@73
|
162 }
|
Chris@73
|
163
|
Chris@73
|
164 zoom_in_spectrogram_further()
|
Chris@73
|
165 {
|
Chris@73
|
166 for x in 1 2 3 4 5; do
|
Chris@73
|
167 sv-command zoomvertical in
|
Chris@73
|
168 done
|
Chris@73
|
169 }
|
Chris@73
|
170
|
Chris@73
|
171 playback_bits()
|
Chris@73
|
172 {
|
Chris@73
|
173 sv-command set pane Follow-Playback Scroll
|
Chris@73
|
174 sv-command jump 10
|
Chris@73
|
175 sv-command setcurrent 1 2
|
Chris@73
|
176 sv-command set layer Colour Blue
|
Chris@73
|
177 sleep 5
|
Chris@73
|
178 hide_stuff
|
Chris@73
|
179 fade_in
|
Chris@73
|
180 sleep 10
|
Chris@73
|
181 scroll_and_zoom
|
Chris@73
|
182 sleep 10
|
Chris@73
|
183 slow
|
Chris@73
|
184 #sv-command set layer Normalize-Visible-Area on
|
Chris@73
|
185 for zoom in 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1; do
|
Chris@73
|
186 sv-command zoom $zoom
|
Chris@73
|
187 sleep 0.1
|
Chris@73
|
188 done
|
Chris@73
|
189 sleep 8
|
Chris@73
|
190 fade_out
|
Chris@73
|
191 done_playback_bits=1
|
Chris@73
|
192 }
|
Chris@73
|
193
|
Chris@73
|
194 spectrogram_bits()
|
Chris@73
|
195 {
|
Chris@73
|
196 add_melodic_range_spectrogram
|
Chris@73
|
197 sv-command zoom 256
|
Chris@73
|
198 sleep 10
|
Chris@73
|
199 zoom_in_spectrogram
|
Chris@73
|
200 sleep 20
|
Chris@73
|
201
|
Chris@73
|
202 if [ -n "$done_playback_bits" ]; then
|
Chris@73
|
203 sv-command setcurrent 1
|
Chris@73
|
204 sv-command zoom out
|
Chris@73
|
205 sv-command zoom out
|
Chris@73
|
206 sv-command zoom out
|
Chris@73
|
207 sv-command zoom out
|
Chris@73
|
208 sv-command zoom out
|
Chris@73
|
209 sv-command setcurrent 2
|
Chris@73
|
210 fi
|
Chris@73
|
211
|
Chris@73
|
212 hide_stuff
|
Chris@73
|
213 fade_in
|
Chris@73
|
214 sleep 10
|
Chris@73
|
215 sv-command set layer Bin-Display Frequencies
|
Chris@73
|
216 sv-command set layer Normalize-Columns on
|
Chris@73
|
217 sleep 20
|
Chris@73
|
218 sv-command set layer Bin-Display "All Bins"
|
Chris@73
|
219 sv-command set layer Colour "Red on Blue"
|
Chris@73
|
220 sleep 10
|
Chris@73
|
221 fade_out
|
Chris@73
|
222 sleep 1
|
Chris@73
|
223 done_spectrogram_bits=1
|
Chris@73
|
224
|
Chris@73
|
225 # zoom_in_spectrogram_further
|
Chris@73
|
226 }
|
Chris@73
|
227
|
Chris@73
|
228 onset_bits()
|
Chris@73
|
229 {
|
Chris@73
|
230 show_stuff
|
Chris@73
|
231 sv-command setcurrent 1
|
Chris@73
|
232 sv-command set pane Global-Zoom on
|
Chris@73
|
233 sv-command set pane Global-Scroll on
|
Chris@73
|
234 sleep 5
|
Chris@73
|
235 sv-command zoom default
|
Chris@73
|
236 sv-command zoom in
|
Chris@73
|
237 sv-command zoom in
|
Chris@73
|
238 sv-command zoom in
|
Chris@73
|
239 sv-command add timeruler
|
Chris@73
|
240 sv-command transform vamp:vamp-aubio:aubioonset:detectionfunction
|
Chris@73
|
241 sleep 5
|
Chris@73
|
242 sv-command set layer Plot-Type Curve
|
Chris@73
|
243 sleep 5
|
Chris@73
|
244 sv-command setcurrent 1
|
Chris@73
|
245 sv-command set pane Follow-Playback Page
|
Chris@73
|
246 sv-command transform vamp:vamp-aubio:aubioonset:detectionfunction
|
Chris@73
|
247 sv-command set layer Colour Red
|
Chris@73
|
248 sleep 5
|
Chris@73
|
249 sv-command set layer Plot-Type Segmentation
|
Chris@73
|
250 # sv-command set layer Vertical-Scale "Log Scale"
|
Chris@73
|
251 sv-command jump 30
|
Chris@73
|
252 sleep 5
|
Chris@73
|
253 # hide_stuff
|
Chris@73
|
254 if [ -n "$done_spectrogram_bits" ]; then
|
Chris@73
|
255 sv-command setcurrent 2
|
Chris@73
|
256 sv-command delete pane
|
Chris@73
|
257 fi
|
Chris@73
|
258 sleep 10
|
Chris@73
|
259 sv-command setcurrent 1 1
|
Chris@73
|
260 sv-command set layer Colour Black
|
Chris@73
|
261 sv-command setcurrent 1 2
|
Chris@73
|
262 fade_in
|
Chris@73
|
263 sleep 5
|
Chris@73
|
264 sv-command transform vamp:vamp-aubio:aubioonset:onsets
|
Chris@73
|
265 sv-command set layer Colour Black
|
Chris@73
|
266 sleep 20
|
Chris@73
|
267 sv-command setcurrent 2
|
Chris@73
|
268 # sv-command transform vamp:qm-vamp-plugins:qm-tempotracker:beats
|
Chris@73
|
269 sv-command transform vamp:vamp-aubio:aubiotempo:beats
|
Chris@73
|
270 sleep 10
|
Chris@73
|
271 fade_out
|
Chris@73
|
272 show_stuff
|
Chris@73
|
273 }
|
Chris@73
|
274
|
Chris@73
|
275 selection_bits()
|
Chris@73
|
276 {
|
Chris@73
|
277 # reset
|
Chris@73
|
278 sv-command set overlays 1
|
Chris@73
|
279 sv-command set zoomwheels 0
|
Chris@73
|
280 sv-command setcurrent 2
|
Chris@73
|
281 sv-command delete pane
|
Chris@73
|
282 if [ -n "$done_playback_bits" ]; then
|
Chris@73
|
283 sv-command setcurrent 1 2
|
Chris@73
|
284 else
|
Chris@73
|
285 sv-command setcurrent 1 3
|
Chris@73
|
286 fi
|
Chris@73
|
287 sv-command delete layer
|
Chris@73
|
288 if [ -n "$done_playback_bits" ]; then
|
Chris@73
|
289 sv-command setcurrent 1 2
|
Chris@73
|
290 else
|
Chris@73
|
291 sv-command setcurrent 1 3
|
Chris@73
|
292 fi
|
Chris@73
|
293 sv-command delete layer
|
Chris@73
|
294 # sv-command transform vamp:qm-vamp-plugins:qm-tempotracker:beats
|
Chris@73
|
295 sv-command transform vamp:vamp-aubio:aubiotempo:beats
|
Chris@73
|
296 sv-command setcurrent 1 2
|
Chris@73
|
297 sv-command set layer Colour Orange
|
Chris@73
|
298 sv-command setcurrent 1 3
|
Chris@73
|
299 sv-command resize 1024 500
|
Chris@73
|
300 sv-command zoom default
|
Chris@73
|
301 sleep 10
|
Chris@73
|
302 sv-command loop on
|
Chris@73
|
303 base=$((RANDOM % 100))
|
Chris@73
|
304 sv-command select $base $base.3
|
Chris@73
|
305 fade_in selection
|
Chris@73
|
306 sleep 12
|
Chris@73
|
307 base=$((base + 4))
|
Chris@73
|
308 sv-command addselect $base $base.1
|
Chris@73
|
309 sleep 12
|
Chris@73
|
310 base=$((base + 2))
|
Chris@73
|
311 sv-command addselect $base $base.1
|
Chris@73
|
312 sleep 6
|
Chris@73
|
313 base=$((base + 2))
|
Chris@73
|
314 sv-command addselect $base $base.3
|
Chris@73
|
315 sleep 6
|
Chris@73
|
316 base=$((base + 3))
|
Chris@73
|
317 sv-command addselect $base $base.3
|
Chris@73
|
318 sleep 6
|
Chris@73
|
319 base=$((base + 2))
|
Chris@73
|
320 sv-command addselect $base $base.3
|
Chris@73
|
321 sleep 12
|
Chris@73
|
322 sv-command set speedup -50
|
Chris@73
|
323 sleep 14
|
Chris@73
|
324 sv-command set speedup 50
|
Chris@73
|
325 sleep 8
|
Chris@73
|
326 sv-command set speedup 100
|
Chris@73
|
327 sleep 5
|
Chris@73
|
328 sv-command set speedup 200
|
Chris@73
|
329 fade_out
|
Chris@73
|
330 sleep 20
|
Chris@73
|
331 sv-command select none
|
Chris@73
|
332 sv-command setcurrent 1 3
|
Chris@73
|
333 sv-command delete layer
|
Chris@73
|
334 sv-command setcurrent 1 2
|
Chris@73
|
335 sv-command set layer Colour Black
|
Chris@73
|
336 }
|
Chris@73
|
337
|
Chris@73
|
338 chromagram_bits()
|
Chris@73
|
339 {
|
Chris@73
|
340 add_melodic_range_spectrogram
|
Chris@74
|
341 sleep 10
|
Chris@73
|
342 sv-command add timeruler
|
Chris@73
|
343 sv-command transform vamp:qm-vamp-plugins:qm-chromagram:chromagram
|
Chris@73
|
344 sleep 2
|
Chris@73
|
345 sv-command jump 20
|
Chris@73
|
346 sleep 10
|
Chris@73
|
347 sv-command zoom out
|
Chris@73
|
348 fade_in
|
Chris@74
|
349 sleep 15
|
Chris@73
|
350 fade_out
|
Chris@73
|
351 }
|
Chris@73
|
352
|
Chris@73
|
353 while /bin/true; do
|
Chris@73
|
354
|
Chris@73
|
355 sleep 2
|
Chris@73
|
356 load_a_file
|
Chris@73
|
357 sv-command loop on
|
Chris@73
|
358
|
Chris@73
|
359 sv-command resize 1024 500
|
Chris@73
|
360 show_stuff
|
Chris@73
|
361 sleep 10
|
Chris@73
|
362 playback_bits
|
Chris@73
|
363
|
Chris@73
|
364 sv-command resize 1024 700
|
Chris@73
|
365 show_stuff
|
Chris@73
|
366 #sleep 10
|
Chris@73
|
367 spectrogram_bits
|
Chris@73
|
368
|
Chris@73
|
369 sv-command jump 0
|
Chris@73
|
370 sv-command resize 1024 700
|
Chris@73
|
371 show_stuff
|
Chris@73
|
372 sleep 10
|
Chris@73
|
373 onset_bits
|
Chris@73
|
374
|
Chris@73
|
375 selection_bits
|
Chris@73
|
376
|
Chris@73
|
377 sv-command resize 1024 700
|
Chris@73
|
378
|
Chris@73
|
379 sv-command jump 0
|
Chris@73
|
380 chromagram_bits
|
Chris@73
|
381
|
Chris@73
|
382 sleep 20
|
Chris@73
|
383
|
Chris@73
|
384 pid="`pidof sonic-visualiser`"
|
Chris@73
|
385 if [ -n "$pid" ]; then
|
Chris@73
|
386 kill "$pid"
|
Chris@74
|
387 sleep 5
|
Chris@73
|
388 else
|
Chris@73
|
389 reset
|
Chris@73
|
390 fi
|
Chris@73
|
391
|
Chris@73
|
392 done
|