Esempio n. 1
1
def loop(serial, host, port):
    osctx = osc_init( (host, port) )
    bitadev = bitalino_init(serial)
    if not bitadev:
        raise Exception("Coultdn't open the BITalino device")

    try:
        print "Entering reading loop..."
        while True:
            samples = bitadev.read()
            time.sleep(0.005)
            #bitadev.trigger(digitalOutput)
            for s in samples:
                msg = OSCMessage()
                msg.setAddress("/biosample")
                out = []

                for sval in s:
                    out.append(sval / 1024)

                msg.append(out)
                #print msg
                osctx.send( msg )
    except KeyboardInterrupt as e:
        print "Looks like you wanna leave. Good bye!"
    finally:
        bitadev.stop()
        bitadev.close()
Esempio n. 2
0
def trajectory_callback(path, tags, args, source):
    trajectory = args[0]
    tokens = trajectory.split(";")
    tPoints = []
    for t in tokens[:-1]:
        tPoints.append(map(lambda x: int(x), t.split(",")))

    client = OSCClient()
    client.connect((source[0], 8001))
    client.send(OSCMessage("/busy"))

    shuffle(tPoints)
    print "Executing", tPoints
    createPath(tPoints)

    if random() > 0.5:
        b = 0
        if random() > 0.5:
            b = 1
        print "Push extra", b
        pushButtonExtra(b, 0.5 + random() * 3)

    client = OSCClient()
    client.connect((source[0], 8001))
    client.send(OSCMessage("/noBusy"))
Esempio n. 3
0
    def __init__(self, address):
        OSCServer.__init__(self, ('', 0))
        self.client.connect(address)
        host, port = self.client.socket.getsockname()

        self.focused = False
        #self.server_host = host
        #self.server_port = port
        self.prefix = DEFAULT_PREFIX

        self.addMsgHandler('default', self.monome_handler)
        self.addMsgHandler('/sys/connect', self.sys_misc)
        self.addMsgHandler('/sys/disconnect', self.sys_misc)
        self.addMsgHandler('/sys/id', self.sys_misc)
        self.addMsgHandler('/sys/size', self.sys_size)
        self.addMsgHandler('/sys/host', self.sys_host)
        self.addMsgHandler('/sys/port', self.sys_port)
        self.addMsgHandler('/sys/prefix', self.sys_prefix)
        self.addMsgHandler('/sys/rotation', self.sys_misc)

        # handshake
        msg = OSCMessage("/sys/host")
        msg.append(host)
        self.client.send(msg)

        msg = OSCMessage("/sys/port")
        msg.append(port)
        self.client.send(msg)

        msg = OSCMessage("/sys/info")
        self.client.send(msg)
Esempio n. 4
0
 def send(self,name,val=None):
     msg = OSCMessage(name)
     if val is not None:
         msg.append(val)
     r = self.client.send(msg)
     self.osc_messages_sent += 1
     return r
Esempio n. 5
0
    def record_data(self):
        if(self.port is None):
            return None
        
        print "Logging started"
        
        while 1:
            localtime = datetime.now()
            current_time = str(localtime.hour)+":"+str(localtime.minute)+":"+str(localtime.second)+"."+str(localtime.microsecond)
            log_string = current_time
            results = {}
            for index in self.sensorlist:
                (name, value, unit) = self.port.sensor(index)
                log_string = log_string + ","+str(value)
                results[obd_sensors.SENSORS[index].shortname] = value;
                
				#send sensor data via OSC
                message = OSCMessage()
                message.setAddress("/"+obd_sensors.SENSORS[index].shortname)
                message.append(value)
                self.client.send(message)

            gear = self.calculate_gear(results["rpm"], results["speed"])
            log_string = log_string #+ "," + str(gear)
			#send gear via OSC
            message = OSCMessage()
            message.setAddress("/gear")
            message.append(gear)
            self.client.send(message)
            self.log_file.write(log_string+"\n")
