예제 #1
0
    def buttonNetworkClicked(self):
        def handlerfunction(x):
            print("get cmd: " + x)

        sender = self.sender()
        self.statusBar().showMessage(sender.text() + ' pressed')

        #
        # send out START command as a bundle
        msg1 = oscbuildparse.OSCMessage("/pc1/cmd/control/ruthere", None,
                                        ["1111"])
        msg2 = oscbuildparse.OSCMessage("/pc2/cmd/control/ruthere", None,
                                        ["1111"])
        msg3 = oscbuildparse.OSCMessage("/pc3/cmd/control/ruthere", None,
                                        ["1111"])
        msg4 = oscbuildparse.OSCMessage("/pc4/cmd/control/ruthere", None,
                                        ["1111"])

        bun = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY,
                                      [msg1, msg2, msg3, msg4])

        osc_send(bun, "oscclient")

        # receive echo back
        osc_process()

        osc_method("/pc1/cmd/control/ruthere", handlerfunction)

        osc_process()
예제 #2
0
    def buttonStartClicked(self):
        sender = self.sender()
        self.statusBar().showMessage(sender.text() + ' pressed')

        if self.isReady == False:
            pe = QtGui.QPalette()
            pe.setColor(QtGui.QPalette.WindowText,
                        QtGui.QColor(255, 0, 0, 200))
            self.ui.labelStatus.setAutoFillBackground(True)
            pe.setColor(QtGui.QPalette.Window, QtGui.QColor(0, 0, 255, 180))
            # pe.setColor(QPalette.Background,Qt.blue)
            self.ui.labelStatus.setPalette(pe)
            self.ui.labelStatus.setFont(QtGui.QFont("", 22, QtGui.QFont.Bold))
            self.ui.labelStatus.setText(" Hit READY before start !!! ")
            return

        # send out START command as a bundle
        msg1 = oscbuildparse.OSCMessage("/pc1/cmd/control/showison", None,
                                        [1111])
        msg2 = oscbuildparse.OSCMessage("/pc2/cmd/control/showison", None,
                                        [1111])
        msg3 = oscbuildparse.OSCMessage("/pc3/cmd/control/showison", None,
                                        [1111])
        msg4 = oscbuildparse.OSCMessage("/pc4/cmd/control/showison", None,
                                        [1111])
        msg5 = oscbuildparse.OSCMessage("/pc5/cmd/control/showison", None,
                                        [1111])
        msg6 = oscbuildparse.OSCMessage("/pc6/cmd/control/showison", None,
                                        [1111])

        bun = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY,
                                      [msg1, msg2, msg3, msg4, msg5, msg6])

        osc_send(bun, "oscclient")

        # Send osc to start
        # msg = oscbuildparse.OSCMessage("/pc1/cmd/control/showison", None, ["1111"])
        # osc_send(msg, "oscclient")
        osc_process()

        pe = QtGui.QPalette()
        pe.setColor(QtGui.QPalette.WindowText, QtGui.QColor(255, 0, 0, 200))
        self.ui.labelStatus.setAutoFillBackground(True)
        pe.setColor(QtGui.QPalette.Window, QtGui.QColor(0, 0, 255, 180))
        # pe.setColor(QPalette.Background,Qt.blue)
        self.ui.labelStatus.setPalette(pe)
        self.ui.labelStatus.setFont(QtGui.QFont("", 22, QtGui.QFont.Bold))

        self.ui.labelStatus.setText(" The show is PLAYING !!! ")
        self.ui.btnStart.setText("Send PLAY signal again ...")
        self.send_play_count = self.send_play_count + 1
        self.statusBar().showMessage("Play signals sending " +
                                     str(self.send_play_count) + " times")

        # jus in case
        osc_send(bun, "oscclient")
        osc_process()
예제 #3
0
    def pause_multi(self, loops=[]):
        """
        Pause a number of loops simultaneously.
        """
        msgs = []
        for loop in loops:
            msgs.append(
                oscbuildparse.OSCMessage("/sl/{}/hit".format(loop.index), ",s",
                                         ["pause"]))
            if settings.DEBUG:
                print(">> {} {} {}".format("/sl/{}/hit".format(loop.index),
                                           ",s", ["pause"]))

        bundle = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY, msgs)
        osc_send(bundle, "SooperLooper")
        osc_process()
