예제 #1
0
 def send2arg(self, adr, val1, val2):
     osc = OSC.OSCClient()
     self.adr = adr
     self.val1 = val1
     self.val2 = val2
     self.msg = OSC.OSCMessage()
     self.msg.setAddress(self.adr)
     self.msg.append(self.val1)
     self.msg.append(self.val2)
     osc.sendto(self.msg, self.destination)
예제 #2
0
def packageAndSend(feature):
	global osc
	if (osc[feature][1] != 0):
		if (time.time() - osc[feature][0] > osc[feature][1]):
			print('*************SENT TO MUSIC SERVER: ' + str(feature) + str(time.time() - osc[feature][0]))
			osc[feature][0] = time.time()
			oscmsg = OSC.OSCMessage()
			oscmsg.setAddress('/bang')
			oscmsg.append(feature)
			c.send(oscmsg)
예제 #3
0
def oscSendSwitch(switch, state):
    try:
        client.sendto(
            OSC.OSCMessage(
                "/" + cfg.switch[switch + cfg.activePage * 4].name,
                cfg.switch[switch + cfg.activePage * 4].stateNames[state]),
            app)
        cfg.switch[switch + cfg.activePage * 4].state = state
    except:
        pass
예제 #4
0
def filter():
    #GPIO.output(mux3s0, 0)
    #GPIO.output(mux3s1, 0)
    #GPIO.output(mux3s2, 1)
    filterVal = int(mcp2.read_adc(1))
    filtFreqOSC = OSC.OSCMessage('/filter/freq')
    filtFreqOSC.append(filterVal / 7.9)
    c.send(filtFreqOSC)

    if (DEBUG):
        print(filterVal / 7.9)

    GPIO.output(mux3s0, 1)
    GPIO.output(mux3s1, 1)
    GPIO.output(mux3s2, 1)
    resVal = int(mcp2.read_adc(0))
    filtResOSC = OSC.OSCMessage('/filter/res')
    filtResOSC.append(resVal / 103.2)
    c.send(filtResOSC)
예제 #5
0
def filterSelect():
    global currentFilter
    filtSelBtn = GPIO.input(filterSel)
    if (filtSelBtn == 1):
        print('filter')
        if (currentFilter == 0):
            filtTypeOSC = OSC.OSCMessage('/filter/type')
            GPIO.output(filterLed, 1)
            filtTypeOSC.append(1)
            c.send(filtTypeOSC)
            currentFilter = 1

        elif (currentFilter == 1):
            filtTypeOSC = OSC.OSCMessage('/filter/type')
            GPIO.output(filterLed, 0)
            filtTypeOSC.append(0)
            c.send(filtTypeOSC)
            currentFilter = 0
        time.sleep(0.2)
예제 #6
0
def send(data):
    oscmsg = OSC.OSCMessage()
    oscmsg.setAddress("/wek/inputs")
    for i, elem in enumerate(data):
        oscmsg.append(float(elem))

    wek.send(oscmsg)
    print(oscmsg)
    #print oscmsg[1:]
    print(data)
예제 #7
0
def set_drum_volume(percentage):
    address = "/lpc/maestro/drums/volume"
    message = OSC.OSCMessage()
    message.setAddress(address)
    if (percentage < 0):
        percentage = 0
    if (percentage > 150):
        percentage = 150
    message.append(int(percentage))
    send_message_to_maestro(message, address)
예제 #8
0
def set_maestro_IP(maestro_IP_string):
    global note_destination_hostname
    note_destination_hostname = maestro_IP_string

    # Send an init message to maestro to tell it to stop all voices
    message = OSC.OSCMessage()
    address = "/lpc/maestro/init"
    message.setAddress(address)
    message.append(int(0))
    send_message_to_maestro(message, address)
예제 #9
0
 def sendOSCMessage(self, address, message):
     try:
         # Send message to client through OSC
         oscmsg = OSC.OSCMessage()
         oscmsg.setAddress("/" + address)
         oscmsg.append(message)
         self.c.send(oscmsg)
         print "Sent message : ", message, " at ", address
     except:
         print "No receiver"
예제 #10
0
def createBinaryMsg(oscAddress, dataArray):
    '''create and return general type binary OSC msg
    '''
    m = OSC.OSCMessage()
    m.address = oscAddress

    for x in dataArray:
        m.append(x)

    return m.getBinary()
예제 #11
0
def send_connect(client, a, b, c, d):
    msg = OSC.OSCMessage()
    msg.setAddress("/connect")
    msg.append(a)
    msg.append(b)
    msg.append(c)
    msg.append(d)
    client.send(msg)
    print "Sending", msg
    send_recompile(client)
예제 #12
0
 def send_pos(self):
     partner = OSC.OSCClient()
     partner.connect((self.partner, 7730))   # localhost, port 57120
     oscmsg = OSC.OSCMessage()
     oscmsg.setAddress("/lastpos")
     while True:
         current_pos=self.read_current_pos()
         oscmsg.append(current_pos)
         partner.send(oscmsg)
         time.sleep(5)
