Mercurial > code > home > repos > light9
annotate light8/Config.py @ 52:065896b0913c
emergency commit
author | dmcc |
---|---|
date | Mon, 08 Jul 2002 03:25:42 +0000 |
parents | 71489bb71528 |
children | 032b2b67bc10 |
rev | line source |
---|---|
0 | 1 from random import randrange |
2 from time import time | |
3 from __future__ import generators,division | |
4 from Subs import * | |
5 | |
51
71489bb71528
- Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents:
40
diff
changeset
|
6 from Fader import fader |
0 | 7 |
8 patch = { | |
40
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
9 |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
10 'side l' : 45, # posts |
4 | 11 'side r' : 46, |
40
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
12 |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
13 ('patio1','main 1',) : 1, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
14 ('main 2',) : 2, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
15 ('main 3',) : 3, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
16 ('main 4',) : 4, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
17 ('main 5',) : 5, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
18 ('god','main 6') : 6, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
19 ('main 7',) : 7, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
20 ('main 8',) : 8, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
21 ('main 9',) : 9, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
22 ('main 10',) : 10, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
23 ('main 11',):11, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
24 ('patio2','main 12',):12, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
25 |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
26 'cycleft' : 43, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
27 'cycright' : 44, # ? might be a different circuit |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
28 |
0 | 29 'house':68, |
40
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
30 ('desk1' ,'b11'):54, # left bank over house |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
31 ('marry1' ,'b12'):53, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
32 ('b13',):52, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
33 ('hotbox1' ,'b14'):51, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
34 ('edge' ,'b15'):50, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
35 ('phone','b16'):49, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
36 ('cuba1' ,'b21'):55, # mid bank |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
37 ('b22',):56, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
38 ('b23',):57, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
39 ('b24'):58, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
40 ('b25'):59, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
41 ('desk2' ,'b26'):60, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
42 ('rock','b31'):61, # right bank |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
43 ('b32',):62, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
44 ('hotbox2' ,'b33'):63, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
45 ('b34',):64, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
46 ('marry2' ,'b35'):65, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
47 ('cuba2' ,'b36'):66, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
48 'oran1':21, 'oran2':25, 'oran3':29, 'oran4':33, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
49 'gree1':22, 'gree2':26, 'gree3':30, 'gree4':34, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
50 'blue1':23, 'blue2':27, 'blue3':31, 'blue4':35, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
51 'red1' :24, 'red2' :28, 'red3' :32, 'red4' :36, |
0 | 52 } |
53 | |
54 from util import maxes,scaledict | |
55 FL=100 | |
56 def fulls(chans): | |
57 # pass a list or multiple args | |
58 return dict([(c,FL) for c in chans]) | |
59 def levs(chans,levs): | |
60 return dict([(c,v) for c,v in zip(chans,levs)]) | |
61 | |
4 | 62 def strobe(params, slideradjuster): |
63 patterns = { | |
64 'blue' : fulls((23,27,31,35,'b0 4 b','b2 3 b')), | |
65 'cyc' : {42:FL,43:FL}, | |
66 'scp all' : fulls((13,16,18,19,39)), | |
67 '1-5' : fulls(range(1, 6)), | |
68 } | |
69 params.add_param('offtime',SliderParam(range=(0.1,0.3), res=0.001, | |
70 initial=0.11, length=100)) | |
71 params.add_param('ontime',SliderParam(range=(0.0,0.8), res=0.001, | |
72 length=100)) | |
73 params.add_param('pattern',ListParam(patterns.keys())) | |
74 params.add_param('current',LabelParam('none')) | |
75 params.add_param('count',SliderParam(range=(0, 10), res=1, initial=0)) | |
76 lastchanged = time() | |
77 state = 0 | |
78 blinkcounter = 0 | |
79 my_pattern = None | |
0 | 80 |
4 | 81 while 1: |
82 if params['count'] and blinkcounter > params['count']: | |
83 blinkcounter = 0 | |
84 slideradjuster.set(0) | |
0 | 85 |
4 | 86 if params['pattern'] != None: |
87 params['current'] = params['pattern'] | |
88 my_pattern = params['pattern'] | |
0 | 89 |
4 | 90 if state == 0: |
91 delay = params['offtime'] | |
92 else: | |
93 delay = params['ontime'] | |
94 | |
95 if time() > (lastchanged + delay): | |
96 # ready for change | |
97 state = not state | |
98 lastchanged = time() | |
99 blinkcounter += 0.5 | |
0 | 100 |
4 | 101 try: # protect against keyerrors (and possibly everything else) |
102 if state: | |
103 yield patterns[my_pattern] | |
104 else: | |
105 yield scaledict(patterns[my_pattern], .1) | |
106 except: | |
107 yield {} | |
0 | 108 |
4 | 109 def chase(params, slideradjuster): |
110 patterns = { | |
111 'all': ( fulls(('b01','b21')), | |
112 fulls(('b02','b22')), | |
113 fulls(('b03','b23')), | |
114 fulls(('b04','b24')), | |
115 fulls(('b05','b25')), | |
116 fulls(('b06','b26')), | |
117 ), | |
118 'red':( fulls(('b0 1 r','b2 2 r')), | |
119 fulls(('b0 5 r','b2 6 r'))), | |
120 'randcol':([fulls((x,)) for x | |
121 in ("b21 b23 b25 b03 b06 b24 b22 "+ | |
122 "b24 b03 b23 b01 b04 b05 b22 "+ | |
123 "b02 b02 b26 b21 b06 b25 b26 "+ | |
124 "b01 b04 b05").split()]), | |
125 'ctrpong':[fulls((x,)) for x in ( | |
126 "b11 b12 b13 b14 b15 b16 b15 b14 b13 b12".split())], | |
127 'l-r': ( fulls(('b01','b11','b21')), | |
128 fulls(('b02','b12','b22')), | |
129 fulls(('b03','b13','b23')), | |
130 fulls(('b04','b14','b24')), | |
131 fulls(('b05','b15','b25')), | |
132 fulls(('b06','b16','b26'))), | |
133 'flutter':( | |
134 fulls(('main 6','b15')), | |
135 fulls(('main 1','b12')), | |
136 fulls(('main 2','b11')), | |
137 fulls(('b12', 'main 3')), | |
138 fulls(('b15', 'main 9')), | |
139 fulls(('b16', 'main 4')), | |
140 fulls(('main 4','b13')), | |
141 fulls(('main 3','b11')), | |
142 fulls(('main 8','b15')), | |
143 fulls(('main 9','b12')), | |
144 fulls(('b11', 'main 1')), | |
145 fulls(('main 5','b15')), | |
146 fulls(('b13', 'main 6')), | |
147 fulls(('b14', 'main 2')), | |
148 fulls(('main 7','b16')), | |
149 ), | |
150 'randstage':([fulls((x,)) for x | |
151 in (""" | |
152 b22 27 b04 26 b26 21 28 b25 23 b02 31 b05 32 34 b03 24 b01 25 | |
153 b23 29 22 35 30 b24 33 36 """).split()]), | |
0 | 154 |
4 | 155 } |
0 | 156 |
4 | 157 params.add_param('steptime',SliderParam(range=(.1,3), |
158 initial=.4,length=150)) | |
159 params.add_param('overlap',SliderParam(range=(0,8),initial=1.5)) | |
160 params.add_param('pattern',ListParam(options=patterns.keys(), | |
161 initial='all')) | |
162 params.add_param('current',LabelParam('none')) | |
163 | |
164 steps=() | |
165 | |
166 def fn(x): | |
167 warm=.1 | |
168 # the _/\_ wave for each step. input 0..1, output 0..1 | |
169 if x<0 or x>1: | |
170 return warm | |
171 if x<.5: | |
172 return warm+(1.0-warm)*(x*2) | |
173 else: | |
174 return warm+(1.0-warm)*(2-(x*2)) | |
0 | 175 |
4 | 176 def stepbrightness(stepnum,numsteps,overlap,pos): |
177 startpos = stepnum/numsteps | |
178 p=( (pos-startpos)*(1.0+overlap) )%1.0 | |
179 ret=fn( p ) | |
180 #print "step %(stepnum)i/%(numsteps)i pos %(pos)f ,p=%(p)f is %(ret)f" % locals() | |
181 return ret | |
0 | 182 |
4 | 183 queued=[] # list of steps, each step is starttime,stepcue |
184 lastaddtime=time()-100 | |
185 currentpattern='all' | |
186 steps=patterns[currentpattern] | |
187 stepsiter=iter(()) | |
188 while 1: | |
189 params['current'] = params['pattern'] | |
0 | 190 |
4 | 191 # changed pattern? |
192 if params['pattern']!=currentpattern and params['pattern'] in patterns: | |
193 currentpattern=params['pattern'] | |
194 steps=patterns[currentpattern] | |
195 stepsiter=iter(steps) # restart iterator | |
0 | 196 |
4 | 197 # time to put a new step in the queue? |
198 if time()>lastaddtime+params['steptime']: | |
199 lastaddtime=time() | |
200 try: | |
201 nextstep = stepsiter.next() | |
202 except StopIteration: | |
203 stepsiter=iter(steps) | |
204 nextstep=stepsiter.next() | |
205 queued.append( (time(),nextstep) ) | |
206 | |
207 # loop over queue, putting still-active (scaled) steps in shiftedsteps | |
208 keepers=[] | |
209 shiftedsteps=[] | |
210 for started,s in queued: | |
211 steptime = time()-started | |
212 finish = started+(1.0+params['overlap'])*params['steptime'] | |
213 pos = (time()-started)/(finish-started) | |
214 if time()<finish: | |
215 keepers.append((started,s)) | |
216 shiftedsteps.append( scaledict(s,fn(pos)) ) | |
217 | |
218 if len(keepers)>30: | |
219 print "too many steps in chase - dumping some" | |
220 queued=keepers[:20] | |
221 else: | |
222 queued=keepers | |
223 | |
224 | |
225 # pos=(time()%params['steptime'])/params['steptime'] # 0..1 animated variable | |
226 # shiftedsteps=[] | |
227 # for i,s in zip(range(0,len(steps)),steps): | |
228 # shiftedsteps.append( scaledict(s, stepbrightness(i,len(steps),params['overlap'],pos)) ) | |
229 yield maxes(shiftedsteps) | |
230 | |
231 | |
232 def randomdimmer(params, slideradjuster): | |
233 params.add_param('magic', CheckboxParam()) | |
234 params.add_param('cheese', TextParam()) | |
235 params.add_param('stuff', ListParam(('a', 'b', 'c'))) | |
236 | |
237 curtime = time() | |
238 dim = 1 | |
239 while 4: | |
240 if time() - curtime > 1: | |
241 dim = randrange(1, 64) | |
242 curtime = time() | |
243 yield {dim : 100, 20 : params.get_param_value('magic')} | |
244 | |
0 | 245 |
4 | 246 subs = { |
247 'over pit sm' : levs(range(1, 13),(100,0,0,91,77,79,86,55,92,77,59,0)), | |
248 'over pit lg' : fulls(range(1, 13)), | |
249 ('house', 'black') : { 68:100 }, | |
250 ('cyc', 'lightBlue'):{42:FL,43:FL}, | |
251 ('scp hot ctr', 'yellow'):{18:FL}, | |
252 ('scp more', '#AAAA00'):{18:FL,14:FL}, | |
253 ('scp all', '#AAAA00'):fulls((13,16,18,19,39)), | |
40
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
254 ('col oran', '#EEEE99'):fulls('oran1 oran2 oran3 oran4'.split()), |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
255 ('col red', 'red'):fulls('red1 red2 red3 red4'.split()), |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
256 ('col blue', 'blue'):fulls('blue1 blue2 blue3 blue4'.split()), |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
257 ('col gree', 'green'):fulls('gree1 gree2 gree3 gree4'.split()), |
4 | 258 'sidepost':fulls((45,46)), |
259 'edges':fulls((55,60,49,54,61,66)), | |
40
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
260 'bank1ctr':fulls(('b22','b23','b24','b25')), |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
261 'god' : fulls((6,)), |
4 | 262 ('strobe', 'grey'):strobe, |
263 | |
264 'chase' : chase, | |
265 'chase2' : chase, | |
266 } | |
0 | 267 |
40
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
268 subs["ba outrs"] = fulls("b11 b12 b13 b14 b15 b16 b31 b32 b33 b34 b35 b36".split()) |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
269 subs["ba some"] = {'b12':40,'b13':FL,'b14':FL,'b15':40, |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
270 'b32':40,'b33':FL,'b34':FL,'b35':40,} |
f3d65ae17a8f
these are mostly replaced with guys&dolls material (effects were not touched)
drewp
parents:
4
diff
changeset
|
271 subs['*curtain'] = subs['ba some'].copy() |