(self, msg)
Handles a single incoming MIDI message during capture.

    If the message is a note_on event, ends the previous note (if applicable)
    and opens a new note in the capture sequence. Ignores repeated note_on
    events.

    If the message is a note_off event matching the current open note in the
    capture sequence

    Args:
      msg: The mido.Message MIDI message to handle.
Handles a single incoming MIDI message during capture.
Handles a single incoming MIDI message during capture .
def _capture_message(self, msg):
    """Handles a single incoming MIDI message during capture.

    If the message is a note_on event, ends the previous note (if applicable)
    and opens a new note in the capture sequence. Ignores repeated note_on
    events.

    If the message is a note_off event matching the current open note in the
    capture sequence

    Args:
      msg: The mido.Message MIDI message to handle.
    """
    if msg.type == 'note_off' or (msg.type == 'note_on' and msg.velocity == 0):
      if self._open_note is None or msg.note != self._open_note.pitch:
        # This is not the note we're looking for. Drop it.
        return

      self._open_note.end_time = msg.time
      self._open_note = None

    elif msg.type == 'note_on':
      if self._open_note:
        if self._open_note.pitch == msg.note:
          # This is just a repeat of the previous message.
          return
        # End the previous note.
        self._open_note.end_time = msg.time

      self._open_note = self._add_note(msg)
def _capture_message ( self , msg ) : if msg . type == 'note_off' or ( msg . type == 'note_on' and msg . velocity == 0 ) : if self . _open_note is None or msg . note != self . _open_note . pitch : # This is not the note we're looking for. Drop it. return self . _open_note . end_time = msg . time self . _open_note = None elif msg . type == 'note_on' : if self . _open_note : if self . _open_note . pitch == msg . note : # This is just a repeat of the previous message. return # End the previous note. self . _open_note . end_time = msg . time self . _open_note = self . _add_note ( msg )