From 0f47169e66121a1d84d2e1c062f57340ca8e3da6 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 11 Oct 2016 01:04:41 +0200 Subject: python: minor updates --- dmx/.gitignore | 1 + dmx/dmxcontrol.py | 124 ++++++++++++++++++++++++++++++++++++++++-------------- dmx/dmxeffects.py | 30 ++++++++++--- 3 files changed, 118 insertions(+), 37 deletions(-) create mode 100644 dmx/.gitignore diff --git a/dmx/.gitignore b/dmx/.gitignore new file mode 100644 index 0000000..39214fd --- /dev/null +++ b/dmx/.gitignore @@ -0,0 +1 @@ +.dmxeffects diff --git a/dmx/dmxcontrol.py b/dmx/dmxcontrol.py index e214aec..8013934 100644 --- a/dmx/dmxcontrol.py +++ b/dmx/dmxcontrol.py @@ -3,53 +3,113 @@ # prevrms = prevrms * 0.64 + rms * 0.4 # print prevrms -gamountmul = 0.2 # 1.4 -gmul = 0.4 - -effects[0].camount = 0.22 * gamountmul -effects[0].cphase = 0.0 -effects[0].jumpdecayset = 0.05 #0.49 # 0.19 -effects[0].jumpdecayfall = 0.90 -effects[0].jumpv = 0.12 +#dmx.lounge_buero_ecke 268 {u'r': 249, u'b': 0, u'g': 19} +#dmx.lounge_midwest 373 {u'r': 255, u'b': 0, u'g': 118} +#dmx.lounge_buehne_links 5 {u'r': 3, u'b': 1, u'g': 1} +#dmx.lounge_traverse 86 {u'r': 58, u'b': 12, u'g': 16} +#dmx.lounge_decke 146 {u'r': 0, u'b': 144, u'g': 2} + +gamountmul = 0.0 #0.33 # 1.4 +gmul = 0.7 + +import time +t = time.time() + +if type(effects[4]) != EffectRGBFadeJump: + effects[4] = EffectRGBFadeJump(universe[4]) + print 'x' + +fadet = None +# fadet = 1398550165 +fadedur = 22. +if fadet != None: + if t < fadet: + fc = 0.0 + elif t > fadet: + fc = min(max(1. - (t - fadet) / fadedur, 0.0), 1.0) + print 'fc', fc + gmul = gmul * fc + else: + print 'fade t =', fadet - t + +# unused +if True: + effects[0].camount = 0.22 * gamountmul + effects[0].cphase = 0.0 + effects[0].jumpdecayset = 0.05 #0.49 # 0.19 + effects[0].jumpdecayfall = 0.90 + effects[0].jumpv = 0.0 + effects[0].fadespeed = 0.04 +else: + effects[0].h = 0.033 + effects[0].s = 1.0 + effects[0].v = 0.8 universe[0].mult = 0.55 * gmul -effects[1].camount = 0.1 * gamountmul -effects[1].cphase = 0.5 -effects[1].phasejump = 0.03 # 0.084 -effects[1].jumpdecayset = 0.1 -effects[1].jumpdecayfall = 0.90 -effects[1].jumpv = 0.2 +if False: + effects[1].camount = 0.1 * gamountmul + effects[1].cphase = 0.5 + effects[1].phasejump = 0.03 # 0.084 + effects[1].jumpdecayset = 0.1 + effects[1].jumpdecayfall = 0.90 + effects[1].jumpv = 0.3 +else: + effects[1].h = 0.14 + effects[1].s = 1.0 + effects[1].v = 1.0 # 3.7 universe[1].mult = 0.55 * gmul +from math import sin, cos, pi +def hsvmap(arg, h, s, v): + #s = 0.7 + 0.3 * cos(arg*2*pi) + #s = 0.7 * s + return (h, s, v) +def hsvmap1(arg, h, s, v): + s = 0.7 + 0.3 * cos(arg*2*pi) + return (h, 0.5 * s, 0.3 + 0.7 * v) + effects[2].camount = 0.12 * gamountmul +effects[2].fadespeed = 0.025 effects[2].cphase = 0.5 -effects[2].phasejump = 0.12 -effects[2].jumpdecayset = 0.36 # 0.19 -effects[2].jumpdecayfall = 0.955 -effects[2].jumpv = 0.3 #1.5 +effects[2].phasejump = 0.05 # 0.075 +effects[2].jumpdecayset = 0.18 # 0.19 +effects[2].jumpdecayfall = 0.935 #0.955 +effects[2].jumpv = 0.6 # 0.8 #1.5 +effects[2].hsvmap = hsvmap universe[2].mult = 0.3 * gmul # + prevrms effects[3].camount = 0.10 * gamountmul +effects[3].fadespeed = 0.04 effects[3].cphase = 0.0 -effects[3].phasejump = 0.12 # 0.084 -effects[3].jumpdecayset = 0.39 # 0.27 -effects[3].jumpdecayfall = 0.955 -effects[3].jumpv = 0.5 #4.23 +effects[3].phasejump = 0.09 # 12 # 0.084 +effects[3].jumpdecayset = 0.38 #0.432 # 0.29 # 0.27 +effects[3].jumpdecayfall = 0.925 #0.955 +effects[3].jumpv = 0.6 #0.8 #4.23 +effects[3].hsvmap = hsvmap +# effects[3].r_phasejump = 0.3 universe[3].mult = 0.3 * gmul # + prevrms -effects[4].camount = 0.12 * gamountmul -effects[4].phasejump = 0.22 -effects[4].cphase = 0.5 -effects[4].jumpdecayset = 0.6 -effects[4].jumpdecayfall = 0.95 -effects[4].jumpv = 0.9 -universe[4].mult = 0.32 * gmul +if True: + effects[4].camount = 0.12 * gamountmul + effects[4].phasejump = 0.03 # 0.22 + effects[4].cphase = 0.5 + effects[4].jumpdecayset = 0.0 # 0.2 + effects[4].jumpdecayfall = 0.95 + effects[4].jumpv = 0.2 + effects[4].hsvmap = hsvmap1 +else: + effects[4].h = 0.18 + effects[4].s = 0.90 + effects[4].v = 3.8 +universe[4].mult = 0.42 * gmul effects[4].r_phasejump += 0.0004 +effects[5].fadespeed = 0.03 # 0.06 + # static -#for e in effects[:3]: -# e.fadespeed = 0.0 -# e.r_phasejump = 0.09 +for e in effects: + e.jumpv = 0 + # e.decay = 0 # bpm = 106. diff --git a/dmx/dmxeffects.py b/dmx/dmxeffects.py index ba6c188..5989517 100644 --- a/dmx/dmxeffects.py +++ b/dmx/dmxeffects.py @@ -12,7 +12,7 @@ from ola.ClientWrapper import ClientWrapper wrapper = None loop_count = 0 TICK_INTERVAL = 10 # in ms -universenum = 0 +universenum = 2 enable = '--enable' in sys.argv[1:] @@ -102,6 +102,8 @@ class EffectRGBFadeJump(object): self.r_phasejump = 0.0 self.r_jumpdecay = 0.0 + self.hsvmap = lambda arg, h, s, v: (h, s, v) + def update(self, timestamp): curphase = beatsep # int(timestamp) if self.r_lastphase != curphase: @@ -113,13 +115,31 @@ class EffectRGBFadeJump(object): mixcorr = (cos((phase * 3) * 2*pi) - 1. / 2.) * 0.33 - (self.target.r, self.target.g, self.target.b) = \ - colorsys.hsv_to_rgb(phase, + h, s, v = (phase, 1.0 - self.r_jumpdecay, (0.8 + mixcorr) * self.control + self.r_jumpdecay * self.jumpv) + h, s, v = self.hsvmap(phase, h, s, v) + + (self.target.r, self.target.g, self.target.b) = \ + colorsys.hsv_to_rgb(h, s, v) self.r_jumpdecay *= self.jumpdecayfall +class EffectStaticHSV(object): + def __init__(self, target): + self.target = target + self.h = 0.0 + self.s = 0.0 + self.v = 0.0 + + self.r_phasejump = 0.0 + self.cphase = 0.0 + self.camount = 0.0 + + def update(self, timestamp): + (self.target.r, self.target.g, self.target.b) = \ + colorsys.hsv_to_rgb(self.h, self.s, self.v) + class EffectEffectCross(object): def __init__(self, group, fadespeed = 1./2., phasejump = 0.0): self.group = group @@ -153,10 +173,10 @@ universe.append(DMXLEDPAR(21, 0.55)) effects = [ EffectRGBFadeJump(universe[0]), - EffectRGBFadeJump(universe[1]), + EffectStaticHSV(universe[1]), EffectRGBFadeJump(universe[2]), # , fadespeed = 1./12., phasejump = 0.1), EffectRGBFadeJump(universe[3]), - EffectRGBFadeJump(universe[4]), + EffectStaticHSV(universe[4]), ] effects.append( -- cgit v1.2.1