'Transpose notes in this Melody.
All notes are transposed the specified amount. Additionally, all notes
are octave shifted to lie within the [min_note, max_note) range.
Args:
transpose_amount: The number of half steps to transpose this Melody.
Positive values transpose up. Negative values transpose down.
min_note: Minimum pitch (inclusive) that the resulting notes will take on.
max_note: Maximum pitch (exclusive) that the resulting notes will take on.'

def transpose(self, transpose_amount, min_note=0, max_note=128):

    for i in range(len(self)):
        if (self._events[i] >= MIN_MIDI_PITCH):
            self._events[i] += transpose_amount
            if (self._events[i] < min_note):
                self._events[i] = (min_note + ((self._events[i] - min_note) % NOTES_PER_OCTAVE))
            elif (self._events[i] >= max_note):
                self._events[i] = ((max_note - NOTES_PER_OCTAVE) + ((self._events[i] - max_note) % NOTES_PER_OCTAVE))
