Chris@73: #!/bin/bash Chris@73: Chris@73: audio=$HOME/music Chris@73: preferred=$audio/ogg/linux Chris@73: list=audiofiles.txt Chris@73: used=audiofiles-used.txt Chris@73: Chris@73: sv-command quit Chris@73: Chris@73: pick_file() Chris@73: { 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@73: ( setsid ../sonic-visualiser & ) Chris@73: sleep 2 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@73: 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@73: 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@73: sv-command setcurrent 1 1 Chris@73: sv-command delete layer Chris@73: 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@73: 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@73: sv-command set speedup "$speed" Chris@73: sleep 1 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@73: sv-command set layer Window-Size 4096 Chris@73: # sv-command set layer Window-Overlap 4 Chris@73: 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@73: sleep 0.1 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@73: sleep 0.1 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@73: sv-command set pane Follow-Playback Scroll Chris@73: sv-command jump 10 Chris@73: sv-command setcurrent 1 2 Chris@73: sv-command set layer Colour Blue Chris@73: sleep 5 Chris@73: hide_stuff Chris@73: fade_in Chris@73: sleep 10 Chris@73: scroll_and_zoom Chris@73: sleep 10 Chris@73: slow Chris@73: #sv-command set layer Normalize-Visible-Area on Chris@73: for zoom in 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1; do Chris@73: sv-command zoom $zoom Chris@73: sleep 0.1 Chris@73: done Chris@73: sleep 8 Chris@73: fade_out Chris@73: done_playback_bits=1 Chris@73: } Chris@73: Chris@73: spectrogram_bits() Chris@73: { Chris@73: add_melodic_range_spectrogram Chris@73: sv-command zoom 256 Chris@73: sleep 10 Chris@73: zoom_in_spectrogram Chris@73: sleep 20 Chris@73: Chris@73: if [ -n "$done_playback_bits" ]; then Chris@73: sv-command setcurrent 1 Chris@73: sv-command zoom out Chris@73: sv-command zoom out Chris@73: sv-command zoom out Chris@73: sv-command zoom out Chris@73: sv-command zoom out Chris@73: sv-command setcurrent 2 Chris@73: fi Chris@73: Chris@73: hide_stuff Chris@73: fade_in Chris@73: sleep 10 Chris@73: sv-command set layer Bin-Display Frequencies Chris@73: sv-command set layer Normalize-Columns on Chris@73: sleep 20 Chris@73: sv-command set layer Bin-Display "All Bins" Chris@73: sv-command set layer Colour "Red on Blue" Chris@73: sleep 10 Chris@73: fade_out Chris@73: sleep 1 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@73: sv-command setcurrent 1 Chris@73: sv-command set pane Global-Zoom on Chris@73: sv-command set pane Global-Scroll on Chris@73: sleep 5 Chris@73: sv-command zoom default Chris@73: sv-command zoom in Chris@73: sv-command zoom in Chris@73: sv-command zoom in Chris@73: sv-command add timeruler Chris@73: sv-command transform vamp:vamp-aubio:aubioonset:detectionfunction Chris@73: sleep 5 Chris@73: sv-command set layer Plot-Type Curve Chris@73: sleep 5 Chris@73: sv-command setcurrent 1 Chris@73: sv-command set pane Follow-Playback Page Chris@73: sv-command transform vamp:vamp-aubio:aubioonset:detectionfunction Chris@73: sv-command set layer Colour Red Chris@73: sleep 5 Chris@73: sv-command set layer Plot-Type Segmentation Chris@73: # sv-command set layer Vertical-Scale "Log Scale" Chris@73: sv-command jump 30 Chris@73: sleep 5 Chris@73: # hide_stuff Chris@73: if [ -n "$done_spectrogram_bits" ]; then Chris@73: sv-command setcurrent 2 Chris@73: sv-command delete pane Chris@73: fi Chris@73: sleep 10 Chris@73: sv-command setcurrent 1 1 Chris@73: sv-command set layer Colour Black Chris@73: sv-command setcurrent 1 2 Chris@73: fade_in Chris@73: sleep 5 Chris@73: sv-command transform vamp:vamp-aubio:aubioonset:onsets Chris@73: sv-command set layer Colour Black Chris@73: sleep 20 Chris@73: sv-command setcurrent 2 Chris@73: # sv-command transform vamp:qm-vamp-plugins:qm-tempotracker:beats Chris@73: sv-command transform vamp:vamp-aubio:aubiotempo:beats Chris@73: sleep 10 Chris@73: fade_out Chris@73: 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@73: sv-command setcurrent 2 Chris@73: sv-command delete pane Chris@73: if [ -n "$done_playback_bits" ]; then Chris@73: sv-command setcurrent 1 2 Chris@73: else Chris@73: sv-command setcurrent 1 3 Chris@73: fi Chris@73: sv-command delete layer Chris@73: if [ -n "$done_playback_bits" ]; then Chris@73: sv-command setcurrent 1 2 Chris@73: else Chris@73: sv-command setcurrent 1 3 Chris@73: fi Chris@73: sv-command delete layer Chris@73: # sv-command transform vamp:qm-vamp-plugins:qm-tempotracker:beats Chris@73: sv-command transform vamp:vamp-aubio:aubiotempo:beats Chris@73: sv-command setcurrent 1 2 Chris@73: sv-command set layer Colour Orange Chris@73: sv-command setcurrent 1 3 Chris@73: sv-command resize 1024 500 Chris@73: sv-command zoom default Chris@73: sleep 10 Chris@73: sv-command loop on Chris@73: base=$((RANDOM % 100)) Chris@73: sv-command select $base $base.3 Chris@73: fade_in selection Chris@73: sleep 12 Chris@73: base=$((base + 4)) Chris@73: sv-command addselect $base $base.1 Chris@73: sleep 12 Chris@73: base=$((base + 2)) Chris@73: sv-command addselect $base $base.1 Chris@73: sleep 6 Chris@73: base=$((base + 2)) Chris@73: sv-command addselect $base $base.3 Chris@73: sleep 6 Chris@73: base=$((base + 3)) Chris@73: sv-command addselect $base $base.3 Chris@73: sleep 6 Chris@73: base=$((base + 2)) Chris@73: sv-command addselect $base $base.3 Chris@73: sleep 12 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@73: sleep 20 Chris@73: sv-command select none Chris@73: sv-command setcurrent 1 3 Chris@73: 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@73: add_melodic_range_spectrogram Chris@74: sleep 10 Chris@73: sv-command add timeruler Chris@73: sv-command transform vamp:qm-vamp-plugins:qm-chromagram:chromagram Chris@73: sleep 2 Chris@73: sv-command jump 20 Chris@73: sleep 10 Chris@73: sv-command zoom out Chris@73: fade_in Chris@74: sleep 15 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@73: sv-command resize 1024 500 Chris@73: show_stuff Chris@73: sleep 10 Chris@73: playback_bits Chris@73: Chris@73: sv-command resize 1024 700 Chris@73: show_stuff Chris@73: #sleep 10 Chris@73: spectrogram_bits Chris@73: Chris@73: sv-command jump 0 Chris@73: sv-command resize 1024 700 Chris@73: show_stuff Chris@73: sleep 10 Chris@73: onset_bits Chris@73: Chris@73: selection_bits Chris@73: Chris@73: sv-command resize 1024 700 Chris@73: Chris@73: sv-command jump 0 Chris@73: chromagram_bits Chris@73: Chris@73: sleep 20 Chris@73: Chris@73: pid="`pidof sonic-visualiser`" Chris@73: if [ -n "$pid" ]; then Chris@73: kill "$pid" Chris@74: sleep 5 Chris@73: else Chris@73: reset Chris@73: fi Chris@73: Chris@73: done