Chris@73: #!/bin/bash Chris@73: Chris@76: audio=/data/music Chris@76: preferred=$audio/free Chris@73: list=audiofiles.txt Chris@73: used=audiofiles-used.txt Chris@73: Chris@76: df=vamp:vamp-aubio:aubioonset:detectionfunction Chris@76: #df=vamp:qm-vamp-plugins:qm-tempotracker:detection_fn Chris@76: onsets=vamp:vamp-aubio:aubioonset:onsets Chris@76: #onsets=vamp:qm-vamp-plugins:qm-tempotracker:beats Chris@76: beats=vamp:vamp-aubio:aubiotempo:beats Chris@76: #beats=$onsets Chris@76: #onsets=$beats Chris@76: chromagram=vamp:qm-vamp-plugins:qm-chromagram:chromagram Chris@76: notes=vamp:vamp-aubio:aubionotes:notes Chris@76: Chris@76: pid=`cat /tmp/demoscript.pid 2>/dev/null` Chris@76: if [ -n "$pid" ]; then Chris@76: kill "$pid" Chris@76: fi Chris@76: echo $$ > /tmp/demoscript.pid Chris@76: trap "rm /tmp/demoscript.pid" 0 Chris@76: Chris@73: sv-command quit Chris@76: sleep 1 Chris@76: killall -9 sonic-visualiser Chris@76: sleep 1 Chris@73: Chris@73: pick_file() Chris@73: { Chris@76: file="" Chris@73: count=`wc -l "$list" 2>/dev/null | awk '{ print $1 }'` Chris@73: if [ ! -f "$list" ] || [ "$count" -eq "0" ] ; then Chris@73: find "$audio" -name \*.ogg -print >> "$list" Chris@73: find "$audio" -name \*.mp3 -print >> "$list" Chris@73: find "$audio" -name \*.wav -print >> "$list" Chris@73: find "$preferred" -name \*.ogg -print >> "$list" Chris@73: find "$preferred" -name \*.mp3 -print >> "$list" Chris@73: find "$preferred" -name \*.wav -print >> "$list" Chris@73: count=`wc -l "$list" 2>/dev/null | awk '{ print $1 }'` Chris@73: fi Chris@73: while [ -z "$file" ]; do Chris@73: index=$((RANDOM % $count)) Chris@73: file=`tail +"$index" "$list" | head -1` Chris@73: [ -f "$file" ] || continue Chris@73: done Chris@73: fgrep -v "$file" "$list" > "$list"_ && mv "$list"_ "$list" Chris@73: echo "$file" Chris@73: } Chris@73: Chris@73: load_a_file() Chris@73: { Chris@73: file=`pick_file` Chris@73: if ! sv-command open "$file"; then Chris@73: pid="`pidof sonic-visualiser`" Chris@73: if [ -z "$pid" ]; then Chris@76: ( setsid sonic-visualiser -geometry 1000x500+10+100 & ) Chris@73: sleep 2 Chris@76: sudo renice +19 `pidof sonic-visualiser` Chris@76: sudo renice +18 `pidof Xorg` Chris@76: sv-command resize 1000 500 Chris@73: load_a_file Chris@73: else Chris@73: echo "ERROR: Unable to contact sonic-visualiser pid $pid" 1>&2 Chris@73: exit 1 Chris@73: fi Chris@73: fi Chris@73: } Chris@73: Chris@73: show_stuff() Chris@73: { Chris@73: sv-command set overlays 2 Chris@76: # sv-command set zoomwheels 1 Chris@73: sv-command set propertyboxes 1 Chris@73: } Chris@73: Chris@73: hide_stuff() Chris@73: { Chris@73: sv-command set overlays 0 Chris@76: # sv-command set zoomwheels 0 Chris@73: sv-command set propertyboxes 0 Chris@73: } Chris@73: Chris@73: reset() Chris@73: { Chris@73: for pane in 1 2 3 4 5; do Chris@73: for layer in 1 2 3 4 5 6 7 8 9 10; do Chris@73: sv-command delete layer Chris@73: done Chris@73: sv-command delete pane Chris@73: done Chris@73: sv-command zoom default Chris@73: sv-command add waveform Chris@73: show_stuff Chris@73: } Chris@73: Chris@73: scroll_and_zoom() Chris@73: { Chris@73: sv-command set overlays 0 Chris@73: sv-command set zoomwheels 0 Chris@73: sv-command set propertyboxes 0 Chris@76: # sv-command setcurrent 1 1 Chris@76: # sv-command delete layer Chris@76: # sv-command setcurrent 1 1 Chris@73: sv-command set layer Colour Red Chris@73: sleep 1 Chris@73: sv-command set pane Global-Zoom off Chris@73: sv-command set pane Global-Scroll off Chris@73: sv-command set pane Follow-Playback Scroll Chris@73: 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: sv-command zoom $zoom Chris@73: sleep 0.1 Chris@73: done Chris@73: } Chris@73: Chris@73: play() Chris@73: { Chris@73: sv-command play "$@" Chris@73: } Chris@73: Chris@73: fade_in() Chris@73: { Chris@73: sv-command set gain 0 Chris@73: sleep 0.5 Chris@73: play "$@" Chris@73: 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: sv-command set gain $gain Chris@73: sleep 0.1 Chris@73: done Chris@73: } Chris@73: Chris@73: fade_out() Chris@73: { Chris@73: 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: sv-command set gain $gain Chris@73: sleep 0.1 Chris@73: done Chris@73: stop Chris@73: sv-command set gain 1 Chris@73: } Chris@73: Chris@73: slow() Chris@73: { Chris@76: # 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@76: # sv-command set speedup "$speed" Chris@76: # sleep 1 Chris@76: # done Chris@76: for speed in -20 -100 -1000; do Chris@76: sv-command set speedup "$speed" Chris@76: sleep 10 Chris@73: done Chris@73: } Chris@73: Chris@73: stop() Chris@73: { Chris@73: sv-command stop "$@" Chris@73: sv-command set speedup 0 Chris@73: } Chris@73: Chris@73: quit() Chris@73: { Chris@73: sv-command quit Chris@73: } Chris@73: Chris@73: add_melodic_range_spectrogram() Chris@73: { Chris@73: sv-command set propertyboxes 1 Chris@73: sv-command add spectrogram Chris@76: sv-command set layer Window-Size 8192 Chris@76: # sv-command set layer Window-Size 4096 Chris@76: sv-command set layer Window-Overlap 4 Chris@76: # sv-command set layer Window-Overlap 3 Chris@73: sv-command set layer Frequency-Scale Log Chris@73: sv-command set layer Colour-Scale Meter Chris@73: } Chris@73: Chris@73: zoom_in_spectrogram() Chris@73: { Chris@73: sv-command zoomvertical 43 8000 Chris@73: for x in 1 2 3 4 5 6; do Chris@73: max=$((8000 - 1000*$x)) Chris@73: sv-command zoomvertical 43 "$max" Chris@76: sleep 0.5 Chris@73: done Chris@73: for x in 1 2 3 4 5; do Chris@73: max=$((2000 - 100 * $x)) Chris@73: sv-command zoomvertical 43 "$max" Chris@76: sleep 0.5 Chris@73: done Chris@73: } Chris@73: Chris@73: zoom_in_spectrogram_further() Chris@73: { Chris@73: for x in 1 2 3 4 5; do Chris@73: sv-command zoomvertical in Chris@73: done Chris@73: } Chris@73: Chris@73: playback_bits() Chris@73: { Chris@76: sv-command setcurrent 1 Chris@76: sv-command set pane Global-Zoom off Chris@76: sv-command set pane Global-Scroll off Chris@73: sv-command set pane Follow-Playback Scroll Chris@73: sv-command jump 10 Chris@76: sv-command setcurrent 1 1 Chris@76: sv-command delete layer Chris@76: sv-command setcurrent 1 1 Chris@76: # sv-command setcurrent 1 2 Chris@73: sv-command set layer Colour Blue Chris@73: sleep 5 Chris@73: hide_stuff Chris@76: sv-command set overlays 0 Chris@76: sv-command set zoomwheels 0 Chris@76: sv-command set propertyboxes 0 Chris@73: fade_in Chris@73: sleep 10 Chris@76: # sv-command set layer Colour Blue Chris@76: # sleep 1 Chris@76: # sv-command set layer Colour Orange Chris@76: # sleep 1 Chris@76: # sv-command set layer Colour Red Chris@76: # sleep 1 Chris@76: # sv-command set layer Colour Green Chris@76: # sleep 1 Chris@76: # sleep 1 Chris@76: Chris@76: Chris@76: # scroll_and_zoom Chris@76: Chris@76: # sv-command set overlays 0 Chris@76: # sv-command set zoomwheels 0 Chris@76: # sv-command set propertyboxes 0 Chris@76: # sv-command setcurrent 1 1 Chris@76: # sv-command delete layer Chris@76: # sv-command setcurrent 1 1 Chris@76: # sv-command set layer Colour Red Chris@76: # sleep 1 Chris@76: # sv-command set pane Global-Zoom off Chris@76: # sv-command set pane Global-Scroll off Chris@76: # sv-command set pane Follow-Playback Scroll Chris@76: sv-command set zoomwheels 1 Chris@76: sleep 1 Chris@76: 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: sv-command zoom $zoom Chris@73: sleep 0.1 Chris@73: done Chris@76: Chris@76: sleep 1 Chris@76: sv-command set zoomwheels 0 Chris@76: sv-command zoom 16 Chris@76: Chris@76: sleep 10 Chris@76: #slow Chris@76: #sv-command set layer Normalize-Visible-Area on Chris@76: # for zoom in 15 14 13 12 11 10 9 8 7 6 5 4 ; do Chris@76: # sv-command zoom $zoom Chris@76: # sleep 0.1 Chris@76: # done Chris@76: sleep 1 Chris@76: sv-command set zoomwheels 0 Chris@76: slow Chris@76: sleep 7 Chris@73: fade_out Chris@76: sv-command setcurrent 1 Chris@76: sv-command set pane Follow-Playback Page Chris@76: sv-command set pane Global-Zoom on Chris@76: sv-command set pane Global-Scroll on Chris@73: done_playback_bits=1 Chris@73: } Chris@73: Chris@73: spectrogram_bits() Chris@73: { Chris@76: sv-command set pane Global-Zoom on Chris@76: sv-command zoom 1024 Chris@73: add_melodic_range_spectrogram Chris@76: sv-command zoom 1024 Chris@76: sleep 5 Chris@76: sv-command jump 10 Chris@76: sleep 20 Chris@73: zoom_in_spectrogram Chris@73: sleep 20 Chris@73: Chris@76: sv-command select 7.5 11 Chris@76: fade_in selection Chris@76: sleep 10 Chris@76: sv-command set speedup -200 Chris@76: sleep 10 Chris@76: sv-command setcurrent 1 Chris@76: sv-command delete pane Chris@76: sv-command zoom in Chris@76: sv-command setcurrent 1 2 Chris@76: sv-command set layer Normalize-Columns off Chris@76: sv-command set layer Normalize-Visible-Area on Chris@76: sleep 20 Chris@76: sv-command set speedup 0 Chris@76: sleep 10 Chris@76: sv-command select none Chris@76: # fade_out Chris@76: Chris@76: # if [ -n "$done_playback_bits" ]; then Chris@76: # sv-command setcurrent 1 Chris@76: # sv-command zoom out Chris@76: # sv-command zoom outvamp:qm-vamp-plugins:qm-chromagram:chromagram Chris@76: # sv-command zoom out Chris@76: # sv-command zoom out Chris@76: # sv-command zoom out Chris@76: # sv-command setcurrent 2 Chris@76: # fi Chris@73: Chris@76: # hide_stuff Chris@76: # fade_in Chris@73: sleep 10 Chris@76: # sv-command set layer Bin-Display Frequencies Chris@76: # sv-command set layer Normalize-Columns on Chris@76: # sleep 20 Chris@76: sv-command set layer Bin-Display "All Bins" Chris@73: sv-command set layer Normalize-Columns on Chris@76: sv-command set layer Normalize-Visible-Area off Chris@76: sv-command set layer Colour-Scale 0 Chris@76: sv-command set layer Colour "Red on Blue" Chris@76: sv-command zoomvertical 23 800 Chris@73: sleep 20 Chris@76: sv-command transform $onsets Chris@76: sv-command set layer Colour Orange Chris@76: sleep 20 Chris@73: fade_out Chris@73: sleep 1 Chris@76: # sv-command jump 10 Chris@76: # sv-command setcurrent 1 2 Chris@76: # sv-command set layer Colour "Black on White" Chris@76: # sv-command transform $notes Chris@76: # sv-command set layer Colour Orange Chris@76: sleep 10 Chris@76: # sv-command setcurrent 1 3 Chris@76: # sv-command delete layer Chris@76: sv-command setcurrent 1 3 Chris@76: sv-command delete layer Chris@76: sv-command setcurrent 1 2 Chris@76: sv-command set layer Colour Default Chris@73: done_spectrogram_bits=1 Chris@73: Chris@73: # zoom_in_spectrogram_further Chris@73: } Chris@73: Chris@73: onset_bits() Chris@73: { Chris@73: show_stuff Chris@76: sv-command set zoomwheels 0 Chris@73: sv-command setcurrent 1 Chris@73: sv-command set pane Global-Zoom on Chris@73: sv-command set pane Global-Scroll on Chris@76: sleep 0.5 Chris@76: sv-command set layer Colour Blue Chris@76: sleep 0.5 Chris@76: sv-command set layer Colour Orange Chris@76: sleep 0.5 Chris@76: sv-command set layer Colour Red Chris@76: sleep 0.5 Chris@76: sv-command set layer Colour Green Chris@76: sleep 1 Chris@76: # sleep 1 Chris@76: # if [ -n "$done_spectrogram_bits" ]; then Chris@76: # sv-command setcurrent 2 Chris@76: # sv-command delete pane Chris@76: # fi Chris@76: # sv-command zoom default Chris@76: # sv-command zoom in Chris@76: # sv-command zoom in Chris@76: # sv-command zoom in Chris@76: sv-command zoom 192 Chris@73: sv-command zoom in Chris@73: sv-command add timeruler Chris@76: sv-command jump 0 Chris@76: sv-command transform $df Chris@76: sv-command set layer Colour Black Chris@73: sleep 5 Chris@73: sv-command set layer Plot-Type Curve Chris@73: sleep 5 Chris@76: sv-command jump 30 Chris@73: sv-command setcurrent 1 Chris@73: sv-command set pane Follow-Playback Page Chris@76: sv-command transform $df Chris@73: sv-command set layer Colour Red Chris@73: sleep 5 Chris@73: sv-command jump 30 Chris@73: sleep 5 Chris@76: if [ "$RANDOM" -lt 16384 ]; then Chris@76: sv-command set layer Vertical-Scale "Log Scale" Chris@76: fi Chris@76: sv-command set layer Plot-Type Segmentation Chris@76: sleep 5 Chris@73: # hide_stuff Chris@73: sleep 10 Chris@76: sv-command set overlays 0 Chris@76: sv-command set propertyboxes 0 Chris@76: # sv-command setcurrent 1 1 Chris@76: # sv-command set layer Colour Black Chris@76: # sv-command setcurrent 1 2 Chris@76: sleep 2 Chris@76: fade_in Chris@76: sleep 2 Chris@76: sv-command transform $onsets Chris@73: sv-command set layer Colour Black Chris@76: sv-command setcurrent 2 Chris@76: sv-command transform $onsets Chris@76: sv-command set layer Colour Blue Chris@73: sleep 20 Chris@76: # sv-command setcurrent 2 Chris@73: # sv-command transform vamp:qm-vamp-plugins:qm-tempotracker:beats Chris@76: # sv-command transform $beats Chris@76: sleep 20 Chris@76: # fade_out Chris@76: # show_stuff Chris@73: } Chris@73: Chris@73: selection_bits() Chris@73: { Chris@73: # reset Chris@73: sv-command set overlays 1 Chris@73: sv-command set zoomwheels 0 Chris@76: sv-command resize 1000 500 Chris@76: sv-command zoom default Chris@73: sv-command setcurrent 2 Chris@73: sv-command delete pane Chris@76: # if [ -n "$done_playback_bits" ]; then Chris@73: sv-command setcurrent 1 2 Chris@76: # else Chris@76: # sv-command setcurrent 1 3 Chris@76: # fi Chris@73: sv-command delete layer Chris@76: # if [ -n "$done_playback_bits" ]; then Chris@73: sv-command setcurrent 1 2 Chris@76: # else Chris@76: # sv-command setcurrent 1 3 Chris@76: # fi Chris@73: sv-command delete layer Chris@73: sv-command setcurrent 1 2 Chris@73: sv-command set layer Colour Orange Chris@76: # sv-command transform vamp:qm-vamp-plugins:qm-tempotracker:beats Chris@76: sv-command transform $beats Chris@76: # sv-command setcurrent 1 2 Chris@76: sv-command set layer Colour Black Chris@76: sleep 20 Chris@73: sv-command loop on Chris@73: base=$((RANDOM % 100)) Chris@73: sv-command select $base $base.3 Chris@76: # fade_in selection Chris@76: play selection Chris@76: sleep 8 Chris@73: base=$((base + 4)) Chris@73: sv-command addselect $base $base.1 Chris@76: #sleep 12 Chris@73: base=$((base + 2)) Chris@73: sv-command addselect $base $base.1 Chris@76: #sleep 6 Chris@73: base=$((base + 2)) Chris@73: sv-command addselect $base $base.3 Chris@76: #sleep 6 Chris@73: base=$((base + 3)) Chris@73: sv-command addselect $base $base.3 Chris@76: #sleep 6 Chris@73: base=$((base + 2)) Chris@73: sv-command addselect $base $base.3 Chris@76: sleep 4 Chris@76: sv-command delete layer Chris@76: sleep 16 Chris@73: sv-command set speedup -50 Chris@73: sleep 14 Chris@73: sv-command set speedup 50 Chris@73: sleep 8 Chris@73: sv-command set speedup 100 Chris@73: sleep 5 Chris@73: sv-command set speedup 200 Chris@73: fade_out Chris@76: # sleep 10 Chris@73: sv-command select none Chris@76: sv-command set overlays 2 Chris@76: sv-command set propertyboxes 1 Chris@76: # sv-command setcurrent 1 3 Chris@76: # sv-command delete layer Chris@73: sv-command setcurrent 1 2 Chris@73: sv-command set layer Colour Black Chris@73: } Chris@73: Chris@73: chromagram_bits() Chris@73: { Chris@76: # add_melodic_range_spectrogram Chris@76: # sleep 10 Chris@73: sv-command add timeruler Chris@76: sleep 5 Chris@76: sv-command jump 10 Chris@76: sv-command zoom out Chris@76: sleep 5 Chris@76: sv-command transform $chromagram Chris@76: sleep 40 Chris@73: sv-command zoom out Chris@73: fade_in Chris@76: sleep 20 Chris@73: fade_out Chris@73: } Chris@73: Chris@73: while /bin/true; do Chris@73: Chris@73: sleep 2 Chris@73: load_a_file Chris@73: sv-command loop on Chris@73: Chris@76: sv-command resize 1000 500 Chris@73: show_stuff Chris@79: sleep 5 Chris@76: sleep 20 Chris@73: playback_bits Chris@73: Chris@76: #sleep 10 Chris@76: sv-command resize 1000 700 Chris@76: sv-command zoom default Chris@73: show_stuff Chris@73: onset_bits Chris@73: Chris@73: selection_bits Chris@73: Chris@76: #sv-command resize 1000 700 Chris@73: Chris@76: #sleep 10 Chris@76: sv-command resize 1000 700 Chris@76: #show_stuff Chris@76: spectrogram_bits Chris@76: Chris@76: #sleep 10 Chris@76: #sv-command jump 0 Chris@76: #show_stuff Chris@76: #chromagram_bits Chris@73: Chris@73: sleep 20 Chris@73: Chris@76: #reset Chris@76: killall -9 sonic-visualiser Chris@73: Chris@73: done