equal
deleted
inserted
replaced
|
1 |
|
2 # |
|
3 # See LICENCE for detail |
|
4 # Copyright (c) 2014 IRI |
|
5 # |
|
6 |
|
7 import datetime |
|
8 import json |
|
9 import uuid |
|
10 |
|
11 from txosc import dispatch |
|
12 from txosc.osc import getAddressParts |
|
13 from txosc.async import DatagramServerProtocol |
|
14 |
|
15 import ntplib |
|
16 |
|
17 from baseserver import BaseProtocol |
|
18 import utils |
|
19 |
|
20 |
|
21 class OSCServerProtocol(DatagramServerProtocol, BaseProtocol): |
|
22 """ |
|
23 Receive UDP OSC messages |
|
24 """ |
|
25 |
|
26 def __init__(self, ws_factory, conn): |
|
27 self.receiver = dispatch.Receiver() |
|
28 self.receiver.addCallback("/pianoroll/*/", self.processPianorollAnnotation) |
|
29 self._init_props(ws_factory, conn) |
|
30 |
|
31 def processPianorollAnnotation(self, message, address): |
|
32 |
|
33 values = message.getValues() |
|
34 ts = datetime.datetime.utcfromtimestamp(ntplib.ntp_to_system_time(values[0])) |
|
35 |
|
36 params = { |
|
37 'ts' : ts, |
|
38 'event': getAddressParts(message.address)[1], |
|
39 'channel' : utils.PIANOROLL_CHANNEL, |
|
40 'content' : values |
|
41 } |
|
42 |
|
43 self.process_annotation(params) |