t = -1
for l in list(open("widor.events"))[:]:
  l = dict([(nm, int(val)) for (nm, _, val) in [p.partition('=') for p in l.rstrip().split()]])
  print "/* %s */" % repr(l)
  if l['t'] != t:
    d = (l['t'] - t)
    print "PAUSE(%d)," % min(255, d)
    channels = {}
    t = l['t']
  ch = int(l['channel'])
  v = channels.get(ch, [0,0,8][ch]) # voice for this note
  print "NOTE(%d, %d, %d)," % (v, l['pitch'], l['velocity'])
  channels[ch] = v + 1
  # print "  ", channels
