def main(ctrl): if ctrl.sensors["Always"].positive: globalDict = bge.logic.globalDict #### Load config from file #### # if "non_blend_osc_conf" not in globalDict: # # globalDict["grabing_env"] = Grab_env(ctrl) # # conf #### Initiate the grabbing environement #### if "grabing_env" not in globalDict: logger.info("Init Grabing_env") globalDict["grabing_env"] = Grab_env(ctrl) grabing_env = globalDict["grabing_env"] #### Initiate the osc pipe environement #### if "osc_pipe" not in globalDict: logger.info("Init OSCpipe") globalDict["osc_client"] = OSCClient() osc_client = globalDict["osc_client"] osc_client.connect( (conf["osc_client_addr"], conf["osc_client_port"]) ) globalDict["osc_pipe"] = OSCpipe() logger.debug(osc_client) osc_client = globalDict["osc_client"] osc_pipe = globalDict["osc_pipe"] #### now, doing stuff #### grabing_env.grab_obj() tosend = osc_pipe.pipes_pool() # logger.debug(tosend) # osc_client.send(OSCMessage("/string_de_test", 13.37)) if tosend: for msg in tosend: osc_client.send(msg)
################## Static configuration // Edit here ################### conf = { "osc_client_addr" : "127.0.0.1", "osc_client_port" : 1337, # full OSC path = osc_base_path + ObjectName + osc_[angle, radius, elevation]_path "osc_base_path": "Non-Mixer.nXEUB/strip/", "osc_azimuth_path": "/Spatializer/Azimuth/unscaled", "osc_radius_path": "/Spatializer/Radius/unscaled", "osc_elevation_path": "/Spatializer/Elevation/unscaled" } ##### Look for the "random" OSC port of non-mixer def non_port(): with open(os.devnull, 'w') as devnull: #portlist = check_output("netstat -ulpn -W | grep non-mixer | cut -d: -f2 | cut -d ' ' -f1 | tail -n2 | head -n1", shell=True, stderr=devnull) portlist = check_output("netstat -ulpn -W | grep non-mixer | cut -d: -f2 | cut -d ' ' -f1 | tail -n1 ", shell=True, stderr=devnull) return portlist non_portlist = non_port() if non_portlist : non_portlist=int(non_portlist) conf["osc_client_port"] = non_portlist logger.info("Found Non-mixer port : %s", non_portlist) else: logger.info("Non-mixer port no found, use config file")