def lf(c1, c2): p1 = PartyBar().all(c1) p2 = PartyBar().all(c2) c = Chase() c.add(FadeCommand(p1, p2, 15, 15.8)) c.add(FadeCommand(p2, p1, 16, 15.8)) c.loop = True return c
def run(self, universe, client, bpm, lastState): src = self.scene1 if src == None: src = PartyBar(lastState) fps = 30 frames = 0.0 fade_duration = 60.0 / bpm * self.duration numFrames = fade_duration * fps while frames < numFrames: bb = PartyBar.blend(src, self.scene2, frames / numFrames) client.SendDmx(universe, bb.data, DmxSent) frames = frames + 1 sleep(fade_duration / numFrames) client.SendDmx(universe, self.scene2.data, DmxSent) return self.scene2.data
def main(): global wrapper wrapper = ClientWrapper() client = wrapper.Client() global l l = LightDrummer(client, 140) # Intro pb2 = PartyBar() pb2.set(PURPLE, BLUE, BLUE, PURPLE) l.run(twobardimmer(pb2)) def handle_input(input): exec input in globals(), globals() shell.run(l, handle_input)
def twobardimmer(pb): c = Chase() pb2 = PartyBar.clone(pb) pb2.dim(0) # If we run the dim for the whole measure we lose time to # hit the next beat c.add(FadeCommand(pb, pb2, 0, 3.75)) c.add(FadeCommand(pb2, pb, 4, 3.75)) return c
def strobe(scene, beatdivision, duration): c = Chase() off = PartyBar.clone(scene) off.dim(0) numScenes = (1.0 / beatdivision) * duration numScenes = numScenes / 2 sceneDuration = beatdivision scenes = 0 while scenes < numScenes: print("Adding commands" + str(scenes)) c.add(SceneCommand(off, 0)) c.add(SceneCommand(scene, beatdivision)) c.add(SleepCommand(beatdivision)) scenes = scenes + 1 return c
def lightDrum(self, client, queue): chase = None lastState = PartyBar().all(WHITE).data while True: if chase != None and chase.loop == True: try: chase = queue.get(False) except: pass else: chase = queue.get() if chase == None: chase = queue.get() if client.disabled == True: return beatPos = 0 startTime = time() if chase.bpm > 0: self.bpm = chase.bpm for command in chase.commands: beatPos = beatPos + command.switchAfter if self.nextBeatTime > 0: nextBeatPos = ceil(beatPos) startTime = self.nextBeatTime - nextBeatPos * (60.0 / self.bpm) self.nextBeatTime = -1 expectedTime = startTime + beatPos * (60.0 / self.bpm) wait = expectedTime - time() if wait > 0: sleep(wait) lastState = command.run(self.universe, client, self.bpm, lastState)
def onebardimmer(pb): c = Chase() pb2 = PartyBar.clone(pb) pb2.dim(0) c.add(FadeCommand(pb, pb2, 0, 4)) return c
def fourstepmover(duration, color, background=BLACK, fadeDivisor=2.0): c = Chase() p0 = PartyBar() p1 = PartyBar() p1.l1(color) p1.l2(background) p1.l3(background) p1.l4(background) p2 = PartyBar() p2.l1(background) p2.l2(color) p2.l3(background) p2.l4(background) p3 = PartyBar() p3.l1(background) p3.l2(background) p3.l3(color) p3.l4(background) p4 = PartyBar() p4.l1(background) p4.l2(background) p4.l3(background) p4.l4(color) sceneDur = duration / 4.0 c.add(FadeCommand(None, p1, 0, sceneDur / fadeDivisor)) c.add(FadeCommand(p1, p2, sceneDur, sceneDur / fadeDivisor)) c.add(FadeCommand(p2, p3, sceneDur, sceneDur / fadeDivisor)) c.add(FadeCommand(p3, p4, sceneDur, sceneDur / fadeDivisor)) c.add(SleepCommand(sceneDur)) return c
def cstrobe(color, dst): p = PartyBar() p.all(color) c = strobe(p, 1 / 2.0, 4.0) return c
def __init__(self, scene, after, target, duration): self.scene2 = PartyBar.clone(scene)