コード例 #1
0
def test_OSC():
    from time import sleep
    from OSC3 import OSCClient, OSCMessage
    import json
        
    receiver_thread()
    
    clt = OSCClient()
    address = ("127.0.0.1", 8080)
    
    for i in range(10):
        msg = OSCMessage("/info")
        sleep(0.1)
        msg.append(i)
        try:
            clt.sendto(msg, address)
            print("msg envoyé", msg)
        except:
            print("msg non envoyé")
            
    # Test d'envoi
    for nb in range(10):
        clt_send = UdpClient()

        data = {"phone": nb}
        data = json.dumps(data).encode("utf-8")

        clt_send.send_to(data, ("127.0.0.1", 9999))

        print("Envoi de {}".format(data))

        clt_send.close()

        # 60 Hz
        sleep(0.1)
コード例 #2
0
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", ip, ":",
                  port)

        osclient.sendto(oscmsg, (ip, port))
        oscmsg.clearData()
        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
コード例 #3
0
def OSCsend(name, oscaddress, oscargs=''):

    #print "OSCsend in plugins got for", name, ": oscaddress", oscaddress, "oscargs :", oscargs
    PluginPort = Port(name)
    #sendWSall("/status Checking "+ name + "...")

    osclientplugin = OSCClient()
    osclientplugin.connect((gstt.LjayServerIP, PluginPort))
    oscmsg = OSCMessage()
    oscmsg.setAddress(oscaddress)
    oscmsg.append(oscargs)

    try:
        if gstt.debug > 0:
            print("Plugins manager : OSCsending", oscmsg, "to plugin", name,
                  "at", gstt.LjayServerIP, ":", PluginPort)

        osclientplugin.sendto(oscmsg, (gstt.LjayServerIP, PluginPort))
        oscmsg.clearData()
        if gstt.debug > 0:
            print(oscaddress, oscargs, "was sent to", name)
        return True

    except:
        if gstt.debug > 0:
            print('OSCSend : Connection to plugin IP', gstt.LjayServerIP, ':',
                  PluginPort, 'refused : died ?')
        #sendWSall("/status No plugin.")
        #sendWSall("/status " + name + " is offline")
        #sendWSall("/" + name + "/start 0")
        #PluginStart(name)
        return False
コード例 #4
0
def Send(oscaddress, oscargs=''):

    oscmsg = OSCMessage()
    oscmsg.setAddress(oscaddress)
    oscmsg.append(oscargs)

    osclient = OSCClient()
    osclient.connect((ip, port))

    print("sending OSC message : ", oscmsg, "to", ip, ":", port)
    try:
        osclient.sendto(oscmsg, (ip, port))
        oscmsg.clearData()
        return True
    except:
        print('Connection to', ip, 'refused : died ?')
        return False