Mercurial > code > home > repos > light9
annotate light8/updatefreq.py @ 167:79bc84310e80
changes from tonight's rehearsal:
changes from tonight's rehearsal:
- CueFader is closer to actually running the show, computes DMX levels
to send.
- KeyboardComposer is not a dummy. Use DMXDUMMY=1 to disable it.
- Submaster: subs can now be "temporary" -- i.e. they shouldn't be saved
or loaded. to save a temporary sub, make a copy of it with a proper name
since the computed name will be ugly.
Also, get_normalized_copy() and crossfade() methods added.
linear_fade helper (shouldn't be in Submaster, probably) added too.
- dmxchanedit: longer labels
- cuelist1 now has some bogus data in it and some crap removed
- dmxclient: now listens to the $DMXHOST and $DMXDUMMY env variables.
- patchdata: now up to date with this year's show
- danshow subs song{01..19}: removed. maybe we'll re-add them in an
archive directory.
author | dmcc |
---|---|
date | Tue, 08 Jul 2003 16:19:55 +0000 |
parents | 57809e0ef359 |
children |
rev | line source |
---|---|
0 | 1 """calculates your updates-per-second""" |
2 | |
3 import time | |
4 | |
5 class Updatefreq: | |
6 """make one of these, call update() on it as much as you want, | |
7 and then float() or str() the object to learn the updates per second. | |
8 | |
9 the samples param to __init__ specifies how many past updates will | |
10 be stored. """ | |
11 | |
126 | 12 def __init__(self,samples=20): |
0 | 13 self.times=[0] |
14 self.samples=samples | |
15 | |
16 def update(self): | |
17 | |
18 """call this every time you do an update""" | |
19 self.times=self.times[-self.samples:] | |
20 self.times.append(time.time()) | |
21 | |
22 def __float__(self): | |
23 | |
24 """a cheap algorithm, for now, which looks at the first and | |
25 last times only""" | |
26 | |
126 | 27 try: |
28 hz=len(self.times)/(self.times[-1]-self.times[0]) | |
29 except ZeroDivisionError: | |
30 return 0 | |
0 | 31 return hz |
32 def __str__(self): | |
126 | 33 return "%.2fHz"%float(self) |