Mercurial > hg > svcore
comparison data/osc/demoscript.sh @ 320:32e50b620a6c
* Move some things around to facilitate plundering libraries for other
applications without needing to duplicate so much code.
sv/osc -> data/osc
sv/audioio -> audioio
sv/transform -> plugin/transform
sv/document -> document (will rename to framework in next commit)
author | Chris Cannam |
---|---|
date | Wed, 24 Oct 2007 16:34:31 +0000 |
parents | |
children | 7419a063878b |
comparison
equal
deleted
inserted
replaced
319:3ff8f571da09 | 320:32e50b620a6c |
---|---|
1 #!/bin/bash | |
2 | |
3 audio=/data/music | |
4 preferred=$audio/free | |
5 list=audiofiles.txt | |
6 used=audiofiles-used.txt | |
7 | |
8 df=vamp:vamp-aubio:aubioonset:detectionfunction | |
9 #df=vamp:qm-vamp-plugins:qm-tempotracker:detection_fn | |
10 onsets=vamp:vamp-aubio:aubioonset:onsets | |
11 #onsets=vamp:qm-vamp-plugins:qm-tempotracker:beats | |
12 beats=vamp:vamp-aubio:aubiotempo:beats | |
13 #beats=$onsets | |
14 #onsets=$beats | |
15 chromagram=vamp:qm-vamp-plugins:qm-chromagram:chromagram | |
16 notes=vamp:vamp-aubio:aubionotes:notes | |
17 | |
18 pid=`cat /tmp/demoscript.pid 2>/dev/null` | |
19 if [ -n "$pid" ]; then | |
20 kill "$pid" | |
21 fi | |
22 echo $$ > /tmp/demoscript.pid | |
23 trap "rm /tmp/demoscript.pid" 0 | |
24 | |
25 sv-command quit | |
26 sleep 1 | |
27 killall -9 sonic-visualiser | |
28 sleep 1 | |
29 | |
30 pick_file() | |
31 { | |
32 file="" | |
33 count=`wc -l "$list" 2>/dev/null | awk '{ print $1 }'` | |
34 if [ ! -f "$list" ] || [ "$count" -eq "0" ] ; then | |
35 find "$audio" -name \*.ogg -print >> "$list" | |
36 find "$audio" -name \*.mp3 -print >> "$list" | |
37 find "$audio" -name \*.wav -print >> "$list" | |
38 find "$preferred" -name \*.ogg -print >> "$list" | |
39 find "$preferred" -name \*.mp3 -print >> "$list" | |
40 find "$preferred" -name \*.wav -print >> "$list" | |
41 count=`wc -l "$list" 2>/dev/null | awk '{ print $1 }'` | |
42 fi | |
43 while [ -z "$file" ]; do | |
44 index=$((RANDOM % $count)) | |
45 file=`tail +"$index" "$list" | head -1` | |
46 [ -f "$file" ] || continue | |
47 done | |
48 fgrep -v "$file" "$list" > "$list"_ && mv "$list"_ "$list" | |
49 echo "$file" | |
50 } | |
51 | |
52 load_a_file() | |
53 { | |
54 file=`pick_file` | |
55 if ! sv-command open "$file"; then | |
56 pid="`pidof sonic-visualiser`" | |
57 if [ -z "$pid" ]; then | |
58 ( setsid sonic-visualiser -geometry 1000x500+10+100 & ) | |
59 sleep 2 | |
60 sudo renice +19 `pidof sonic-visualiser` | |
61 sudo renice +18 `pidof Xorg` | |
62 sv-command resize 1000 500 | |
63 load_a_file | |
64 else | |
65 echo "ERROR: Unable to contact sonic-visualiser pid $pid" 1>&2 | |
66 exit 1 | |
67 fi | |
68 fi | |
69 } | |
70 | |
71 show_stuff() | |
72 { | |
73 sv-command set overlays 2 | |
74 # sv-command set zoomwheels 1 | |
75 sv-command set propertyboxes 1 | |
76 } | |
77 | |
78 hide_stuff() | |
79 { | |
80 sv-command set overlays 0 | |
81 # sv-command set zoomwheels 0 | |
82 sv-command set propertyboxes 0 | |
83 } | |
84 | |
85 reset() | |
86 { | |
87 for pane in 1 2 3 4 5; do | |
88 for layer in 1 2 3 4 5 6 7 8 9 10; do | |
89 sv-command delete layer | |
90 done | |
91 sv-command delete pane | |
92 done | |
93 sv-command zoom default | |
94 sv-command add waveform | |
95 show_stuff | |
96 } | |
97 | |
98 scroll_and_zoom() | |
99 { | |
100 sv-command set overlays 0 | |
101 sv-command set zoomwheels 0 | |
102 sv-command set propertyboxes 0 | |
103 # sv-command setcurrent 1 1 | |
104 # sv-command delete layer | |
105 # sv-command setcurrent 1 1 | |
106 sv-command set layer Colour Red | |
107 sleep 1 | |
108 sv-command set pane Global-Zoom off | |
109 sv-command set pane Global-Scroll off | |
110 sv-command set pane Follow-Playback Scroll | |
111 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 | |
112 sv-command zoom $zoom | |
113 sleep 0.1 | |
114 done | |
115 } | |
116 | |
117 play() | |
118 { | |
119 sv-command play "$@" | |
120 } | |
121 | |
122 fade_in() | |
123 { | |
124 sv-command set gain 0 | |
125 sleep 0.5 | |
126 play "$@" | |
127 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 | |
128 sv-command set gain $gain | |
129 sleep 0.1 | |
130 done | |
131 } | |
132 | |
133 fade_out() | |
134 { | |
135 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 | |
136 sv-command set gain $gain | |
137 sleep 0.1 | |
138 done | |
139 stop | |
140 sv-command set gain 1 | |
141 } | |
142 | |
143 slow() | |
144 { | |
145 # for speed in -1 -10 -20 -30 -40 -50 -60 -70 -80 -100 -140 -200 -250 -300 -400 -500 -700 -800 -900 -1000; do | |
146 # sv-command set speedup "$speed" | |
147 # sleep 1 | |
148 # done | |
149 for speed in -20 -100 -1000; do | |
150 sv-command set speedup "$speed" | |
151 sleep 10 | |
152 done | |
153 } | |
154 | |
155 stop() | |
156 { | |
157 sv-command stop "$@" | |
158 sv-command set speedup 0 | |
159 } | |
160 | |
161 quit() | |
162 { | |
163 sv-command quit | |
164 } | |
165 | |
166 add_melodic_range_spectrogram() | |
167 { | |
168 sv-command set propertyboxes 1 | |
169 sv-command add spectrogram | |
170 sv-command set layer Window-Size 8192 | |
171 # sv-command set layer Window-Size 4096 | |
172 sv-command set layer Window-Overlap 4 | |
173 # sv-command set layer Window-Overlap 3 | |
174 sv-command set layer Frequency-Scale Log | |
175 sv-command set layer Colour-Scale Meter | |
176 } | |
177 | |
178 zoom_in_spectrogram() | |
179 { | |
180 sv-command zoomvertical 43 8000 | |
181 for x in 1 2 3 4 5 6; do | |
182 max=$((8000 - 1000*$x)) | |
183 sv-command zoomvertical 43 "$max" | |
184 sleep 0.5 | |
185 done | |
186 for x in 1 2 3 4 5; do | |
187 max=$((2000 - 100 * $x)) | |
188 sv-command zoomvertical 43 "$max" | |
189 sleep 0.5 | |
190 done | |
191 } | |
192 | |
193 zoom_in_spectrogram_further() | |
194 { | |
195 for x in 1 2 3 4 5; do | |
196 sv-command zoomvertical in | |
197 done | |
198 } | |
199 | |
200 playback_bits() | |
201 { | |
202 sv-command setcurrent 1 | |
203 sv-command set pane Global-Zoom off | |
204 sv-command set pane Global-Scroll off | |
205 sv-command set pane Follow-Playback Scroll | |
206 sv-command jump 10 | |
207 sv-command setcurrent 1 1 | |
208 sv-command delete layer | |
209 sv-command setcurrent 1 1 | |
210 # sv-command setcurrent 1 2 | |
211 sv-command set layer Colour Blue | |
212 sleep 5 | |
213 hide_stuff | |
214 sv-command set overlays 0 | |
215 sv-command set zoomwheels 0 | |
216 sv-command set propertyboxes 0 | |
217 fade_in | |
218 sleep 10 | |
219 # sv-command set layer Colour Blue | |
220 # sleep 1 | |
221 # sv-command set layer Colour Orange | |
222 # sleep 1 | |
223 # sv-command set layer Colour Red | |
224 # sleep 1 | |
225 # sv-command set layer Colour Green | |
226 # sleep 1 | |
227 # sleep 1 | |
228 | |
229 | |
230 # scroll_and_zoom | |
231 | |
232 # sv-command set overlays 0 | |
233 # sv-command set zoomwheels 0 | |
234 # sv-command set propertyboxes 0 | |
235 # sv-command setcurrent 1 1 | |
236 # sv-command delete layer | |
237 # sv-command setcurrent 1 1 | |
238 # sv-command set layer Colour Red | |
239 # sleep 1 | |
240 # sv-command set pane Global-Zoom off | |
241 # sv-command set pane Global-Scroll off | |
242 # sv-command set pane Follow-Playback Scroll | |
243 sv-command set zoomwheels 1 | |
244 sleep 1 | |
245 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 | |
246 sv-command zoom $zoom | |
247 sleep 0.1 | |
248 done | |
249 | |
250 sleep 1 | |
251 sv-command set zoomwheels 0 | |
252 sv-command zoom 16 | |
253 | |
254 sleep 10 | |
255 #slow | |
256 #sv-command set layer Normalize-Visible-Area on | |
257 # for zoom in 15 14 13 12 11 10 9 8 7 6 5 4 ; do | |
258 # sv-command zoom $zoom | |
259 # sleep 0.1 | |
260 # done | |
261 sleep 1 | |
262 sv-command set zoomwheels 0 | |
263 slow | |
264 sleep 7 | |
265 fade_out | |
266 sv-command setcurrent 1 | |
267 sv-command set pane Follow-Playback Page | |
268 sv-command set pane Global-Zoom on | |
269 sv-command set pane Global-Scroll on | |
270 done_playback_bits=1 | |
271 } | |
272 | |
273 spectrogram_bits() | |
274 { | |
275 sv-command set pane Global-Zoom on | |
276 sv-command zoom 1024 | |
277 add_melodic_range_spectrogram | |
278 sv-command zoom 1024 | |
279 sleep 5 | |
280 sv-command jump 10 | |
281 sleep 20 | |
282 zoom_in_spectrogram | |
283 sleep 20 | |
284 | |
285 sv-command select 7.5 11 | |
286 fade_in selection | |
287 sleep 10 | |
288 sv-command set speedup -200 | |
289 sleep 10 | |
290 sv-command setcurrent 1 | |
291 sv-command delete pane | |
292 sv-command zoom in | |
293 sv-command setcurrent 1 2 | |
294 sv-command set layer Normalize-Columns off | |
295 sv-command set layer Normalize-Visible-Area on | |
296 sleep 20 | |
297 sv-command set speedup 0 | |
298 sleep 10 | |
299 sv-command select none | |
300 # fade_out | |
301 | |
302 # if [ -n "$done_playback_bits" ]; then | |
303 # sv-command setcurrent 1 | |
304 # sv-command zoom out | |
305 # sv-command zoom outvamp:qm-vamp-plugins:qm-chromagram:chromagram | |
306 # sv-command zoom out | |
307 # sv-command zoom out | |
308 # sv-command zoom out | |
309 # sv-command setcurrent 2 | |
310 # fi | |
311 | |
312 # hide_stuff | |
313 # fade_in | |
314 sleep 10 | |
315 # sv-command set layer Bin-Display Frequencies | |
316 # sv-command set layer Normalize-Columns on | |
317 # sleep 20 | |
318 sv-command set layer Bin-Display "All Bins" | |
319 sv-command set layer Normalize-Columns on | |
320 sv-command set layer Normalize-Visible-Area off | |
321 sv-command set layer Colour-Scale 0 | |
322 sv-command set layer Colour "Red on Blue" | |
323 sv-command zoomvertical 23 800 | |
324 sleep 20 | |
325 sv-command transform $onsets | |
326 sv-command set layer Colour Orange | |
327 sleep 20 | |
328 fade_out | |
329 sleep 1 | |
330 # sv-command jump 10 | |
331 # sv-command setcurrent 1 2 | |
332 # sv-command set layer Colour "Black on White" | |
333 # sv-command transform $notes | |
334 # sv-command set layer Colour Orange | |
335 sleep 10 | |
336 # sv-command setcurrent 1 3 | |
337 # sv-command delete layer | |
338 sv-command setcurrent 1 3 | |
339 sv-command delete layer | |
340 sv-command setcurrent 1 2 | |
341 sv-command set layer Colour Default | |
342 done_spectrogram_bits=1 | |
343 | |
344 # zoom_in_spectrogram_further | |
345 } | |
346 | |
347 onset_bits() | |
348 { | |
349 show_stuff | |
350 sv-command set zoomwheels 0 | |
351 sv-command setcurrent 1 | |
352 sv-command set pane Global-Zoom on | |
353 sv-command set pane Global-Scroll on | |
354 sleep 0.5 | |
355 sv-command set layer Colour Blue | |
356 sleep 0.5 | |
357 sv-command set layer Colour Orange | |
358 sleep 0.5 | |
359 sv-command set layer Colour Red | |
360 sleep 0.5 | |
361 sv-command set layer Colour Green | |
362 sleep 1 | |
363 # sleep 1 | |
364 # if [ -n "$done_spectrogram_bits" ]; then | |
365 # sv-command setcurrent 2 | |
366 # sv-command delete pane | |
367 # fi | |
368 # sv-command zoom default | |
369 # sv-command zoom in | |
370 # sv-command zoom in | |
371 # sv-command zoom in | |
372 sv-command zoom 192 | |
373 sv-command zoom in | |
374 sv-command add timeruler | |
375 sv-command jump 0 | |
376 sv-command transform $df | |
377 sv-command set layer Colour Black | |
378 sleep 5 | |
379 sv-command set layer Plot-Type Curve | |
380 sleep 5 | |
381 sv-command jump 30 | |
382 sv-command setcurrent 1 | |
383 sv-command set pane Follow-Playback Page | |
384 sv-command transform $df | |
385 sv-command set layer Colour Red | |
386 sleep 5 | |
387 sv-command jump 30 | |
388 sleep 5 | |
389 if [ "$RANDOM" -lt 16384 ]; then | |
390 sv-command set layer Vertical-Scale "Log Scale" | |
391 fi | |
392 sv-command set layer Plot-Type Segmentation | |
393 sleep 5 | |
394 # hide_stuff | |
395 sleep 10 | |
396 sv-command set overlays 0 | |
397 sv-command set propertyboxes 0 | |
398 # sv-command setcurrent 1 1 | |
399 # sv-command set layer Colour Black | |
400 # sv-command setcurrent 1 2 | |
401 sleep 2 | |
402 fade_in | |
403 sleep 2 | |
404 sv-command transform $onsets | |
405 sv-command set layer Colour Black | |
406 sv-command setcurrent 2 | |
407 sv-command transform $onsets | |
408 sv-command set layer Colour Blue | |
409 sleep 20 | |
410 # sv-command setcurrent 2 | |
411 # sv-command transform vamp:qm-vamp-plugins:qm-tempotracker:beats | |
412 # sv-command transform $beats | |
413 sleep 20 | |
414 # fade_out | |
415 # show_stuff | |
416 } | |
417 | |
418 selection_bits() | |
419 { | |
420 # reset | |
421 sv-command set overlays 1 | |
422 sv-command set zoomwheels 0 | |
423 sv-command resize 1000 500 | |
424 sv-command zoom default | |
425 sv-command setcurrent 2 | |
426 sv-command delete pane | |
427 # if [ -n "$done_playback_bits" ]; then | |
428 sv-command setcurrent 1 2 | |
429 # else | |
430 # sv-command setcurrent 1 3 | |
431 # fi | |
432 sv-command delete layer | |
433 # if [ -n "$done_playback_bits" ]; then | |
434 sv-command setcurrent 1 2 | |
435 # else | |
436 # sv-command setcurrent 1 3 | |
437 # fi | |
438 sv-command delete layer | |
439 sv-command setcurrent 1 2 | |
440 sv-command set layer Colour Orange | |
441 # sv-command transform vamp:qm-vamp-plugins:qm-tempotracker:beats | |
442 sv-command transform $beats | |
443 # sv-command setcurrent 1 2 | |
444 sv-command set layer Colour Black | |
445 sleep 20 | |
446 sv-command loop on | |
447 base=$((RANDOM % 100)) | |
448 sv-command select $base $base.3 | |
449 # fade_in selection | |
450 play selection | |
451 sleep 8 | |
452 base=$((base + 4)) | |
453 sv-command addselect $base $base.1 | |
454 #sleep 12 | |
455 base=$((base + 2)) | |
456 sv-command addselect $base $base.1 | |
457 #sleep 6 | |
458 base=$((base + 2)) | |
459 sv-command addselect $base $base.3 | |
460 #sleep 6 | |
461 base=$((base + 3)) | |
462 sv-command addselect $base $base.3 | |
463 #sleep 6 | |
464 base=$((base + 2)) | |
465 sv-command addselect $base $base.3 | |
466 sleep 4 | |
467 sv-command delete layer | |
468 sleep 16 | |
469 sv-command set speedup -50 | |
470 sleep 14 | |
471 sv-command set speedup 50 | |
472 sleep 8 | |
473 sv-command set speedup 100 | |
474 sleep 5 | |
475 sv-command set speedup 200 | |
476 fade_out | |
477 # sleep 10 | |
478 sv-command select none | |
479 sv-command set overlays 2 | |
480 sv-command set propertyboxes 1 | |
481 # sv-command setcurrent 1 3 | |
482 # sv-command delete layer | |
483 sv-command setcurrent 1 2 | |
484 sv-command set layer Colour Black | |
485 } | |
486 | |
487 chromagram_bits() | |
488 { | |
489 # add_melodic_range_spectrogram | |
490 # sleep 10 | |
491 sv-command add timeruler | |
492 sleep 5 | |
493 sv-command jump 10 | |
494 sv-command zoom out | |
495 sleep 5 | |
496 sv-command transform $chromagram | |
497 sleep 40 | |
498 sv-command zoom out | |
499 fade_in | |
500 sleep 20 | |
501 fade_out | |
502 } | |
503 | |
504 while /bin/true; do | |
505 | |
506 sleep 2 | |
507 load_a_file | |
508 sv-command loop on | |
509 | |
510 sv-command resize 1000 500 | |
511 show_stuff | |
512 sleep 5 | |
513 sleep 20 | |
514 playback_bits | |
515 | |
516 #sleep 10 | |
517 sv-command resize 1000 700 | |
518 sv-command zoom default | |
519 show_stuff | |
520 onset_bits | |
521 | |
522 selection_bits | |
523 | |
524 #sv-command resize 1000 700 | |
525 | |
526 #sleep 10 | |
527 sv-command resize 1000 700 | |
528 #show_stuff | |
529 spectrogram_bits | |
530 | |
531 #sleep 10 | |
532 #sv-command jump 0 | |
533 #show_stuff | |
534 #chromagram_bits | |
535 | |
536 sleep 20 | |
537 | |
538 #reset | |
539 killall -9 sonic-visualiser | |
540 | |
541 done |