comparison data/osc/sv-command @ 320:32e50b620a6c

* Move some things around to facilitate plundering libraries for other applications without needing to duplicate so much code. sv/osc -> data/osc sv/audioio -> audioio sv/transform -> plugin/transform sv/document -> document (will rename to framework in next commit)
author Chris Cannam
date Wed, 24 Oct 2007 16:34:31 +0000
parents
children
comparison
equal deleted inserted replaced
319:3ff8f571da09 320:32e50b620a6c
1 #!/bin/sh
2 #
3 # A very simple command shell for Sonic Visualiser.
4 #
5 # This provides a wrapper for the sv-osc-send program, which is a
6 # generic OSC sending program (not specific to SV, despite its name).
7 # This script attempts to guess the OSC port number for an SV
8 # process running on the local host, and then composes a method name
9 # and arguments into a complete OSC call.
10 #
11 # You can either run this with the method and its arguments on the
12 # command line, e.g. "sv-command set layer Frequency-Scale Log", or
13 # you can provide a series of method + argument commands on stdin.
14 #
15 # Unless you use the -q option, this script will echo the OSC URL
16 # and arguments that it is sending for each command.
17 #
18 # Note that the method and arguments may not contain spaces.
19 #
20 # Chris Cannam, Nov 2006
21
22 quiet=
23 if [ "$1" = "-q" ]; then
24 quiet=true; shift;
25 fi
26
27 # The yucky bit
28
29 port=`lsof -c sonic- | \
30 grep UDP | \
31 sed -e 's/^.*[^0-9]\([0-9][0-9]*\) *$/\1/' | \
32 grep -v ' ' | \
33 head -1 `
34
35 host=127.0.0.1
36 scheme=osc.udp
37
38 if [ -z "$port" ]; then
39 echo "Sonic Visualiser OSC port not found"
40 exit 1
41 fi
42
43 if [ -n "$1" ]; then
44 command=$1; shift
45 [ -z "$quiet" ] && echo "$scheme://$host:$port/$command" "$@"
46 sv-osc-send "$scheme://$host:$port/$command" "$@"
47 else
48 while read command a1 a2 a3 a4 a5; do
49 [ -z "$command" ] && continue
50 [ -z "$quiet" ] && echo "$scheme://$host:$port/$command" $a1 $a2 $a3 $a4 $a5
51 sv-osc-send "$scheme://$host:$port/$command" $a1 $a2 $a3 $a4 $a5
52 done
53 fi
54
55 exit 0