예제 #4
0
    def buttonStopClicked(self):

        if self.isReady == True:
            self.isReady = False
            self.ui.btnStop.setEnabled(False)
        else:
            self.isReady = True
            self.ui.btnStop.setEnabled(True)

            # send out READY command as a bundle
            msg1 = oscbuildparse.OSCMessage("/pc1/cmd/control/showison", None,
                                            [6666])
            msg2 = oscbuildparse.OSCMessage("/pc2/cmd/control/showison", None,
                                            [6666])
            msg3 = oscbuildparse.OSCMessage("/pc3/cmd/control/showison", None,
                                            [6666])
            msg4 = oscbuildparse.OSCMessage("/pc4/cmd/control/showison", None,
                                            [6666])
            msg5 = oscbuildparse.OSCMessage("/pc5/cmd/control/showison", None,
                                            [6666])
            msg6 = oscbuildparse.OSCMessage("/pc6/cmd/control/showison", None,
                                            [6666])

            bun = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY,
                                          [msg1, msg2, msg3, msg4, msg5, msg6])

            osc_send(bun, "oscclient")
            osc_process()

            pe = QtGui.QPalette()
            pe.setColor(QtGui.QPalette.WindowText, QtGui.QColor(0, 0, 0, 200))
            self.ui.labelStatus.setAutoFillBackground(True)
            pe.setColor(QtGui.QPalette.Window, QtGui.QColor(0, 0, 255, 180))
            # pe.setColor(QPalette.Background,Qt.blue)
            self.ui.labelStatus.setPalette(pe)
            self.ui.labelStatus.setFont(QtGui.QFont("", 22, QtGui.QFont.Bold))

            self.ui.labelStatus.setText(" The show is READY !!! ")
            self.ui.btnStart.setText("ALL START")
            self.send_play_count = 0
            self.statusBar().showMessage("Play signals sending " +
                                         str(self.send_play_count) + " times")

            self.isReady = True
            self.ui.btnStop.setEnabled(False)
예제 #5
0
    def set_properties(self, properties={}, loop=-3):
        """
        Take dict of properties and set on the loop.
        e.g.
        properties = dict(sync=1, playback_sync=1, quantize=3)
        """
        messages = []
        for command, value in properties.items():
            msg = oscbuildparse.OSCMessage("/sl/{}/set".format(loop), ",sf",
                                           [command, value])
            messages.append(msg)
            if settings.DEBUG:
                print(">> {} {} {}".format("/sl/{}/set".format(loop), ",sf",
                                           [command, value]))

        if messages:
            bundle = \
                oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY, messages)
            osc_send(bundle, "SooperLooper")
            osc_process()
예제 #6
0
    def unpause_multi(self, loops=[]):
        """
        Unpause a number of loops, assuming synced to loop 0.

        We therefore hit trigger on all bar loop 0 and then unpause 0 (unless
        has already been unpaused).
        """
        master = None
        msgs = []
        for loop in loops:
            if loop.index == 0:
                master = loop
                continue
            msgs.append(
                oscbuildparse.OSCMessage("/sl/{}/hit".format(loop.index), ",s",
                                         ["trigger"]))
        bundle = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY, msgs)
        osc_send(bundle, "SooperLooper")
        osc_process()

        if master.state == Loop.PAUSED:
            self.pause(master.index)
예제 #7
0
파일: ok.py 프로젝트: vwls/ctc-1000-ws2018
# Make client channels to send packets.
osc_udp_client("192.168.0.4", 2781, "aclientname")

# Build a simple message and send it.
msg = oscbuildparse.OSCMessage("/test/me", ",sif", ["text", 672, 8.871])
osc_send(msg, "aclientname")

# Build a message with autodetection of data types, and send it.
msg = oscbuildparse.OSCMessage("/test/me", None, ["text", 672, 8.871])
osc_send(msg, "aclientname")

# Buils a complete bundle, and postpone its executions by 10 sec.
exectime = time.time() + 10  # execute in 10 seconds
msg1 = oscbuildparse.OSCMessage("/sound/levels", None, [1, 5, 3])
msg2 = oscbuildparse.OSCMessage("/sound/bits", None, [32])
msg3 = oscbuildparse.OSCMessage("/sound/freq", None, [42000])
bun = oscbuildparse.OSCBundle(oscbuildparse.unixtime2timetag(exectime),
                              [msg1, msg2, msg3])
osc_send(bun, "aclientname")

# Periodically call osc4py3 processing method in your event loop.
finished = False
while not finished:
    # You can send OSC messages from your event loop too…
    # …
    osc_process()
    # …

# Properly close the system.
osc_terminate()
예제 #8
0
# NGIMU settings
osc_broadcast_client(
    "255.255.255.255", 9000,
    "to_NGIMUs")  # Make broadcast client send bundle with settings.
