annotate data/osc/demoscript.sh @ 723:21d39720d5da

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