Esempio n. 6
0
    def on_frame(self, controller):
        # Get the most recent frame and report some basic information
        frame = controller.frame()
        #print ("Frame id: %d, timestamp: %d, hands: %d, fingers: %d, tools: %d" % (
        #              frame.id, frame.timestamp, len(frame.hands), len(frame.fingers), len(frame.tools)))

        if not frame.hands.empty:
            bundle = OSCBundle()

            bundle.append(
                OSCMessage("/leap/frame/timestamp", str(frame.timestamp)))

            for hand in frame.hands:
                handPos = OSCMessage("/leap/frame/hand/pos", [
                    hand.id, hand.palm_position[0], hand.palm_position[1],
                    hand.palm_position[2]
                ])
                bundle.append(handPos)
                normal = hand.palm_normal
                direction = hand.direction
                #handOrientation = OSCMessage("/leap/frame/hand/orientation",
                #    [hand.id, hand.palm_position[0], hand.palm_position[1], hand.palm_position[2]])
                #bundle.append(handOrientation)

            self.osc_client.send(bundle)
Esempio n. 7
0
class SendOSC(object):

    def __init__(self):
        self.osc_message = None
        self.osc_client = OSCClient()
        self.osc_message = OSCMessage()        
        
        self.ip = ""
        self.port = 0

    def connect(self, ip="localhost", port=8080):
        self.ip = ip
        self.port = port
        self.osc_client.connect((self.ip, self.port))

    def send(self, address, value):
        self.osc_message.setAddress(address)
        self.osc_message.append(value)
        self.osc_client.send(self.osc_message)

    def send_distane(self, distance):
        oscdump = "/dumpOSC/DistanceTipTarget"
        self.send(oscdump, distance)

    def send_needle_tip_position(self, x, y, z):
        oscdump = "/dumpOSC/needltip/x"
        self.send(oscdump, x)
        oscdump = "/dumpOSC/needltip/y"
        self.send(oscdump, y)
        oscdump = "/dumpOSC/needltip/z"
        self.send(oscdump, z)
Esempio n. 8
0
 def kit(self,arrCmd):   #this one's more for my own set
     oscm = OSCMessage("/live/track/device/param" )
     oscm.append(self.int_or_string(arrCmd[0]))  #track
     oscm.append('Kits','s')                     #device named kits
     oscm.append(9,'i')                          #param chain selector
     oscm.append(int(arrCmd[1]),'i')             #value
     return oscm
Esempio n. 9
0
 def send(self, name, val=None):
     msg = OSCMessage(name)
     if val is not None:
         msg.append(val)
     r = self.client.send(msg)
     self.osc_messages_sent += 1
     return r
Esempio n. 10
0
def hardware_callback(addr, tags, d, client_address):
    #d is data

    h_id = int(addr.split("/")[-1])

    event = None
    error = False

    if h_id == JUNCTION:
        if len(d) == 13:    
            #create event object
            event = pygame.event.Event(NETWORK_HARDWARE,{"hardware_id":JUNCTION,
                    "topRowOn":d[0],1:d[1],2:d[2],3:d[3],4:d[4],5:d[5],6:d[6],
                    7:d[7],8:d[8],9:d[9],10:d[10],11:d[11],12:d[12]})
        else:
            error = True
    elif h_id == SCIENCE:
        event = pygame.event.Event(NETWORK_HARDWARE,{"hardware_id":SCIENCE,"s1":True})
    elif h_id == COMMANDER:
        event = pygame.event.Event(NETWORK_HARDWARE,{"hardware_id":COMMANDER,"has_power":True})
    elif h_id == RADIO:
        event = pygame.event.Event(NETWORK_HARDWARE,{"hardware_id":RADIO,"frequency":55})

    if event != None:
        pygame.event.post(event)
    if error:
        #object malformed, return error
        msg = OSCMessage("/user/1")
        msg.append("Error")
        server.client.sendto(msg,client_address)
Esempio n. 11
0
def fader_callback(path, tags, args, source):
	print ("path", path) 
	print ("args", args) 
	print ("source", source) 
	msg=OSCMessage("/1/rotary1")
	msg.append(args);
	client.send(msg)
