-
Notifications
You must be signed in to change notification settings - Fork 2
/
solriser_working.py
158 lines (134 loc) · 4.25 KB
/
solriser_working.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import sys
import random
from birdfish.input.osc import OSCDispatcher
from birdfish.effects import Blink, Pulser
from birdfish.lights import LightElement, RGBLight, PulseChase, LightShow
from birdfish.output.solriserdmx import SolRiserDmx
from birdfish import tween
# create a light show - manages the updating of all lights
show = LightShow()
# Create a network - in this case, universe 3
dmx = SolRiserDmx('/dev/ttyATH0')
#dmx = SolRiserDmx('/dev/tty.usbmodem1d21')
# add the network to the show
show.networks.append(dmx)
# create an input interface
# dispatcher = MidiDispatcher("MidiKeys")
dispatcher = OSCDispatcher(('0.0.0.0', 8998))
## create a single channel light element
#single = LightElement(
# start_channel=1,
# name="singletest",
# attack_duration=1,
# release_duration=1.5,
# )
# add the light to a network
#show.add_element(single, network=dmx)
# the effect is configured by how many times it should pulse per second
# 1 is the default
pulser = Pulser()
# if you wanted to give the pulse a different characteristic
# pulser = Pulser(on_shape=tween.IN_CIRC, off_shape=tween.OUT_CIRC)
# we append the effect to the elements own list of effects
#single.effects.append(pulser)
# set the input interface to trigger the element
# midi code 41 is the "Q" key on the qwerty keyboard for the midikeys app
#dispatcher.add_observer((0,41), single)
#dispatcher.add_trigger('/1/push1', single)
#single = RGBLight(
# start_channel=1,
# name="singletestb",
## attack_duration=0,
## decay_duration=0,
## release_duration=0,
## sustain_value=0,
# simple=True
# )
#
#single.hue = random.random()
#single.saturation = 1
##single.bell_mode = True
#single.update_rgb()
#
#
## add the light to a network
#show.add_element(single, network=dmx)
#
## set the input interface to trigger the element
## midi code 41 is the "Q" key on the qwerty keyboard for the midikeys app
#dispatcher.add_trigger('/1/toggle1', single)
#dispatcher.add_map('/1/fader2', single, 'hue')
#dispatcher.add_map('/1/fader1', single, 'saturation')
##dispatcher.add_map('/1/faderA', single, 'saturation', in_range=(0,4))
#
## set the input interface to trigger the element
## midi code 41 is the "Q" key on the qwerty keyboard for the midikeys app
## midi_dispatcher.add_observer((0,41), single)
#dispatcher.add_trigger('/1/push1', single)
#p = PulseChase(name="greenpulse",
# start_pos=1,
# end_pos=12,
# speed=3,
# move_tween=tween.IN_OUT_CUBIC,
# )
#
elementid = 0
for i in range(1,27,3):
elementid += 1
l = RGBLight(
start_channel=i,
name="pulse_%s" % elementid,
attack_duration=0,
release_duration=0,
sustain_value=1,
#simple=True
)
#l.hue = random.random() # * 255
l.hue = .74
l.saturation = 1
l.update_rgb()
show.add_element(l, network=dmx)
#l.simple = True
# add the light to the network
#dmx.add_element(l)
#p.elements.append(l)
dispatcher.add_map('/1/fader1', l, 'hue')
dispatcher.add_map('/1/fader2', l, 'intensity')
# l.effects.append(pulser)
# set the input interface to trigger the element
# midi code 41 is the "Q" key on the qwerty keyboard for the midikeys app
#dispatcher.add_observer((0,41), single)
dispatcher.add_trigger('/1/push1', l)
dispatcher.add_trigger('/1/toggle1', l)
#
#
#p.start_pos = 1
## p.left_width = p.right_width = 10
#p.left_width = 1
#p.right_width = 1
#p.left_shape = p.right_shape = tween.OUT_CIRC
#p.speed = 3
#p.moveto = p.end_pos = 12
##p.trigger_toggle = True
#
#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)
#dispatcher.add_map('/1/fader1', p, 'speed', in_range=(0,1), out_range=(.5, 10))
#
##dispatcher.add_trigger('/1/push1', p)
#dispatcher.add_trigger('/1/toggle1', p)
# startup the midi communication - runs in its own thread
# dispatcher.start()
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()
dispatcher.stop()
sys.exit(0)