예제 #13
0
 def updateChannel(self, addr, tags, stuff, source):
     chanInd = stuff[0]
     transFunc = self.channels[chanInd][0]
     rootMel = self.channels[chanInd][1]
     newMel = transFunc(rootMel)
     msg = OSC.OSCMessage()
     msg.setAddress("/algRecieveUpdate")
     msg.append(chanInd)
     msg.append(self.hitListToString(newMel, 'fillerStuff', 'fillerStuff'))
     self.superColliderClient.send(msg)
예제 #14
0
def moveJoystick_handler(add, tags, stuff, source):
    print "message received:"
    msg = OSC.OSCMessage()
    msg.setAddress(addr)
    msg.append(stuff)
    c.send(msg)
    print "X Value is: "
    print stuff[0]
    print "Y Value is: "
    print stuff[1]  #stuff is a 'list' variable
예제 #15
0
    def stop_note(self, i, l, s, t):
        route = "/raspi%d/sinte" % self.rPi_id
        msg = OSC.OSCMessage()
        msg.setAddress(route)
        msg.append(s)
        cOsc.send(msg)

        route = "/raspi%d/nota" % self.rPi_id
        msg = OSC.OSCMessage()
        msg.setAddress(route)
        msg.append(i)
        msg.append(t)
        cOsc.send(msg)

        route = "/raspi%d/canal" % self.rPi_id
        msg = OSC.OSCMessage()
        msg.setAddress(route)
        msg.append(l)
        cOsc.send(msg)
예제 #16
0
def forwardPowerOff(client, adress, port):

    msg = OSC.OSCMessage()
    msg.setAddress("/fit/poweroff")
    msg.append(0)
    try:
        client.sendto(msg, (adress, port))
        msg.clearData()
    except:
        print(" error on sending : quit ")
예제 #17
0
 def outputRandom(self, *args):
     print("args = {} ".format(args))
     type_received_elements = args[1]
     received_elements = args[2]
     for i in range(0, len(received_elements)):
         print("Element {}: type = {}, value = {}".format(
             i, type_received_elements[i], received_elements[i]))
     message = OSC.OSCMessage("/random")
     message.append(random.random())
     self.client.sendto(message, ("127.0.0.1", self.outPort))
예제 #18
0
def sensor_3(add, tags, stuff, source):
    global sw3
    if int(stuff[0]) > swsens:
        if sw3 == 0:
            sw3 = 1
            print "SWITCH 3 ON"
            oscmsg = OSC.OSCMessage()
            oscmsg.setAddress("/switch/3")
            oscmsg.append(1)
            # messages to be sent to processing to trigger stress testing procedures
            processingclient.send(oscmsg)
    else:
        if sw3 == 1:
            sw3 = 0
            print "SWITCH 3 OFF"
            oscmsg = OSC.OSCMessage()
            oscmsg.setAddress("/switch/3")
            oscmsg.append(0)
            processingclient.send(oscmsg)
예제 #19
0
def sensor_2(add, tags, stuff, source):
    global sw2
    # a bit of threshold logic to prevent messages being sent repeatedly
    if int(stuff[0]) > 2000:
        if sw2 == 0:
            sw2 = 1
            print "SWITCH 2 ON"
            oscmsg = OSC.OSCMessage()
            oscmsg.setAddress("/switch/2")
            oscmsg.append(1)
            scclient.send(oscmsg)
    else:
        if sw2 == 1:
            sw2 = 0
            print "SWITCH 2 OFF"
            oscmsg = OSC.OSCMessage()
            oscmsg.setAddress("/switch/2")
            oscmsg.append(0)
            scclient.send(oscmsg)
	def sendNote(self, channel, note, vel, onOff):
		if self.broadcasting:
			return
		msg = OSC.OSCMessage()
		msg.setAddress("/spatializePlay")
		msg.append(channel)
		msg.append(note)
		msg.append(vel)
		msg.append(onOff)
		self.scClient.send(msg)
	def broadcastNote(self, channel, note, vel, onOff):
		if not self.broadcasting:
			return
		msg = OSC.OSCMessage()
		msg.setAddress("/broadcastNoteSelector-"+str(self.chanInd))
		msg.append(channel)
		msg.append(note)
		msg.append(vel)
		msg.append(onOff)
		self.broadcastClient.send(msg)
예제 #22
0
def sensor_1(add,tags,stuff,source):
	global sw1
	# a bit of threshold logic to prevent messages being sent repeatedly
	if int(stuff[0]) == swsens:
		if sw1 == 0:
			sw1 = 1
			cprint("SWITCH 1 ON",'green',attrs=['bold','underline'])
			oscmsg = OSC.OSCMessage()
			oscmsg.setAddress("/switch/1")
			oscmsg.append(1)
			scclient.send(oscmsg)
	else:
		if sw1 == 1:
			sw1 = 0
			cprint("SWITCH 1 OFF",'red',attrs=['bold','underline'])
			oscmsg = OSC.OSCMessage()
			oscmsg.setAddress("/switch/1")
			oscmsg.append(0)
			scclient.send(oscmsg)