Esempio n. 12
0
    def messageServer(self, messagePath, argument):
        client = OSCClient()
        client.connect((self.serverIP, self.serverPort))
        message = OSCMessage(messagePath)
        message.append(argument)

        client.send(message)
Esempio n. 13
0
def sl_pos(path, tags, args, source):
    #doesn't work till record is pressed after script is going
    if path == "/sl_pos":
        if looplist[args[0]].state != 2:
            pos = args[2]

            eigth_pos = int((pos / looplist[args[0]].len) * 8)

            ##            this didnt work because.. position isn't sent/triggered
            ##            while length is changing from length, could be called if necessary
            ##            if (looplist[args[0]].state  == 2 ) == True:
            ##                print "truth"

            if looplist[args[
                    0]].pos_eigth != eigth_pos:  #dont repeat values more than once

                print args[0], eigth_pos

                looplist[args[0]].pos_eigth = eigth_pos

                client2.send(OSCMessage("/lp2", [eigth_pos, args[0], 0, 1]))
                if eigth_pos > 0:
                    client2.send(
                        OSCMessage("/lp2", [eigth_pos - 1, args[0], 0, 0]))
                elif eigth_pos == 0:
                    client2.send(OSCMessage("/lp2", [7, args[0], 0, 0]))
def serialComms():
	while run:
		proximity = ser.readline()
		proxMsg = OSCMessage()
		proxMsg.setAddress(OSCAddress)
		proxMsg.append(proximity)
		columnClient.send(proxMsg)
Esempio n. 15
0
def toggleMuteGroup(channel, state):
 stringChannel = str(channel)
 muteAddress = '/config/mute/' + stringChannel
 msg = OSCMessage(muteAddress)
 msg.append(state)
 client.send(msg)
 print msg
Esempio n. 16
0
def send_event():
    spectral_densities = ['filled', 'packed', 'opaque','translucent','transparent','empty']
    # fill blanks
    data = ['']*17*3
    #onset, continuant, termination
    data[0] = 'attack'

    #elegimos el de mayor momento transversal
    i = [l for l in tree.lep_pt].index(max(tree.lep_pt))

    #duration, based on momento transversal .. lep_pt
    data[1] = mapValue(tree.lep_pt[i],0,100000,0.1,10)
    #Spectrum types: electrones : inarmonico  ,  muones:  granular
    data[10] = 'inharmonic' if tree.lep_type[i] == 11 else 'granular'
    #Spectrum occupation: angulo
    data[11] = 'center'
    #Spectrum density: lepton energy .. lep_E
    data[16] = spectral_densities[int(mapValue(tree.lep_E[i],0,100000,0,5))]

    bundle = OSCBundle()
    msg = OSCMessage("/"+args.messagename)
    for d in data:
        msg.append(d)
    bundle.append(msg)
    client.send(bundle)
Esempio n. 17
0
 def send(self, sample):
     mes = OSCMessage(self.address)
     mes.append(sample.channel_data)
     try:
         self.client.send(mes)
     except:
         return
Esempio n. 18
0
def sendPosition(positionX, positionY):
    MSG_ = OSCMessage('/position')
    MSG_ += positionX
    MSG_ += positionY
    #print(MSG_)
    binary = MSG_.getBinary()
    sock.sendto(binary, (UDP_IP, UDP_PORT))
