comparison osc/demoscript.sh @ 73:e200055fe80b

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