#setIP = oscbuildparse.OSCMessage("/wifi/send/ip", ",s", ["192.168.1.3"])
EulerRate = oscbuildparse.OSCMessage("/rate/euler", ",f", [0.0])
QuatRate = oscbuildparse.OSCMessage("/rate/quaternion", ",f", [0.0])
LinRate = oscbuildparse.OSCMessage("/rate/linear", ",f", [0.0])
EarthRate = oscbuildparse.OSCMessage("/rate/earth", ",f", [0.0])
SensRate = oscbuildparse.OSCMessage("/rate/sensors", ",f", [0.0])
AltRate = oscbuildparse.OSCMessage("/rate/altitude", ",f", [10.0])
BattRate = oscbuildparse.OSCMessage("/rate/battery", ",f", [0.0])
RssiRate = oscbuildparse.OSCMessage("/rate/rssi", ",f", [0.0])

RateBundle = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY, [
    EulerRate, QuatRate, LinRate, EarthRate, SensRate, AltRate, BattRate,
    RssiRate
])
osc_send(RateBundle, "to_NGIMUs")

# Make server channels to receive from NGIMUs
osc_udp_server("192.168.1.3", 8034, NGIMUs[0])
osc_udp_server("192.168.1.3", 8035, NGIMUs[1])
osc_udp_server("192.168.1.3", 8036, NGIMUs[2])
osc_udp_server("192.168.1.3", 8037, NGIMUs[3])
osc_udp_server("192.168.1.3", 8038, NGIMUs[4])
osc_udp_server("192.168.1.3", 8039, NGIMUs[5])

# Associate Python functions with message address patterns, using default
osc_method("/euler",
           euler,
           argscheme=osm.OSCARG_DATA + osm.OSCARG_READERNAME +
예제 #9
0
        print(r"  /!\ Bug: no arg")
    for a in args:
        print("  ",str(a))

# The dispatcher.
disp = Dispatcher("global",{'logger': logger})

# Message filters creation and registration.
filter0 = MethodFilter("/*", matchfct, argscheme=OSCARG_ADDRESS + OSCARG_DATAUNPACK + OSCARG_METHODFILTER)
disp.add_method(filter0)
filter1 = MethodFilter("/just", matchfct, argscheme=OSCARG_DATAUNPACK + OSCARG_METHODFILTER)
disp.add_method(filter1)
filter2 = MethodFilter("//test", matchfct, argscheme=OSCARG_DATAUNPACK + OSCARG_METHODFILTER)
disp.add_method(filter2)
filter3 = MethodFilter("/just/[a-c]/test", matchfct, argscheme=OSCARG_DATAUNPACK + OSCARG_METHODFILTER)
disp.add_method(filter3)
filter4 = MethodFilter("/*/c/", matchfct, argscheme=OSCARG_DATAUNPACK + OSCARG_METHODFILTER)
disp.add_method(filter4)

# Test messages dispatching.
msg = obp.OSCMessage("/just/a/test", None, [1, 2, 3])
print("Dispatching a message:", msg)
disp.dispatch_packet(msg, PacketOptions())

bun = obp.OSCBundle(obp.OSC_IMMEDIATELY, [
        obp.OSCMessage("/just/c/test", None, ["Hello"]),
        obp.OSCMessage("/just/d/test/here", None, [ 3.13, "is", "pi"]),
        ])
print("Dispatching a bundle:", bun)
disp.dispatch_packet(bun, PacketOptions())
예제 #10
0
 while True:
     #flick test
     if flicktxt:
         os.system('clear')
         print(flicktxt)
         if flicktxt == "south - north" and flickupcount < 3:
             flickupcount += 1
         elif flickupcount == 3:
             if sendlvl < 1.0:
                 sendlvl += 0.1
             #increase sendlvl by 10% and send to Ableton
             msg0 = oscbuildparse.OSCMessage("/live/send", ",iif",
                                             [track, 0, sendlvl])
             msg1 = oscbuildparse.OSCMessage("/live/send", ",iif",
                                             [track, 1, sendlvl])
             bun = oscbuildparse.OSCBundle(
                 oscbuildparse.unixtime2timetag(time.time()), [msg0, msg1])
             print("Increasing track ", track, " to ", sendlvl)
             osc_send(bun, "aLive")
             osc_process()
             flicktxt = ''
             flickupcount = 0
         if flicktxt == "north - south" and flickdowncount < 3:
             flickdowncount += 1
         elif flickdowncount == 3:
             if sendlvl > 0.0:
                 sendlvl -= 0.1
             #decrease sendlvl by 10% and send to Ableton on both sends
             msg0 = oscbuildparse.OSCMessage("/live/send", ",iif",
                                             [track, 0, sendlvl])
             msg1 = oscbuildparse.OSCMessage("/live/send", ",iif",
                                             [track, 1, sendlvl])