Mercurial > hg > sonic-visualiser
annotate osc/sv-command @ 128:6caf27d1e5e8
* Russian update from Alexandre, and a couple of i18n fixes
author | Chris Cannam |
---|---|
date | Mon, 02 Apr 2007 12:12:36 +0000 |
parents | e200055fe80b |
children |
rev | line source |
---|---|
Chris@69 | 1 #!/bin/sh |
Chris@70 | 2 # |
Chris@70 | 3 # A very simple command shell for Sonic Visualiser. |
Chris@70 | 4 # |
Chris@70 | 5 # This provides a wrapper for the sv-osc-send program, which is a |
Chris@70 | 6 # generic OSC sending program (not specific to SV, despite its name). |
Chris@70 | 7 # This script attempts to guess the OSC port number for an SV |
Chris@70 | 8 # process running on the local host, and then composes a method name |
Chris@70 | 9 # and arguments into a complete OSC call. |
Chris@70 | 10 # |
Chris@70 | 11 # You can either run this with the method and its arguments on the |
Chris@70 | 12 # command line, e.g. "sv-command set layer Frequency-Scale Log", or |
Chris@70 | 13 # you can provide a series of method + argument commands on stdin. |
Chris@70 | 14 # |
Chris@70 | 15 # Unless you use the -q option, this script will echo the OSC URL |
Chris@70 | 16 # and arguments that it is sending for each command. |
Chris@70 | 17 # |
Chris@70 | 18 # Note that the method and arguments may not contain spaces. |
Chris@70 | 19 # |
Chris@70 | 20 # Chris Cannam, Nov 2006 |
Chris@70 | 21 |
Chris@70 | 22 quiet= |
Chris@70 | 23 if [ "$1" = "-q" ]; then |
Chris@70 | 24 quiet=true; shift; |
Chris@70 | 25 fi |
Chris@70 | 26 |
Chris@70 | 27 # The yucky bit |
Chris@70 | 28 |
Chris@70 | 29 port=`lsof -c sonic- | \ |
Chris@70 | 30 grep UDP | \ |
Chris@70 | 31 sed -e 's/^.*[^0-9]\([0-9][0-9]*\) *$/\1/' | \ |
Chris@70 | 32 grep -v ' ' | \ |
Chris@70 | 33 head -1 ` |
Chris@70 | 34 |
Chris@70 | 35 host=127.0.0.1 |
Chris@70 | 36 scheme=osc.udp |
Chris@70 | 37 |
Chris@69 | 38 if [ -z "$port" ]; then |
Chris@69 | 39 echo "Sonic Visualiser OSC port not found" |
Chris@69 | 40 exit 1 |
Chris@69 | 41 fi |
Chris@70 | 42 |
Chris@69 | 43 if [ -n "$1" ]; then |
Chris@69 | 44 command=$1; shift |
Chris@70 | 45 [ -z "$quiet" ] && echo "$scheme://$host:$port/$command" "$@" |
Chris@70 | 46 sv-osc-send "$scheme://$host:$port/$command" "$@" |
Chris@69 | 47 else |
Chris@70 | 48 while read command a1 a2 a3 a4 a5; do |
Chris@70 | 49 [ -z "$command" ] && continue |
Chris@70 | 50 [ -z "$quiet" ] && echo "$scheme://$host:$port/$command" $a1 $a2 $a3 $a4 $a5 |
Chris@70 | 51 sv-osc-send "$scheme://$host:$port/$command" $a1 $a2 $a3 $a4 $a5 |
Chris@69 | 52 done |
Chris@69 | 53 fi |
Chris@69 | 54 |
Chris@73 | 55 exit 0 |