Esempio n. 19
0
 def send_oscbundle(self):
     # send a bundle with current bpm and polar coordinates of 
     # sound-objects relative to player
     #            /game/bpm
     client = OSCClient()
     bpm = OSCMessage()     
     bpm.setAddress("/game/bpm")
     bpm.append(self.player['bpm'])   
     bundle = OSCBundle()
     bundle.append(bpm)
     #            /game/sndobj/id-bola (ang, mod)  
     scn = bge.logic.getCurrentScene()
     play = scn.objects["player"]
     
     for ball in self.soundobjects:
         ballpos = ball.worldPosition
         vect = mathutils.Vector((0,1))
         dist = play.getVectTo(ballpos)[0]
         vect2 = play.getVectTo(ballpos)[2].to_2d()
         angle = math.degrees(-vect.angle_signed(vect2))
         #print("angle ", angle, "distancia ",dist)
         data = (angle, dist)
         # append data to bundle
         msg = OSCMessage()
         tag = "/game/sndobj/position/" + str(ball['id'])
         msg.setAddress(tag)
         msg.append(data)
         bundle.append(msg)
         #print(msg)
     #gl.client is a tuple in gl with ip and port
     client.sendto(bundle, gl.send_to)
def sendOscMessage(_x, _y, _w, _h):
    if x > 1 and y > 1:
        global client
        connectOsc()
        msg = OSCMessage("/shast/coordenadas")
        msg.extend([_x, _y, _w, _h])
        client.send(msg)
Esempio n. 21
0
def espaces_callback(path, tags, args, source):

    msg_string = ""
    msg_string += "\n\tpath   : %s" % path
    msg_string += "\n\ttags   : %s" % tags
    msg_string += "\n\targs   : %s" % args
    msg_string += "\n\tsource :%s" % str(source)
    print "OSCServer received: %s\nfrom %s.\n" % (msg_string, getUrlStr(source))

    ir_params = {  'duration'      : float(args[4]),
                   'nu'            : float(args[5]),
                   'sampling_rate' : float(args[6]),
                   'ev_params'     : {'space': str(args[1]), 'c':float(args[2]), 'j_max':int(args[3]),'F':list(args[7:])},
                }

    command = espace_client.handle_request(ir_params)

    # send reply to the client
    reply_port = int(args[0])
    reply_addresse = (source[0], reply_port)
    msg = OSCMessage("/pd")
    msg.append(command['saved_audio_path'])
    server.client.sendto(msg,reply_addresse,timeout=1)
    print "OSCServer send:\n\t%s\nto %s.\n" %(msg,reply_addresse)

    return OSCMessage("/")
def sendMessage():
    msg = OSCMessage()
    msg.setAddress("/oscTest")
    msg.append(100)
    print "sending '/oscTest 100' message to SuperCollider"
    client.send(msg)
    timedSendMessage()  # recursive call, keeps the timer going
Esempio n. 23
0
 def send(self, sample):
     mes = OSCMessage(self.address)
     mes.append(sample.channel_data)
     try:
         self.client.send(mes)
     except:
         return
Esempio n. 24
0
 def serve_forever(self):
     for msg in self.json_to_osc_q:
         osc_msg = OSCMessage(self.osc_command_name)
         osc_msg.append(msg[0]) #HTTP verb
         osc_msg.append(msg[1]) #HTTP path
         osc_msg.append(msg[2]) #content
         self.osc_client.send(osc_msg)
Esempio n. 25
0
  def handle_sample(self, sample):
    mes = OSCMessage(self.address)
	mes.append(sample.channel_data)
	# silently pass if connection drops
	try:
		self.client.send(mes)
	except:
		return	
Esempio n. 26
0
def send_osc_message(name, *args):
	msg = OSCMessage(name)
	for arg in args:
		msg.append(arg)
	try:
		client.send(msg, 0)
	except Exception, e:
		pass
Esempio n. 27
0
def sendOSCMessage(pin, value):
  # LOW/0 = pressed and HIGH/1 = released
  # example: "/b/p 12 0"
  if (value == 0):
    obj = OSCMessage("/b/p")
  else:
    obj = OSCMessage("/b/r")
  obj.append(int(pin))
Esempio n. 28
0
 def send(self, path, value):
     try:
         message = OSCMessage(path)
         message.append(value)
         self.osc.send(message)
     except:
         print "Error connecting to OSC server. Re-initiating Connection."
         self.setup_connection()
