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