-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOSCserver_dataPlayer.py
More file actions
65 lines (52 loc) · 1.57 KB
/
OSCserver_dataPlayer.py
File metadata and controls
65 lines (52 loc) · 1.57 KB
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
# Program to play motion data from data files
# Sends to port 9050 (normally the Processing port)
import json
from datetime import datetime, timedelta
from DataIOClasses import DataWriter, DataReader
directory = 'tests/data/'
filename = '20150303-183941.txt'
datareader = DataReader( directory + filename )
messageHistory = datareader.getEntries()
# print messageHistory
OSCport = 9050
print ""
print ""
print ""
print "--------------------"
print "--------------------"
print "OSC Data Player RUNNING"
print "--------------------"
print "--------------------"
print ""
print "Playing file: " + directory + filename
print "Sending to OSC port: ", OSCport
print messageHistory[-1]['time'].total_seconds(), " seconds of recorded data"
print ""
# From "client.py" in pyliblo examples
import liblo, sys
try:
target = liblo.Address(OSCport)
except liblo.AddressError, err:
print str(err)
sys.exit()
# Loop through all messages and send to Processing
while True:
try:
startTime = datetime.now()
print "BEGIN SENDING recorded data"
for message in messageHistory:
msg = liblo.Message(message['path'])
for data in message['data']:
msg.add(data)
while ( (datetime.now()-startTime) < message['time'] ):
pass
liblo.send(target, msg)
print "END SENDING recorded data"
print ""
except KeyboardInterrupt:
break
print "--------------------"
print "--------------------"
print "OSC Data Player CLOSED"
print "--------------------"
print "--------------------"