(self)
Plays messages in the queue until empty and _allow_updates is False.
Plays messages in the queue until empty and _allow_updates is False.
Plays messages in the queue until empty and _allow_updates is False .
def run(self):
    """Plays messages in the queue until empty and _allow_updates is False."""
    # Assumes model where NoteSequence is time-stamped with wall time.
    # TODO(hanzorama): Argument to allow initial start not at sequence start?

    while self._message_queue and self._message_queue[0].time < time.time():
      self._message_queue.popleft()

    while True:
      while self._message_queue:
        delta = self._message_queue[0].time - time.time()
        if delta > 0:
          self._update_cv.wait(timeout=delta)
        else:
          msg = self._message_queue.popleft()
          if msg.type == 'note_on':
            self._open_notes.add(msg.note)
          elif msg.type == 'note_off':
            self._open_notes.discard(msg.note)
          self._outport.send(msg)

      # Either keep player alive and wait for sequence update, or return.
      if self._allow_updates:
        self._update_cv.wait()
      else:
        break
def run ( self ) : # Assumes model where NoteSequence is time-stamped with wall time. # TODO(hanzorama): Argument to allow initial start not at sequence start? while self . _message_queue and self . _message_queue [ 0 ] . time < time . time ( ) : self . _message_queue . popleft ( ) while True : while self . _message_queue : delta = self . _message_queue [ 0 ] . time - time . time ( ) if delta > 0 : self . _update_cv . wait ( timeout = delta ) else : msg = self . _message_queue . popleft ( ) if msg . type == 'note_on' : self . _open_notes . add ( msg . note ) elif msg . type == 'note_off' : self . _open_notes . discard ( msg . note ) self . _outport . send ( msg ) # Either keep player alive and wait for sequence update, or return. if self . _allow_updates : self . _update_cv . wait ( ) else : break