def myTest(): """ a simple function that creates the necesary sockets and enters an enless loop sending and receiving OSC """ osc.init() inSocket = osc.createListener("127.0.0.1", 9001) # in this case just using one socket ## inSocket = osc.createListener() # this defaults to port 9001 as well # bind addresses to functions -> printStuff() function will be triggered everytime a # "/test" labeled message arrives osc.bind(printStuff, "/test") import time # in this example we will have a small delay in the while loop print "ready to receive and send osc messages ..." while 1: ## osc.sendMsg("/test", [444], "127.0.0.1", 9000) # send normal msg to a specific ip and port osc.sendMsg("/test", [444]) # !! it sends by default to localhost ip "127.0.0.1" and port 9000 # create and send a bundle bundle = osc.createBundle() osc.appendToBundle(bundle, "/test/bndlprt1", [1, 2, 3]) # 1st message appent to bundle osc.appendToBundle(bundle, "/test/bndlprt2", [4, 5, 6]) # 2nd message appent to bundle ## osc.sendBundle(bundle, "127.0.0.1", 9000) # send it to a specific ip and port osc.sendBundle(bundle) # !! it sends by default to localhost ip "127.0.0.1" and port 9000 osc.getOSC(inSocket) # listen to incomming OSC in this socket time.sleep(0.5) # you don't need this, but otherwise we're sending as fast as possible.
def main(port): osc.init() listener = osc.createListener("",port) import time while 1: time.sleep(0.1) osc.getOSC(listener)
def myTest(): """ a simple function that creates the necesary sockets and enters an enless loop sending and receiving OSC """ osc.init() osc.bind(printStuff, "/gainSlider") inSocket = osc.createListener("127.0.0.1", 9001) import time while 1: osc.getOSC(inSocket) osc.dontListen()
def __init__(self, address='127.0.0.1', port=9000, prefix='/wii/1'): if osc.outSocket == 0: # Only init once. osc.init() self.address = address self.port = port self.listener = osc.createListener(address, port) osc.bind(self._wii_pry, "/wii/1/accel/pry") osc.bind(self._wii_xyz, "/wii/1/accel/xyz") osc.bind(self._wii_a, "/wii/1/button/A") osc.bind(self._wii_b, "/wii/1/button/B") self.prefix = prefix self.pitch = 0.0 self.roll = 0.0 self.yaw = 0.0 self.accel = 0.0 self.x = 0.0 self.y = 0.0 self.z = 0.0 self.a = False self.b = False
def myTest(): """ a simple function that creates the necesary sockets and enters an enless loop sending and receiving OSC """ osc.init() inSocket = osc.createListener('127.0.0.1', 9001) # in this case just using one socket ## inSocket = osc.createListener() # this defaults to port 9001 as well # bind addresses to functions -> printStuff() function will be triggered everytime a # "/test" labeled message arrives osc.bind(printStuff, "/test") import time # in this example we will have a small delay in the while loop print 'ready to receive and send osc messages ...' while 1: ## osc.sendMsg("/test", [444], "127.0.0.1", 9000) # send normal msg to a specific ip and port osc.sendMsg("/test", [ 444 ]) # !! it sends by default to localhost ip "127.0.0.1" and port 9000 # create and send a bundle bundle = osc.createBundle() osc.appendToBundle(bundle, "/test/bndlprt1", [1, 2, 3]) # 1st message appent to bundle osc.appendToBundle(bundle, "/test/bndlprt2", [4, 5, 6]) # 2nd message appent to bundle ## osc.sendBundle(bundle, "127.0.0.1", 9000) # send it to a specific ip and port osc.sendBundle( bundle ) # !! it sends by default to localhost ip "127.0.0.1" and port 9000 osc.getOSC(inSocket) # listen to incomming OSC in this socket time.sleep( 0.5 ) # you don't need this, but otherwise we're sending as fast as possible.