Esempio n. 29
0
def rotary1_callback(path, tags, args, source):
	print str(path) + " " + str(args[0])
	json.send({'command':'put', 'key':'rotary1', 'value':'%i' % int(args[0])})
	#create feedback for faders label:	
	msg = OSCMessage("/1/label_rotary1")
	msg.insert(0, int(args[0]))
	client.connect( (source[0], 9000) )
	client.send(msg)
Esempio n. 30
0
def sendOscMessage(_x, _y, _w, _h):
    if x > 1 and y > 1:
        global client

        connectOsc()

        msg = OSCMessage("/shast/coordinates")
        msg.extend([_x, _y, _w, _h])
        client.send( msg )
def fader_callback(path, tags, args, source):
	global fader1Feedback
	if path=="/1/fader1":
		fader1Feedback = float(args[0])
		msg = OSCMessage("/1/label1")
		msg.insert(0, fader1Feedback)
		print "%i" % fader1Feedback
		json.send({'command':'put', 'key':'D13', 'value':'%i' % (fader1Feedback)})
		client.send(msg)
Esempio n. 32
0
 def loopend(self,arrCmd):
     oscm = OSCMessage("/live/clip/loop/end")
     oscm.append(self.int_or_string(arrCmd[0])) #track
     oscm.append(int(arrCmd[1])) #slot
     if arrCmd[2].lower() == 'bars':
         oscm.append((float(arrCmd[3]) - 1) * self.parent.signature_numerator) #position in beats
     else:
         oscm.append(float(arrCmd[3]) - 1) #position in beats
     return oscm
def loop():
    global messageQ, clientMap, oscOut, currentButtonState, lastDownTime, isRecording, audioThread

    ## deal with UI
    previousButtonState = currentButtonState
    currentButtonState = GPIO.input(SWITCH_PIN)
    buttonJustGotPressed = (currentButtonState is GPIO.HIGH
                            and previousButtonState is GPIO.LOW)
    buttonJustGotReleased = (currentButtonState is GPIO.LOW
                             and previousButtonState is GPIO.HIGH)
    if buttonJustGotPressed:
        lastDownTime = time()

    if (isRecording):
        if ((time() - lastDownTime > 8.0)
                or (buttonJustGotReleased and (time() - lastDownTime > 1.0))
                or buttonJustGotPressed):
            isRecording = False
            GPIO.output(LED_PIN, GPIO.LOW)
            audioThread.join()
            call('rm -rf vox.mp3', shell=True)
            call('lame -mm -r vox.raw vox.mp3', shell=True)
            call('cp vox.mp3 data/vox_' +
                 strftime("%Y%m%d_%H%M%S", localtime()) + '.mp3',
                 shell=True)
            call('rm -rf vox.raw', shell=True)
            _setupAudio()
            messageQ.put((1, VOICE_MESSAGE_STRING))
    elif buttonJustGotPressed:
        isRecording = (not audioInput is None)
        GPIO.output(LED_PIN, GPIO.HIGH)
        audioThread = RecordThread()
        audioThread.start()

    ## deal with messages
    if (not messageQ.empty()):
        # TODO change this to something more complicated...
        # TODO nltk
        msg = messageQ.get()[1]
        for index, (i, p) in enumerate(clientMap):
            if (time() - clientMap[(i, p)] < 60):
                oscMsg = OSCMessage()
                oscMsg.setAddress("/ffqmevox")
                oscMsg.append(msg.encode('utf-8'))
                ## TODO: pan and tilt and delay
                oscMsg.append(randint(0, 255))
                oscMsg.append(randint(0, 255))
                oscMsg.append(0 if random() < 0.66 else index *
                              len(msg.encode('utf-8')) * 200)
                try:
                    oscOut.connect((i, p))
                    oscOut.sendto(oscMsg, (i, p))
                    oscOut.connect((i, p))
                except OSCClientError:
                    print "no connection to %s : %s, can't send message" % (i,
                                                                            p)