예제 #23
0
def createBinaryMsg(oscAddress, dataArray):
    """create and return general type binary OSC msg
    """
    m = OSC.OSCMessage()
    m.address = oscAddress

    for x in dataArray:  ## append each item of the array to the message
        m.append(x)

    return m.getBinary() # get the actual OSC to send
예제 #24
0
    def update(self):
        vp = self.transform.getPos()
        vr = self.transform.getHpr()
        msg = OSC.OSCMessage()
        msg.setAddress(self.oscName)
        msg.append("%f %f %f %f %f %f" %
                   (vp.getX() * .9, vp.getY() * .9, vp.getZ() * .9, vr.getX(),
                    vr.getY(), vr.getZ()))

        self.oscClient.send(msg)
예제 #25
0
 def padFollowerHandler(self, addr, tags, stuff, source):
     if stuff[0] in self.delays:
         for padDelay in self.delays[stuff[0]]:
             msg = OSC.OSCMessage()
             msg.setAddress("/xyFollowing")
             msg.append(padDelay[0])
             msg.append(stuff[1])
             msg.append(stuff[2])
             msg.append(padDelay[1])
             self.superColliderClient.send(msg)
예제 #26
0
	def _update(self, *args):
		renderList = self.pydalPattern.render()
		renderStr = ";".join(str(t[0]) + "-" + ",".join(t[1]) for t in renderList)
		msg = OSC.OSCMessage()
		msg.setAddress("/arpeggiatorSendUpdate")
		msg.append(self.num)
		msg.append(renderStr)
		msg.append(self.midiChannel)
		msg.append(self.pydalPattern.frac)
		self.superColliderClient.send(msg)
예제 #27
0
def OSCsend(adr, ch, val):
    client = OSC.OSCClient()
    OSCaddress = (ip_adr, port)

    msg = OSC.OSCMessage()

    msg.setAddress(adr)
    msg.append(ch)
    msg.append(val)
    client.sendto(msg, OSCaddress)
예제 #28
0
def ws_bulk(message):
    if message['data']:
        for row in message['data']:
            msg = OSC.OSCMessage("/repovizz")
            msg += row
            try:
                send(msg)
                sleep(0.001)
            except OSC.OSCClientError:
                pass
예제 #29
0
def predict_all_buffers(addr, tags, data, client_address):
    """
    Record sound from sound card into a buffer and calls conv_NN for classification
    """
    global graph
    global rec_buffer_1
    global rec_buffer_2
    global rec_buffer_3
    global rec_buffer_4

    with graph.as_default():  #use the graph of the other thread. Otherwite it doesn't run
        verdict1 = conv.predict_vector_regression(rec_buffer_1)
    with graph.as_default():  #use the graph of the other thread. Otherwite it doesn't run
        verdict2 = conv.predict_vector_regression(rec_buffer_2)
    with graph.as_default():  #use the graph of the other thread. Otherwite it doesn't run
        verdict3 = conv.predict_vector_regression(rec_buffer_3)
    with graph.as_default():  #use the graph of the other thread. Otherwite it doesn't run
        verdict4 = conv.predict_vector_regression(rec_buffer_4)

    verdict_msg1 = OSC.OSCMessage(1)
    verdict_msg1.setAddress("/verdict/voice_1")
    verdict_msg1.append(verdict1)
    client.send(verdict_msg1)
    verdict_msg2 = OSC.OSCMessage(1)
    verdict_msg2.setAddress("/verdict/voice_2")
    verdict_msg2.append(verdict2)
    client.send(verdict_msg2)
    verdict_msg3 = OSC.OSCMessage(1)
    verdict_msg3.setAddress("/verdict/voice_3")
    verdict_msg3.append(verdict3)
    client.send(verdict_msg3)
    verdict_msg4 = OSC.OSCMessage(1)
    verdict_msg4.setAddress("/verdict/voice_4")
    verdict_msg4.append(verdict4)
    client.send(verdict_msg4)

    int_verdict1 = np.argmax(verdict1)
    int_verdict2 = np.argmax(verdict2)
    int_verdict3 = np.argmax(verdict3)
    int_verdict4 = np.argmax(verdict4)

    multibar(int_verdict1, int_verdict2, int_verdict3, int_verdict4)
예제 #30
0
def recieveMessage(addr, tags, stuff, source):
    inputLength = int(stuff[0])
    print "Received message:", inputLength
    text = str(markovGenerator.make_short_sentence(inputLength))
    print "sending message: " + text

    messageToSend = OSC.OSCMessage()
    messageToSend.setAddress(adressText)
    messageToSend.append(text)
    oscSender.send(messageToSend)
    return