def print_diff(): global t, error, bpm if t == 0: t = time() return if bpm != seq.bpm: bpm=seq.bpm error = 0 t = time() return nt = time() error += 60. / bpm - (nt - t) t = nt print("Cumulated error: %s%.3f ms (%5.2f" % (' ' if str(error)[0]!='-' else '',round(1000000 * error)/1000, abs(100 * error / (60. / bpm))) + "%) at " + str(bpm) + " bpm")
def print_diff(): global t, error, bpm if t == 0: t = time() return if bpm != seq.bpm: bpm = seq.bpm error = 0 t = time() return nt = time() error += 60. / bpm - (nt - t) t = nt print("Cumulated error: %s%.3f ms (%5.2f" % (' ' if str(error)[0] != '-' else '', round(1000000 * error) / 1000, abs(100 * error / (60. / bpm))) + "%) at " + str(bpm) + " bpm")
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)
def group(self, messages): """ Send a group of timestamped messages to OSC path Data format: message = [path, offset_in_seconds, id, value] """ now = liblo.time() elapsed = 0.0 offset = 0.0 for message in messages: elapsed += offset path = message[0] self.send(path, now + elapsed, *tuple(message[2:])) offset = float(message[1])
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)
import liblo, sys # send all messages to port 1234 on the local machine try: target = liblo.Address(1234) except liblo.AddressError, err: print str(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)
if(RECORD): cv.WriteFrame(writer, frame) if frame == None: print "END OF VIDEO" cv.WaitKey() break output = Preprocess(frame) contours = cv.FindContours (output, cv.CreateMemStorage(0) , cv.CV_RETR_CCOMP) cv.DrawContours(frame, contours, cv.ScalarAll(125), cv.ScalarAll(125), 100); contour=contours _id=0 bundle = liblo.Bundle(liblo.time(), liblo.Message('/Start')) Blobs = [] cv.CvtColor(frame,frame,cv.CV_BGR2HSV); try : contour[0] empty=False except : empty=True while (contour is not None) and (not empty): rect = cv.BoundingRect(contour) c = ColorBlob()
def time(): return time()
def test(self, seq, timer): print('Network + Code latency = %f ms' % ((time() - timer.clock) * 1000)) timer.wait(1, 'beat') seq.send(':/Sequencer/Scene/Play', 'test', ('t', time()))
def timestamp(ev): return ('t', time())