title: Sending and receiving MIDI sync data
body: <p>I want to send MMC to Cubase to tell it to start, stop and rewind, and Cubase sends timecode to my program to keep in sync. Sometimes this script works flawlessly, other times it gets blocked up somehow and stops responding, while MIDIOX shows me that Cubase continues to send MIDI timecode - not 100 per second, but 1 every 3 seconds! Could Cubase have a higher priority and so my script is not allowed to process the input, then it gets blocked? Except it doesn't help for me to flush the messages. Any ideas?</p>
  
  <pre><code>import time
  import rtmidi as md
  mtcin = md.MidiIn()
  mout = md.MidiOut()
  mtcin.ignore_types(sysex=False, timing=False)
  mtcin.open_port(0)
  mout.open_port(3)
  event_list = [(0,123),(0.13,234,45),(1.5,345,56),(3,14)]
  ind = 0
  timecode = -1
  mout.send_message((0xf0, 0x7f, 127, 6, 2, 0xf7))
  while ind &lt; len(event_list):
      msg = mtcin.get_message()
      if msg:
          timecode += 1
      if event_list[ind][0] &lt;= timecode/100.0:
          print event_list[ind][1:]
          ind += 1
      time.sleep(0.001)
  mout.send_message((0xf0, 0x7f, 127, 6, 1, 0xf7))
  mout.send_message((0xf0, 0x7f, 127, 6, 0x44, 6, 1, 32, 0, 0, 0, 0, 0xf7))
  </code></pre>