'Repeated notes before sustain can overlap and should not be modified.
Once a repeat happens within the sustain, any active notes should end
before the next one starts.
This is kind of an edge case because a note overlapping a note of the same
pitch may not make sense, but apply_sustain_control_changes tries not to
modify events that happen outside of a sustain.'

def testApplySustainControlChangesWithRepeatedNotesBeforeSustain(self):

    sequence = copy.copy(self.note_sequence)
    testing_lib.add_control_changes_to_sequence(sequence, 0, [(1.0, 64, 127), (4.0, 64, 0)])
    expected_sequence = copy.copy(sequence)
    testing_lib.add_track_to_sequence(sequence, 0, [(60, 100, 0.25, 1.5), (60, 100, 0.5, 1.5), (60, 100, 1.25, 2.0)])
    testing_lib.add_track_to_sequence(expected_sequence, 0, [(60, 100, 0.25, 1.25), (60, 100, 0.5, 1.25), (60, 100, 1.25, 4.0)])
    sus_sequence = sequences_lib.apply_sustain_control_changes(sequence)
    self.assertProtoEquals(expected_sequence, sus_sequence)
