diff --git a/bin/dmxserver b/bin/dmxserver
--- a/bin/dmxserver
+++ b/bin/dmxserver
@@ -28,11 +28,38 @@ from twisted.web import xmlrpc, server
import sys,time,os
from optparse import OptionParser
import run_local
+import txosc.dispatch, txosc.async
from light9.io import ParportDMX, UsbDMX
from light9.updatefreq import Updatefreq
from light9 import networking
+
+class ReceiverApplication(object):
+ """
+ receive UDP OSC messages. address is /dmx/1 for dmx channel 1,
+ arguments are 0-1 floats for that channel and any number of
+ following channels.
+ """
+ def __init__(self, port, lightServer):
+ self.port = port
+ self.lightServer = lightServer
+ self.receiver = txosc.dispatch.Receiver()
+ self.receiver.addCallback("/dmx/*", self.pixel_handler)
+ self._server_port = reactor.listenUDP(
+ self.port,
+ txosc.async.DatagramServerProtocol(self.receiver),
+ interface='0.0.0.0')
+ print "Listening OSC on udp port %s" % (self.port)
+
+ def pixel_handler(self, message, address):
+ # this is already 1-based though I don't know why
+ startChannel = int(message.address.split('/')[2])
+ levels = [a.value for a in message.arguments]
+ allLevels = [0] * (startChannel - 1) + levels
+ self.lightServer.xmlrpc_outputlevels("osc@%s" % startChannel,
+ allLevels)
+
class XMLRPCServe(xmlrpc.XMLRPC):
def __init__(self,options):
@@ -215,8 +242,13 @@ print options
if options.dummy:
os.environ['DMXDUMMY'] = "1"
+
port = networking.dmxServer.port
print "starting xmlrpc server on port %s" % port
-reactor.listenTCP(port,server.Site(XMLRPCServe(options)))
+xmlrpcServe = XMLRPCServe(options)
+reactor.listenTCP(port,server.Site(xmlrpcServe))
+
+oscApp = ReceiverApplication(9051, xmlrpcServe)
+
reactor.run()
diff --git a/light9/networking.py b/light9/networking.py
--- a/light9/networking.py
+++ b/light9/networking.py
@@ -35,6 +35,7 @@ class ServiceAddress(object):
return self.url + str(more)
dmxServer = ServiceAddress(L9['dmxServer'])
+oscDmxServer = ServiceAddress(L9['oscDmxServer'])
musicPlayer = ServiceAddress(L9['musicPlayer'])
keyboardComposer = ServiceAddress(L9['keyboardComposer'])
curveCalc = ServiceAddress(L9['curveCalc'])
diff --git a/pydeps b/pydeps
--- a/pydeps
+++ b/pydeps
@@ -14,4 +14,5 @@ ipdb==0.7
git+git://github.com/drewp/python-coloredlogs@9803112ddf7d4cd7dd001912ad1aa482fb8383f6
genshi==0.7
pyjade==2.0.2
-python-dateutil==2.1
\ No newline at end of file
+python-dateutil==2.1
+txosc==0.2.0
\ No newline at end of file
diff --git a/show/dance2013/networking.n3 b/show/dance2013/networking.n3
--- a/show/dance2013/networking.n3
+++ b/show/dance2013/networking.n3
@@ -6,6 +6,7 @@ show:dance2013 :networking sh:netHome .
sh:netHome
:musicPlayer ;
:dmxServer ;
+ :oscDmxServer ;
:curveCalc ;
:keyboardComposer ;
:vidref .
\ No newline at end of file