annotate data/osc/demoscript.sh @ 1737:5d631f6129fe by-id

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