annotate light8/rsn.py @ 17:43aa1ee8b3a9

some comments and garbage cleanup
author drewp
date Sun, 07 Jul 2002 06:43:40 +0000
parents 7dbe8067acea
children 6284a812da50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
1 #!/usr/bin/env python
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
2 from __future__ import nested_scopes
45b12307c695 Initial revision
drewp
parents:
diff changeset
3
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
4 from Tkinter import *
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
5 from time import sleep
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
6 from signal import *
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
7 import sys, thread, cPickle
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
8
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
9 import io
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
10 from uihelpers import *
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
11 from panels import *
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
12 from Xfader import *
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
13 import stage
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
14
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 if len(sys.argv) >= 2:
45b12307c695 Initial revision
drewp
parents:
diff changeset
16 DUMMY = 0
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
17 print "This is the real thing, baby"
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 window_title = "Light 8.8 (On Air)"
45b12307c695 Initial revision
drewp
parents:
diff changeset
19 else:
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 DUMMY = 1
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
21 print "Dummy mode"
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
22 window_title = "Light 8.8 (Bogus)"
45b12307c695 Initial revision
drewp
parents:
diff changeset
23
45b12307c695 Initial revision
drewp
parents:
diff changeset
24 root = Tk()
45b12307c695 Initial revision
drewp
parents:
diff changeset
25 root.wm_title(window_title)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
26 root.wm_geometry('+447+373')
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
27
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
28 import Subs, Patch
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
29
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
30 def get_data(*args):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
31 Subs.reload_data(DUMMY)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
32 Patch.reload_data(DUMMY)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
33 print "Patch:", Patch.patch
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
34 print "Subs:", ', '.join(Subs.subs.keys())
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
35
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
36 get_data()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
37
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
38 io.init(DUMMY)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
39
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
40 channel_levels = []
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
41 scalelevels = {}
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
42 fades = {}
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
43
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
44 _oldlevels=[None] * 68
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
45
17
43aa1ee8b3a9 some comments and garbage cleanup
drewp
parents: 16
diff changeset
46 # this is called on a loop, and ALSO by the Scales
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
47 def changelevel(*args):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
48 'Amp trims slider'
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
49 global _oldlevels
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
50
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
51 levels = [0] * 68
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
52 for name, s in Subs.subs.items():
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
53 newlevels = s.get_levels(level=scalelevels[name].get())
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
54 for (ch, fadelev) in newlevels.items():
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
55 levels[ch-1] = max(levels[ch-1], fadelev)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
56
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
57 levels = [int(l) for l in levels]
16
7dbe8067acea fixed bug with channel levels not displaying
drewp
parents: 12
diff changeset
58
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
59 for lev,lab,oldlev in zip(levels, channel_levels, _oldlevels):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
60 if lev != oldlev:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
61 lab.config(text="%d" % lev)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
62 colorlabel(lab)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
63
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
64 _oldlevels = levels[:]
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
65
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
66 io.sendlevels(levels)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
67
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
68 def backgroundloop(*args):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
69 root.after(50, backgroundloop, ())
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
70 changelevel()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
71
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
72 buildinterface = None # temporary
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
73 def refresh(*args):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
74 get_data()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
75 buildinterface()
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
76 bindkeys(root,'<Escape>', quit)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
77
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
78 def quit(*args):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
79 filename = '/tmp/light9.prefs'
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
80 if DUMMY:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
81 filename += '.dummy'
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
82 print "Saving to", filename
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
83 file = open(filename, 'w')
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
84 cPickle.dump(Pickles(scalelevels), file)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
85 root.destroy()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
86 sys.exit()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
87
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
88
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
89 xfader=Xfader(scalelevels)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
90
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
91 def buildinterface(*args):
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
92 global channel_levels, _oldlevels, leveldisplay, xfader
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
93 for w in root.winfo_children():
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
94 w.destroy()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
95
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
96 stage_tl=toplevelat(165,90)
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
97 s=stage.Stage(stage_tl)
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
98 stage.createlights(s)
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
99 s.pack()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
100
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
101 sub_tl = toplevelat(0,0)
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
102 effect_tl = toplevelat(0,352)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
103
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
104 Subpanels(sub_tl,effect_tl,scalelevels,Subs,xfader,changelevel)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
105
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
106 # def event_printer(evt):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
107 # print dir(evt)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
108
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
109 # sub_tl.bind('<b>', event_printer)
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
110 leveldisplay=toplevelat(873,400)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
111 leveldisplay.bind('<Escape>', sys.exit)
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
112
16
7dbe8067acea fixed bug with channel levels not displaying
drewp
parents: 12
diff changeset
113 Leveldisplay(leveldisplay,_oldlevels,channel_levels)
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
114
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
115 Console()
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
116
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
117 # root frame
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
118 controlpanel = Controlpanel(root,xfader,refresh,quit)
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
119
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
120 xf=Frame(root)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
121 xf.pack(side='right')
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
122
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
123 root.bind('<q>', quit)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
124 root.bind('<r>', refresh)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
125 leveldisplay.bind('<q>', quit)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
126 leveldisplay.bind('<r>', refresh)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
127
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
128 xfader.setupwidget(xf)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
129 controlpanel.pack()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
130
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
131
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
132 buildinterface()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
133
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
134 class Pickles:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
135 def __init__(self, scalelevels):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
136 self.scalelevels = dict([(name, lev.get())
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
137 for name,lev in scalelevels.items()])
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
138
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
139 def load():
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
140 try:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
141 filename = '/tmp/light9.prefs'
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
142 if DUMMY:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
143 filename += '.dummy'
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
144 print "Loading from", filename
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
145 file = open(filename, 'r')
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
146 p = cPickle.load(file)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
147 for s, v in p.scalelevels.items():
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
148 try:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
149 scalelevels[s].set(v)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
150 except:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
151 print "Couldn't set %s -> %s" % (s, v)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
152 except:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
153 print "Couldn't load prefs (%s)" % filename
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
154
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
155 def make_sub(name):
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
156 global _oldlevels
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
157 i = 1
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
158 # name = console_entry.get() # read from console
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
159 if not name:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
160 print "Enter sub name in console."
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
161 return
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
162
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
163 st = ''
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
164 linebuf = 'subs["%s"] = {' % name
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
165 for l in _oldlevels:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
166 if l:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
167 if len(linebuf) > 60:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
168 st += linebuf + '\n '
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
169 linebuf = ''
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
170
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
171 linebuf += ' "%s" : %d,' % (Patch.get_channel_name(i), l)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
172 i += 1
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
173 st += linebuf + '}\n'
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
174 if DUMMY:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
175 filename = 'ConfigDummy.py'
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
176 else:
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
177 filename = 'Config.py'
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
178 f = open(filename, 'a')
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
179 f.write(st)
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
180 f.close()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
181 print 'Added sub:', st
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
182 refresh()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
183
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
184 load()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
185 signal(SIGINT, quit)
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
186 bindkeys(root,'<Escape>', quit)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
187
12
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
188 # bindkeys(root,'<q>', quit)
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
189 # bindkeys(root,'<r>', refresh)
7adc65771676 big restructuring - moved lots of things (including most panels) to other files
drewp
parents: 4
diff changeset
190 # bindkeys(root,'<s>', make_sub)
4
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
191 backgroundloop()
f974a462133f added light8 from the posted light8-1.0.tgz
drewp
parents: 0
diff changeset
192 root.mainloop() # Receiver switches main