-
Notifications
You must be signed in to change notification settings - Fork 7
/
deldo_server.py
executable file
·47 lines (38 loc) · 1.04 KB
/
deldo_server.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
#!/usr/bin/env python
import sys
sys.path.append('/Users/qdot/git-projects/library/usr_darwin_10.5_x86/lib/python2.6/site-packages')
import time
import OSC
from trancevibe import *
from contextlib import *
class DeldoServer(object):
def __init__(self, tv):
self.trancevibe = tv
return
@classmethod
def create(cls, tv):
d = DeldoServer(tv)
d.open()
return d
def open(self):
OSC.init()
OSC.listen("127.0.0.1", 9001)
OSC.bind(self.set_speed, "/deldo/speed")
return
def set_speed(self, *msg):
self.trancevibe.set_speed(msg[0][2])
@contextmanager
def close(self):
OSC.dontListen()
return
def main(argv = None):
with closing(TranceVibrator.create()) as tv:
with closing(DeldoServer.create(tv)) as d:
try:
while(1):
time.sleep(0.1)
except KeyboardInterrupt, e:
pass
return 0
if __name__ == '__main__':
sys.exit(main())