Esempio n. 34
0
 def send(self, name, val=None):
     if self.current_bundle is None:
         super(BundledMixin,self).send(name,val)
     else:
         self.osc_messages_sent += 1
         #log("Bundle: %s\n" % self.current_bundle)
         msg = OSCMessage(name)
         if val is not None:
             msg.append(val)
         self.current_bundle.append(msg)
Esempio n. 35
0
def shutdown():

    print "shutdown"
    client1.send(OSCMessage("/shutdown"))  # message sent
    client2.send(OSCMessage("/shutdown"))  # message sent
    client3.send(OSCMessage("/shutdown"))  # message sent
    client4.send(OSCMessage("/shutdown"))  # message sent
    client5.send(OSCMessage("/shutdown"))  # message sent
    # https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=133665
    call("sudo reboot now", shell=True)
def callback_videoStop(path, tags, args, source):
    if args[0] == 1.0:
        msg = OSCMessage(
        )  #  we reuse the same variable msg used above overwriting it
        msg.setAddress("/millumin/action/stopColumn")
        print "stopVideo"
        client.send(
            msg)  # now we dont need to tell the client the address anymore
        client2.send(
            msg)  # now we dont need to tell the client the address anymore
Esempio n. 37
0
def sendOSCnextlevel():
        client = OSCClient()
        msg = OSCMessage()
        # gl.client is a tuple in gl with ip and port
        address = "/game/nextlevel"
        msg.setAddress(address)
        msg.append(currentlevel)
        client.sendto(msg, gl.send_to)
        #print('Send message example =', msg, "to ", gl.send_to)
        return
Esempio n. 38
0
 def send(self, name, val=None):
     if self.current_bundle is None:
         super(BundledMixin, self).send(name, val)
     else:
         self.osc_messages_sent += 1
         #log("Bundle: %s\n" % self.current_bundle)
         msg = OSCMessage(name)
         if val is not None:
             msg.append(val)
         self.current_bundle.append(msg)
Esempio n. 39
0
 def _oscHandler(self, addr, tags, stuff, source):
     addrTokens = addr.lstrip('/').split('/')
     ## list of all receivers
     if ((addrTokens[0].lower() == "localnet")
           and (addrTokens[1].lower() == "receivers")):
         ## as good, if not better than a ping
         self.lastPingTime = time.time()
         print "got receivers %s"%(stuff[0])        
         for rcvr in stuff[0].split(','):
             self.allReceivers[rcvr] = rcvr
         if(self.subscribedToAll and not self.subscribedReceivers):
             self.subscribeToAll()
     ## hijack /LocalNet/Add !
     elif ((addrTokens[0].lower() == "localnet")
         and (addrTokens[1].lower() == "add")):
         ip = getUrlStr(source).split(":")[0]
         port = int(stuff[0])
         print "adding %s:%s to PantallaServer" % (ip, port)
         self.allClients[(ip,port)] = addrTokens[2]
     ## hijack a /LocalNet/ListReceivers
     elif ((addrTokens[0].lower() == "localnet")
           and (addrTokens[1].lower().startswith("listreceiver"))):
         ip = getUrlStr(source).split(":")[0]
         port = int(stuff[0])
         ## send list of receivers to client
         msg = OSCMessage()
         msg.setAddress("/LocalNet/Receivers")
         msg.append(self.name)
         print "got a request for receivers from %s:%s"%(ip,port)
         try:
             #self.oscClient.connect((ip, port))
             self.oscClient.sendto(msg, (ip, port))
             #self.oscClient.connect((ip, port))
         except OSCClientError:
             print "no connection to %s:%s, can't send list of receivers"%(ip,port)
     ## actual message from AEffect Network !!
     elif (addrTokens[0].lower() == "aeffectlab"):
         self.messageQ.put((addrTokens[1],
                            addrTokens[2],
                            stuff[0].decode('utf-8')))
         self.messageQ.put((addrTokens[1],
                            addrTokens[2],
                            stuff[0].decode('utf-8')))
     ## ping
     if ((addrTokens[0].lower() == "localnet")
         and (addrTokens[1].lower() == "ping")):
         self.lastPingTime = time.time()
         # forward to clients
         for (ip,port) in self.allClients.keys():
             try:
                 #self.oscClient.connect((ip, int(port)))
                 self.oscClient.sendto(self.oscPingMessage, (ip, int(port)))
                 #self.oscClient.connect((ip, int(port)))
             except OSCClientError:
                 print ("no connection to %s:%s, can't send bang"%(ip,port))
