'Returns indexes of the most recent pitch and NOTE_OFF events.
Returns:
A tuple (start_step, end_step) of the last note\'s on and off event
indices.
Raises:
ValueError: If `events` contains no NOTE_OFF or pitch events.'

def _get_last_on_off_events(self):

    last_off = len(self)
    for i in range((len(self) - 1), (-1), (-1)):
        if (self._events[i] == MELODY_NOTE_OFF):
            last_off = i
        if (self._events[i] >= MIN_MIDI_PITCH):
            return (i, last_off)
    raise ValueError('No    events    in    the    stream')
