def OSCsend(name, oscaddress, oscargs=''): ip = midi2OSC[name]["oscip"] port = midi2OSC[name]["oscport"] osclient = OSCClient() osclient.connect((ip, port)) oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) try: if gstt.debug > 0: print("Midi OSCSend : sending", oscmsg, "to", name, "at", gstt.LjayServerIP, ":", PluginPort) osclient.sendto(oscmsg, (ip, port)) oscmsg.clearData() #if gstt.debug >0: # print oscaddress, oscargs, "was sent to",name return True except: if gstt.debug > 0: print('Midi OSCSend : Connection to IP', ip, ':', port, 'refused : died ?') #sendWSall("/status No plugin.") #sendWSall("/status " + name + " is offline") #sendWSall("/" + name + "/start 0") #PluginStart(name) return False
def send3(oscaddress, oscargs): oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if gstt.debug > 0: print "sending to 3 : ", oscmsg try: osclient3.sendto(oscmsg, (oscIPin, 8003)) oscmsg.clearData() except: print('Connection to 3 refused') pass
def sendme(oscaddress, oscargs): oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if gstt.debug > 0: print "sending me: ", oscmsg try: osclientme.sendto(oscmsg, (oscIPin, oscPORTin)) oscmsg.clearData() except: print('Connection to myself refused') pass
def sendme(oscaddress,oscargs): #def sendme(oscargs): oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) #print "sending me: ",oscmsg, oscargs try: osclientme.sendto(oscmsg, (oscIPin, oscPORTin)) oscmsg.clearData() except: print ('Connection to mycontroller refused') pass
def sendresol(oscaddress, oscargs): oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if gstt.debug > 0: print "sending to Resolume : ", oscmsg try: osclientresol.sendto(oscmsg, (oscIPresol, oscPORTresol)) oscmsg.clearData() except: print('Connection to Resolume refused') pass
def sendnozosc(oscaddress,oscargs=''): oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) #print ("sending to nozosc : ",oscmsg) try: osclientnozosc.sendto(oscmsg, (NozoscIPout, NozoscPORTout)) oscmsg.clearData() except: print ('Connection to nozosc refused : died ?') sendWSall("/on 0") sendWSall("/status No Nozosc ") pass
def sendosc(oscaddress, oscargs): # also works : osclient.send(OSCMessage("/led", oscargs)) oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if gstt.debug > 0: print "sending : ", oscmsg try: osclient.sendto(oscmsg, (oscIPout, oscPORTout)) oscmsg.clearData() except: print('Connection refused at ', oscIPout) pass
def SendUI(oscaddress,oscargs=''): oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) osclientlj = OSCClient() osclientlj.connect((gstt.TouchOSCIP, gstt.TouchOSCPort)) #print("MIDI Aurora sending UI :", oscmsg, "to",gstt.TouchOSCIP,":",gstt.TouchOSCPort) try: osclientlj.sendto(oscmsg, (gstt.TouchOSCIP, gstt.TouchOSCPort)) oscmsg.clearData() except: log.err('Connection to Aurora UI refused : died ?') pass
def SendAU(oscaddress,oscargs=''): oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) osclientlj = OSCClient() osclientlj.connect((gstt.myIP, 8090)) # print("MIDI Aurora sending itself OSC :", oscmsg, "to localhost:8090") try: osclientlj.sendto(oscmsg, (gstt.myIP, 8090)) oscmsg.clearData() except: log.err('Connection to Aurora refused : died ?') pass
def SendResol(oscaddress, oscargs): oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) osclientresol = OSCClient() osclientresol.connect((oscIPresol, oscPORTresol)) print("lj23layers sending OSC message : ", oscmsg, "to Resolume", oscIPresol, ":", oscPORTresol) try: osclientresol.sendto(oscmsg, (oscIPresol, oscPORTresol)) oscmsg.clearData() except: print('Connection to Resolume refused : died ?') pass
def sendled(zzzport): global counter zzz = zzzport % 127 # zzz = led color msg = OSCMessage() msg.setAddress("/bhoreal/in") msg.append(counter) msg.append(zzz) try: client.sendto(msg, ('127.0.0.1', 9002)) msg.clearData() except: print 'Connection refused' pass sleep(0.001) counter += 1 if counter > 63: counter = 0
def SendLJ(oscaddress, oscargs=''): oscmsg = OSCMessage() oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) osclientlj = OSCClient() osclientlj.connect((redisIP, 8002)) #print("lj23layers for", name, "sending OSC message :", oscmsg, "to", redisIP, ":8002") if gstt.debug > 0: print("lj23layers for", name, "sending OSC message :", oscmsg, "to", redisIP, ":8002") try: osclientlj.sendto(oscmsg, (redisIP, 8002)) oscmsg.clearData() except: print('Connection to LJ refused : died ?') pass
def sendosc(oscaddress,oscargs): #def sendosc(oscargs): # also works : osclient.send(OSCMessage("/led", oscargs)) oscpath = oscaddress.split("/") pathlength = len(oscpath) oscmsg = OSCMessage() #print "here in sendosc in nozosc" #print oscaddress #print oscargs #raw_input("Press Enter to continue3...") if oscpath[2] == "name": print "we are asked to send a name" oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if oscpath[2] == "status": print "we are asked to send a status" oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if oscpath[2] == "knob": print "we are asked to send knob %d's value" % int(oscargs[0:3]) oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:3]))))) oscmsg.append(int(oscargs[3:100])) if oscpath[2] == "osc": #print "we are asked to send continusouly an osc value" #print oscargs oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:3]))))) #print "oscmsg:", oscmsg oscmsg.append(int(oscargs[3:100])) if oscpath[2] == "lfo": #print "we are asked to send continusouly a lfo value" oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:2]))))) oscmsg.append(int(oscargs[2:100])) if oscpath[2] == "vco": #print "we are asked to send continusouly a vco value" oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:2]))))) oscmsg.append(int(oscargs[2:100])) if oscpath[2] == "mix": #print "we are asked to send continusouly a mix value" oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:2]))))) oscmsg.append(int(oscargs[2:100])) if oscpath[2] == "X": print "we are asked to send continusouly a X value" oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if oscpath[2] == "Y": print "we are asked to send continusouly a Y value" print "oscaddress:",oscaddress print "oscargs",oscargs oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if oscpath[2] == "offset": print "we are asked to offset a curve" oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if oscpath[2] == "color": print "we are asked to change lazer color" oscmsg.setAddress(oscaddress) if len(oscargs) > 0: oscmsg.append(oscargs) try: #print oscmsg osclient.sendto(oscmsg, (oscIPout, oscPORTout)) oscmsg.clearData() except: print ('Connection refused at ',oscIPout) pass
#!/usr/bin/env python # http://shinybit.github.io/sending-osc-messages-from-pythonista/ # https://gist.github.com/shinybit/3d7e0fc7e62887ab48e931af1d4c0986 # Get pyOSC here: https://trac.v2.nl/wiki/pyOSC # The GitHub-hosted version of pyOSC is for Python 3 which isn't supported by Pythonista at the moment from OSC import OSCClient, OSCMessage client = OSCClient() client.connect(("192.168.43.120", 8000)) msg = OSCMessage("/msg/notes") msg.append([50, 60]) client.send(msg) msg.clearData() msg.append(["C3", 127]) client.send(msg) client.send(OSCMessage("/quit"))
def sendosc(oscaddress,oscargs): #def sendosc(oscargs): # also works : osclient.send(OSCMessage("/led", oscargs)) oscpath = oscaddress.split("/") pathlength = len(oscpath) oscmsg = OSCMessage() if oscpath[2] == "name": print "we are asked to send a name" oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if oscpath[2] == "status": print "we are asked to send a status" oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) if oscpath[2] == "knob": print "we are asked to send a knob value" oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:2]))))) oscmsg.append(int(oscargs[2:100])) if mydmx: joydmx(int(oscargs[0:2]),int(oscargs[2:100])) #else: # print oscmsg if oscpath[2] == "osc": #print "we are asked to send continusouly an osc value" #print oscargs oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:2]))))) oscmsg.append(int(oscargs[2:100])) #if mydmx: # nozdmx(gstt.OsciLazCoord[int(oscargs[0:2])], # int(oscargs[0:2]), # int(oscargs[2:100])) if oscpath[2] == "lfo": #print "we are asked to send continusouly a lfo value" oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:2]))))) oscmsg.append(int(oscargs[2:100])) if oscpath[2] == "vco": #print "we are asked to send continusouly a vco value" oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:2]))))) oscmsg.append(int(oscargs[2:100])) if oscpath[2] == "mix": #print "we are asked to send continusouly a mix value" oscmsg.setAddress(''.join((oscaddress,"/",str(int(oscargs[0:2]))))) oscmsg.append(int(oscargs[2:100])) if oscpath[2] == "X": print "we are asked to send continusouly a X value" oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) #print oscargs gstt.OsciLazCoord[oscargs]="X" #print gstt.OsciLazCoord[oscargs] #if mydmx: # print oscaddress # print oscargs # #print oscargs[2:100] # #nozdmx(1,int(oscargs[0:2]),int(oscargs[2:100])) if oscpath[2] == "Y": print "we are asked to send continusouly a Y value" oscmsg.setAddress(oscaddress) oscmsg.append(oscargs) gstt.OsciLazCoord[oscargs]="Y" #if mydmx: # print oscaddress # print oscargs # #print oscargs[2:100] # #nozdmx(2,int(oscargs[0:2]),int(oscargs[2:100])) if oscpath[2] == "color": print "we are asked to change lazer color" oscmsg.setAddress(oscaddress) if len(oscargs) > 0: oscmsg.append(oscargs) #print "here we are sendosc function" #print "path:",oscaddress,"pathlength:", pathlength,"oscpath:", oscpath,"args:", oscargs #oscmsg.setAddress(''.join((oscaddress,"/",oscargs))) #oscmsg.append(oscargs[0]) #oscmsg.append(oscargs) #print "oscmsg length:",len(oscmsg) #print "sending:",oscmsg #if len(oscmsg) > 0: # try: #send to sam nrhck # osclient.sendto(oscmsg, (oscIPout2, oscPORTout2)) #print ('Connection accepted @ sam ',oscIPout2) # except: # print ('Connection refused @ sam ',oscIPout2) # pass try: osclient.sendto(oscmsg, (oscIPout, oscPORTout)) oscmsg.clearData() except: print ('Connection refused at ',oscIPout) pass