Esempio n. 40
0
 def send_destroy(self,id):
     #
     client = OSCClient()
     msg = OSCMessage()
     # gl.client is a tuple in gl with ip and port
     address = "/game/sndobj/destroy"
     msg.setAddress(address)
     msg.append(id)
     client.sendto(msg, gl.send_to)
     #print('Send message example =', msg, "to ", gl.send_to)
     return    
def serialComms():
	while run:
		proximity = ser.readline()
		proxMsg = OSCMessage()
		proxMsg.setAddress(OSCAddress)
		proxMsg.append(proximity)
		try:
			columnClient.send(proxMsg)
		except:
			print("client unavailable")
			pass
def sendMessage():
    msg = OSCMessage()
    msg.setAddress("/oscTest")
    msg.append(100)
    print "Sending '/oscTest 100' message to SuperCollider"
    try:
        client.send(msg)
    except:
        print "Waiting for SuperCollider to become available..."
        pass
    timedSendMessage()  # recursive call, keeps the timer going
Esempio n. 43
0
def test_callback(path, tags, args, source):

    client = OSCClient()
    client.connect((source[0], 8001))
    client.send(OSCMessage("/busy"))
    print "Do test"
    pushTwo((2, 4), (2, 5))

    client = OSCClient()
    client.connect((source[0], 8001))
    client.send(OSCMessage("/noBusy"))
Esempio n. 44
0
 def send_choque(self):
     #
     client = OSCClient()
     msg = OSCMessage()
     # gl.client is a tuple in gl with ip and port
     address = "/player/choque"
     msg.setAddress(address)
     msg.append(0)
     client.sendto(msg, gl.send_to)
     #print('Send message example =', msg, "to ", gl.send_to)
     return
Esempio n. 45
0
def zero_callback(path, tags, args, source):

    client = OSCClient()
    client.connect((source[0], 8001))
    client.send(OSCMessage("/busy"))
    print "Go Zero"
    goToZero()

    client = OSCClient()
    client.connect((source[0], 8001))
    client.send(OSCMessage("/noBusy"))
Esempio n. 46
0
 def send_stop(self):
     # da stop al soundengine
     client = OSCClient()
     msg = OSCMessage()
     # gl.client is a tuple in gl with ip and port
     address = "/game/stop"
     msg.setAddress(address)
     msg.append(0)
     client.sendto(msg, gl.send_to)
     #print('Send message example =', msg, "to ", gl.send_to)
     return
Esempio n. 47
0
 def knob(self,arrCmd):
     if arrCmd[0].lower() == "send":
         oscm = OSCMessage("/live/return/device/param" )
         arrCmd.pop(0)
     else:
         oscm = OSCMessage("/live/track/device/param" )
     oscm.append(self.int_or_string(arrCmd[0]))  #track
     oscm.append(self.int_or_string(arrCmd[1]))  #device
     oscm.append(self.int_or_string(arrCmd[2]))  #param
     oscm.append(float(arrCmd[3]),'f')           #value
     return oscm
Esempio n. 48
0
def rotary1_callback(path, tags, args, source):
    print str(path) + " " + str(args[0])
    json.send({
        'command': 'put',
        'key': 'rotary1',
        'value': '%i' % int(args[0])
    })
    #create feedback for faders label:
    msg = OSCMessage("/1/label_rotary1")
    msg.insert(0, int(args[0]))
    client.connect((source[0], 9000))
    client.send(msg)
