Chris@320: #!/bin/sh Chris@320: # Chris@320: # A very simple command shell for Sonic Visualiser. Chris@320: # Chris@320: # This provides a wrapper for the sv-osc-send program, which is a Chris@320: # generic OSC sending program (not specific to SV, despite its name). Chris@320: # This script attempts to guess the OSC port number for an SV Chris@320: # process running on the local host, and then composes a method name Chris@320: # and arguments into a complete OSC call. Chris@320: # Chris@320: # You can either run this with the method and its arguments on the Chris@320: # command line, e.g. "sv-command set layer Frequency-Scale Log", or Chris@320: # you can provide a series of method + argument commands on stdin. Chris@320: # Chris@320: # Unless you use the -q option, this script will echo the OSC URL Chris@320: # and arguments that it is sending for each command. Chris@320: # Chris@320: # Note that the method and arguments may not contain spaces. Chris@320: # Chris@320: # Chris Cannam, Nov 2006 Chris@320: Chris@320: quiet= Chris@320: if [ "$1" = "-q" ]; then Chris@320: quiet=true; shift; Chris@320: fi Chris@320: Chris@320: # The yucky bit Chris@320: Chris@320: port=`lsof -c sonic- | \ Chris@320: grep UDP | \ Chris@320: sed -e 's/^.*[^0-9]\([0-9][0-9]*\) *$/\1/' | \ Chris@320: grep -v ' ' | \ Chris@320: head -1 ` Chris@320: Chris@320: host=127.0.0.1 Chris@320: scheme=osc.udp Chris@320: Chris@320: if [ -z "$port" ]; then Chris@320: echo "Sonic Visualiser OSC port not found" Chris@320: exit 1 Chris@320: fi Chris@320: Chris@320: if [ -n "$1" ]; then Chris@320: command=$1; shift Chris@320: [ -z "$quiet" ] && echo "$scheme://$host:$port/$command" "$@" Chris@320: sv-osc-send "$scheme://$host:$port/$command" "$@" Chris@320: else Chris@320: while read command a1 a2 a3 a4 a5; do Chris@320: [ -z "$command" ] && continue Chris@320: [ -z "$quiet" ] && echo "$scheme://$host:$port/$command" $a1 $a2 $a3 $a4 $a5 Chris@320: sv-osc-send "$scheme://$host:$port/$command" $a1 $a2 $a3 $a4 $a5 Chris@320: done Chris@320: fi Chris@320: Chris@320: exit 0