1.1.2
by Jaakko Sipari
Import upstream version 1.4.7 |
1 |
#!/usr/bin/python
|
2 |
# ecarack: use ecasound to run a saved JACK Rack configuration.
|
|
3 |
# This is rather simplistic: it only looks at plugin controls and the Enable
|
|
4 |
# buttons, so MIDI controls, wet/dry settings and the like will be ignored.
|
|
5 |
# Copyright (C) 2007 Adam Sampson <ats@offog.org>
|
|
6 |
#
|
|
7 |
# This program is free software; you can redistribute it and/or modify
|
|
8 |
# it under the terms of the GNU General Public License as published by
|
|
9 |
# the Free Software Foundation; either version 2 of the License, or
|
|
10 |
# (at your option) any later version.
|
|
11 |
#
|
|
12 |
# This program is distributed in the hope that it will be useful,
|
|
13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 |
# GNU General Public License for more details.
|
|
16 |
#
|
|
17 |
# You should have received a copy of the GNU General Public License
|
|
18 |
# along with this program; if not, write to the Free Software
|
|
19 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
20 |
||
21 |
import sys, os, gzip, xml.dom.minidom |
|
22 |
||
23 |
def main(args): |
|
24 |
if len(args) != 1 or args[0] == "--help": |
|
25 |
print >>sys.stderr, "Usage: ecarack RACK-FILE" |
|
26 |
return 1 |
|
27 |
||
28 |
try: |
|
29 |
f = gzip.open(args[0], "r") |
|
30 |
except IOError, e: |
|
31 |
print >>sys.stderr, "Failed to open %s: %s" % (args[0], e) |
|
32 |
return 1 |
|
33 |
try: |
|
34 |
dom = xml.dom.minidom.parse(f) |
|
35 |
except: |
|
36 |
print >>sys.stderr, "Failed to parse %s" % args[0] |
|
37 |
return 1 |
|
38 |
f.close() |
|
39 |
||
40 |
cmd = ["ecasound", "-i:jack_auto", "-o:jack_auto"] |
|
41 |
||
42 |
def get(node, tag): |
|
43 |
return node.getElementsByTagName(tag) |
|
44 |
def text(node): |
|
45 |
if node.nodeType == node.TEXT_NODE: |
|
46 |
return node.data |
|
47 |
else: |
|
48 |
return " ".join(map(text, node.childNodes)).strip() |
|
49 |
for plugin in get(dom, "plugin"): |
|
50 |
if text(get(plugin, "enabled")[0]) == "false": |
|
51 |
continue
|
|
52 |
id = text(get(plugin, "id")[0]) |
|
53 |
controls = [text(get(n, "value")[0]) |
|
54 |
for n in get(plugin, "controlrow")] |
|
55 |
cmd.append("-eli:" + id + "".join(["," + v for v in controls])) |
|
56 |
||
57 |
print >>sys.stderr, "ecarack: running " + " ".join(cmd) |
|
58 |
os.execvp(cmd[0], cmd) |
|
59 |
return 1 |
|
60 |
||
61 |
if __name__ == "__main__": |
|
62 |
sys.exit(main(sys.argv[1:])) |