class OscOut(): def __init__(self, IPaddress = "localhost", port = 57110): self.IPaddress = InetAddress.getByName(IPaddress) # holds IP address of OSC device to connect with self.port = port # and its listening port self.portOut = OSCPortOut(self.IPaddress, self.port) # create the connection def sendMessage(self, oscAddress, *args): """ Sends an OSC message consisting of the 'oscAddress' and corresponding 'args' to the OSC output device. """ # HACK: For some reason, float OSC arguments do not work, unless they are explictly converted to Java Floats. # The following list comprehension does the trick. from java.lang import Float # for every argument, if it is a float cast it to a Java Float, otherwise leave unchanged args = [Float(x) if isinstance(x, float) else x for x in args] #print "sendMessage args = ", args oscMessage = OSCMessage( oscAddress, args ) # create OSC message from this OSC address and arguments self.portOut.send(oscMessage) # and send it to the OSC device that's listening to us # remember that this OscIn has been created and is active (so that it can be stopped/terminated by JEM, if desired) _ActiveOscOutObjects_.append(self)
def __init__(self, IPaddress = "localhost", port = 57110): self.IPaddress = InetAddress.getByName(IPaddress) # holds IP address of OSC device to connect with self.port = port # and its listening port self.portOut = OSCPortOut(self.IPaddress, self.port) # create the connection