utils/pianoroll-format.py
author ymh <ymh.work@gmail.com>
Thu, 23 Oct 2014 17:51:55 +0200
changeset 57 cb4df234fd79
parent 0 e1d4d7a8255a
permissions -rw-r--r--
when querying event, replace one by first to avoid raising an exception when the event is not found


import sys
import csv
import datetime
import time
import ntplib
from txosc import osc

if __name__ == '__main__':
    t0 = time.time()
    with open(sys.argv[1], 'rU') as datafile:
        reader = csv.reader(datafile, delimiter=' ')
        for row in reader:
            t1 = t0 + float(row[1])/10**3
            timetag = ntplib.system_to_ntp_time(t1)
            print " ".join([str(s) for s in [timetag, int(row[1]), 0] + [int(s) for s in row[2:4]]])