Esempio n. 49
0
def play_scene_02(path, tags, args, source):
    print path
    print source  # who is sending the message to the server

    print "play_scene_02"
    client1.send(OSCMessage("/play/scene/2"))  # message sent
    client2.send(OSCMessage("/play/scene/2"))  # message sent
    client3.send(OSCMessage("/play/scene/2"))  # message sent
    client4.send(OSCMessage("/play/scene/2"))  # message sent
    client5.send(OSCMessage("/play/scene/2"))  # message sent

    print "client messages sent"
    player.load("/home/pi/Videos/scene_02_01_flora.mp4")
Esempio n. 50
0
def fader_callback(path, tags, args, source):
    global fader1Feedback
    if path == "/1/fader1":
        fader1Feedback = float(args[0])
        msg = OSCMessage("/1/label1")
        msg.insert(0, fader1Feedback)
        print "%i" % fader1Feedback
        json.send({
            'command': 'put',
            'key': 'D13',
            'value': '%i' % (fader1Feedback)
        })
        client.send(msg)
Esempio n. 51
0
def my_callback(channel):
    global timePulse
    if (time.time() - timePulse) > timerPulse:
        try:
            msg = OSCMessage(
            )  #  we reuse the same variable msg used above overwriting it
            msg.setAddress("/keydown")
            print "/keydown"
            client.send(
                msg)  # now we dont need to tell the client the address anymore
            timePulse = time.time()
        except:
            print("Sin conexion OSC")
Esempio n. 52
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",
                  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
Esempio n. 53
0
def update():
    message = OSCMessage()  #Create the OSC Message
    message.setAddress("/myoscaddress")  #Define the OSC Address
    message.append(44)  #first argument
    message.append(11)  #second argument
    message.append(4.5)  #third argument
    oscclient.sendto(message, (OSC_DEST_IP, OSC_DEST_PORT))  #send osc message
Esempio n. 54
0
def sendColor(color):

    message = OSCMessage()  #Create the OSC Message
    message.setAddress("/tph/color")  #Define the OSC Address
    message.append(int(color.r))
    message.append(int(color.g))
    message.append(int(color.b))
    oscclient.sendto(message, (OSC_DEST_IP, OSC_DEST_PORT))  #send osc message
Esempio n. 55
0
	def updateNode(self,args,BSSID,kind):
		if BSSID == " ":
			return 
		msg =  OSCMessage("/update")
		msg.append(kind.strip())
		msg.append(args)
		msg.append(BSSID.strip()) 
		self.client.send(msg)
def goto(end, s):
    global angle
    if abs(end - angle) < 1:
        return

    print "Moving from: ", angle, " to: ", end, " in: ", s, " s"

    init = angle * 1.0
    end = end * 1.0
    steps = s / SERVO_DELTA_TIME
    inc = abs(init - end) / steps
    for i in range(int(steps) + 1):
        pos = inc * i

        if init > end:
            a = init - pos
        else:
            a = init + pos

        if a < 0:
            a = 0
        if a > SERVO_MAX_ANGLE:
            a = SERVO_MAX_ANGLE

        angle = a
        try:
            client.send(OSCMessage("/angle", [args.identifier, int(angle), 1]))
        except:
            pass
        p.ChangeDutyCycle(duty(a))
        time.sleep(SERVO_DELTA_TIME)
Esempio n. 57
0
def main(args):

    # Default host and port
    HOST = '192.168.1.8'
    PORT = 3032
    
    if len(args) == 2:
        HOST = args[0]
        PORT = args[1]
    elif len(args) == 1:
        HOST = args[0]
    elif len(args) > 2:
        errorPrint("OSC Go button accepts at most 2 arguments.\n" + len(args) + " were provided.");

    client = OSCClient()
    client.connect((HOST, PORT))

    msg = OSCMessage("/eos/key/go_0");
    client.send(msg);
    client.close();

    print
    print "GO"
    print
    exit();
Esempio n. 58
0
def ping_callback(path, tags, args, source):
    try:
        client = OSCClient()
        client.connect((source[0], 8001))
        client.send(OSCMessage("/ping"))
    except Exception as e:
        print e