-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
98 lines (78 loc) · 2.42 KB
/
test.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
import sys
import lightsclient
import random
import time
import midilistener
def main() :
if len(sys.argv) > 1 and sys.argv[1] == 'rest' :
lightsClient = lightsclient.LightsRestClient("127.0.0.1", "8081")
else :
lightsClient = lightsclient.LightsLocalClient("192.168.43.3", "8899", lightsclient.LightsLocalClient.REAL_SETUP)
lightsController = lightsClient._lightsController
lightsController.setLightOn(False, 0)
'''time.sleep(1)
for group in range(1, 2):
emulator.setLight([random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)], 254, group)
time.sleep(0.2)
emulator.setLightOn(False, group)
time.sleep(0.2)
emulator.setLightOn(True, group)
time.sleep(0.2)'''
#emulator.setLightOn(False, 0)
#time.sleep(1)
#lightsController.setLightOn(True, 0)
lightsClient.changeColorGamma(3, 0)
time.sleep(1)
lightsClient.changeIntensity(127, 0)
time.sleep(0.1)
lightsClient.changeIntensity(90, 0)
time.sleep(0.1)
lightsClient.changeIntensity(50, 0)
time.sleep(0.1)
lightsClient.changeIntensity(30, 0)
#lightsController.setLightOn(False, 0)
lightsClient.colorFlicker(0, 0)
lightsClient.colorFlicker(10, 0)
lightsClient.colorFlicker(20, 0)
lightsClient.colorFlicker(30, 0)
lightsClient.colorFlicker(39, 0)
lightsClient.colorFlicker(50, 0)
lightsClient.colorFlicker(60, 0)
lightsClient.colorFlicker(70, 0)
lightsClient.colorFlicker(80, 0)
lightsClient.colorFlicker(90, 0)
lightsClient.colorFlicker(100, 0)
lightsClient.colorFlicker(110, 0)
lightsClient.colorFlicker(120, 0)
def test_listener():
midiListener = midilistener.MidiListener(1)
midiListener.start()
for i in xrange(1000):
m = createMidi()
time.sleep(0.025)
midiListener.receiveMidi(m)
def createMidi():
channel = random.randint(2, 3)
if channel == 2:
note_number = 1 if random.randint(1, 100) > 10 else 2
else:
note_number = random.randint(1, 40)
velocity = random.randint(1, 127)
return Midi(channel, note_number, velocity)
class Midi(object):
def __init__(self, channel, note_number, velocity):
self.channel = channel
self.note_number = note_number
self.velocity = velocity
def getNoteNumber(self):
return self.note_number
def getVelocity(self):
return self.velocity
def getChannel(self):
return self.channel
def isNoteOn(self):
return True
def __str__(self):
return "Midi(channel: %s, note: %s, velocity: %s)" % (self.channel, self.note_number, self.velocity)
if __name__ == "__main__" :
test_listener()