Ejemplo n.º 1
0
 def testSendBundle(self):
     self.server.add_method('/foo', 'i', self.callback_dict)
     self.server.add_method('/bar', 's', self.callback_dict)
     self.server.send(1234, liblo.Bundle(
         liblo.Message('/foo', 123),
         liblo.Message('/bar', "blubb")
     ))
     self.assertTrue(self.server.recv(100))
     self.assertEqual(self.cb['/foo'].args[0], 123)
     self.assertEqual(self.cb['/bar'].args[0], "blubb")
Ejemplo n.º 2
0
 def testSendTimestamped(self):
     self.server.add_method('/blubb', 'i', self.callback)
     d = 1.23
     t1 = time.time()
     b = liblo.Bundle(liblo.time() + d)
     b.add('/blubb', 42)
     self.server.send(1234, b)
     while not self.cb:
         self.server.recv(1)
     t2 = time.time()
     self.assertAlmostEqual(t2 - t1, d, 1)
Ejemplo n.º 3
0
    def sync(self, client):
        logger.debug('system="%s", action="sync", client="%r"', self.system,
                     client)

        liblo.send(
            client,
            liblo.Bundle(

                # Gross, this needs refactoring...
                liblo.Message(
                    "/light/cloud_z", self.controller.params.lightning_new /
                    self.lightningProbabilityScale),
                liblo.Message(
                    "/light2/brightness",
                    self.controller.params.brightness / self.brightnessScale),
                liblo.Message(
                    "/light2/contrast",
                    self.controller.params.contrast / self.contrastScale),
                liblo.Message("/light2/detail", self.controller.params.detail /
                              self.detailScale),
                liblo.Message("/light2/color_top",
                              self.controller.params.color_top),
                liblo.Message("/light2/color_bottom",
                              self.controller.params.color_bottom),
                liblo.Message(
                    "/light2/turbulence",
                    self.controller.params.turbulence / self.turbulenceScale),
                liblo.Message(
                    "/light2/speed",
                    self.controller.params.wind_speed / self.windSpeedScale),

                # XXX: This doesn't work- TouchOSC seems to spam these events
                #      at both XY pads for some reason. Bug in TouchOSC? Using
                #      liblo incorrectly?
                #
                # liblo.Message("/light2/heading",
                #     -math.cos(self.controller.params.wind_heading),
                #     math.sin(self.controller.params.wind_heading)),
                #
                # liblo.Message("/light2/rotation",
                #     math.sin(-self.controller.params.rotation),
                #     -math.cos(-self.controller.params.rotation))
            ))
Ejemplo n.º 4
0
import liblo, sys

# send all messages to port 1234 on the local machine
try:
    target = liblo.Address("192.168.1.138", 3001)

except liblo.AddressError as err:
    print(err)
    sys.exit()

# send message "/foo/message1" with int, float and string arguments
liblo.send(target, "/foo/message1", 123, 456.789, "test")

# send double, int64 and char
liblo.send(target, "/foo/message2", ('d', 3.1415), ('h', 2**42), ('c', 'x'))

# we can also build a message object first...
msg = liblo.Message("/foo/blah")
# ... append arguments later...
msg.add(123, "foo")
# ... and then send it
liblo.send(target, msg)

# send a list of bytes as a blob
blob = [4, 8, 15, 16, 23, 42]
liblo.send(target, "/foo/blob", blob)

# wrap a message in a bundle, to be dispatched after 2 seconds
bundle = liblo.Bundle(liblo.time() + 2.0, liblo.Message("/blubb", 123))
liblo.send(target, bundle)
Ejemplo n.º 5
0
        elif opt in ("--help"):
            print_help()


# parse arguments on start
parse_args(sys.argv[1:])

# setup OSC
address = liblo.Address(host, port)

touched = []
for i in electrodes_range:
    touched.append(False)

while True:
    bundle = liblo.Bundle()

    if sensor.touch_status_changed():
        sensor.update_touch_data()

    sensor.update_baseline_data()
    sensor.update_filtered_data()

    # touch values
    for i in electrodes_range:
        is_touched = sensor.get_touch_data(i)
        if touched[i] == False and is_touched:
            touch = liblo.Message("/live/play")
            print "touched: " + str(i)
            bundle.add(touch)
            touched[i] = True
Ejemplo n.º 6
0
 def build_message(self):
     return liblo.Bundle(
         liblo.Message('/sl/0/load_loop', self.path, '', ''),
         #liblo.Message('/sl/0/register_update/', 'scratch_pos', '', ''),
         liblo.Message('/sl/0/hit', 'trigger'))
Ejemplo n.º 7
0
 def build_message(self):
     return liblo.Bundle(
         liblo.Message('/jadeo/load', self.path),
         liblo.Message('/jadeo/seel', 0),
         liblo.Message('/jadeo/cmd'))