-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsol_random.py
66 lines (50 loc) · 1.55 KB
/
sol_random.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from random import random
import sys
from birdfish.lights import RGBLight, Chase, LightShow, LightGroup
# create a light show - manages the updating of all lights
show = LightShow()
# Create a network - in this case, universe 3
#dmx3 = LumosNetwork(3)
# add the network to the show
# show.networks.append(dmx3)
# create an input interface
dispatcher = MidiDispatcher("MidiKeys")
class CustomColorChanger(LightGroup):
def trigger(self, sig_intensity, **kwargs):
for e in self.elements:
e.hue = random()
e.update_rgb()
super(CustomColorChanger, self).trigger(sig_intensity, **kwargs)
p = CustomColorChanger(name="bluechase")
elementid = 0
for i in range(1,360,3):
elementid += 1
l = RGBLight(
start_channel=i,
name="pulse_%s" % elementid,
attack_duration=1,
decay_duration=.8,
release_duration=0,
sustain_value=0,
)
l.hue = random()
l.saturation = 1
l.update_rgb()
# l.simple = True
# add the light to the network
dmx3.add_element(l)
p.elements.append(l)
show.add_element(p)
# set the input interface to trigger the element
# midi code 70 is the "J" key on the qwerty keyboard for the midikeys app
dispatcher.add_observer((0,70), p)
# startup the midi communication - runs in its own thread
dispatcher.start()
# start the show in a try block so that we can catch ^C and stop the midi
# dispatcher thread
try:
show.run_live()
except KeyboardInterrupt:
# cleanup
dispatcher.stop()
sys.exit(0)