def testEq(self): left_hand = sequences_lib.QuantizedSequence() left_hand.qpm = 123.0 left_hand.steps_per_quarter = 7 left_hand.time_signature = sequences_lib.TimeSignature(7, 8) testing_lib.add_quantized_track( left_hand, 0, [(12, 100, 0, 40), (11, 100, 1, 2)]) testing_lib.add_quantized_track( left_hand, 2, [(55, 100, 4, 6), (14, 120, 4, 10)]) testing_lib.add_quantized_track( left_hand, 3, [(1, 10, 0, 6), (2, 50, 20, 21), (0, 101, 17, 21)]) right_hand = sequences_lib.QuantizedSequence() right_hand.qpm = 123.0 right_hand.steps_per_quarter = 7 right_hand.time_signature = sequences_lib.TimeSignature(7, 8) testing_lib.add_quantized_track( right_hand, 0, [(11, 100, 1, 2), (12, 100, 0, 40)]) testing_lib.add_quantized_track( right_hand, 2, [(14, 120, 4, 10), (55, 100, 4, 6)]) testing_lib.add_quantized_track( right_hand, 3, [(0, 101, 17, 21), (2, 50, 20, 21), (1, 10, 0, 6)]) self.assertEqual(left_hand, right_hand)
def testFromNotesStepsPerBar(self): self.quantized_sequence.time_signature = sequences_lib.TimeSignature(7, 8) self.quantized_sequence.steps_per_quarter = 12 self.quantized_sequence.tracks[0] = [] melody = melodies_lib.MonophonicMelody() melody.from_quantized_sequence(self.quantized_sequence, start_step=0, track=0, ignore_polyphonic_notes=False) self.assertEqual(42, melody.steps_per_bar)
def testFromQuantizedSequenceNotCommonTimeSig(self): self.quantized_sequence.time_signature = sequences_lib.TimeSignature(7, 8) testing_lib.add_quantized_track( self.quantized_sequence, 0, [(12, 100, 0, 40), (11, 55, 1, 2), (40, 45, 10, 14), (55, 120, 16, 17), (52, 99, 19, 20)]) melody = melodies_lib.MonophonicMelody() melody.from_quantized_sequence(self.quantized_sequence, start_step=0, track=0) expected = ([12, 11, NOTE_OFF, NO_EVENT, NO_EVENT, NO_EVENT, NO_EVENT, NO_EVENT, NO_EVENT, NO_EVENT, 40, NO_EVENT, NO_EVENT, NO_EVENT, NOTE_OFF, NO_EVENT, 55, NOTE_OFF, NO_EVENT, 52]) self.assertEqual(expected, list(melody)) self.assertEqual(14, melody.steps_per_bar)