def testInferChordsForSequence(self): # Test non-quantized sequence. sequence = copy.copy(self.note_sequence) testing_lib.add_track_to_sequence( sequence, 0, [(60, 100, 1.0, 3.0), (64, 100, 1.0, 2.0), (67, 100, 1.0, 2.0), (65, 100, 2.0, 3.0), (69, 100, 2.0, 3.0), (62, 100, 3.0, 5.0), (65, 100, 3.0, 4.0), (69, 100, 3.0, 4.0)]) expected_sequence = copy.copy(sequence) testing_lib.add_chords_to_sequence( expected_sequence, [('C', 1.0), ('F/C', 2.0), ('Dm', 3.0)]) sequences_lib.infer_chords_for_sequence(sequence) self.assertProtoEquals(expected_sequence, sequence) # Test quantized sequence. sequence = copy.copy(self.note_sequence) sequence.quantization_info.steps_per_quarter = 1 testing_lib.add_track_to_sequence( sequence, 0, [(60, 100, 1.1, 3.0), (64, 100, 1.0, 1.9), (67, 100, 1.0, 2.0), (65, 100, 2.0, 3.2), (69, 100, 2.1, 3.1), (62, 100, 2.9, 4.8), (65, 100, 3.0, 4.0), (69, 100, 3.0, 4.1)]) testing_lib.add_quantized_steps_to_sequence( sequence, [(1, 3), (1, 2), (1, 2), (2, 3), (2, 3), (3, 5), (3, 4), (3, 4)]) expected_sequence = copy.copy(sequence) testing_lib.add_chords_to_sequence( expected_sequence, [('C', 1.0), ('F/C', 2.0), ('Dm', 3.0)]) testing_lib.add_quantized_chord_steps_to_sequence( expected_sequence, [1, 2, 3]) sequences_lib.infer_chords_for_sequence(sequence) self.assertProtoEquals(expected_sequence, sequence)
def testQuantizeNoteSequenceAbsolute(self): testing_lib.add_track_to_sequence( self.note_sequence, 0, [(12, 100, 0.01, 10.0), (11, 55, 0.22, 0.50), (40, 45, 2.50, 3.50), (55, 120, 4.0, 4.01), (52, 99, 4.75, 5.0)]) testing_lib.add_chords_to_sequence( self.note_sequence, [('B7', 0.22), ('Em9', 4.0)]) testing_lib.add_control_changes_to_sequence( self.note_sequence, 0, [(2.0, 64, 127), (4.0, 64, 0)]) expected_quantized_sequence = copy.deepcopy(self.note_sequence) expected_quantized_sequence.quantization_info.steps_per_second = 4 testing_lib.add_quantized_steps_to_sequence( expected_quantized_sequence, [(0, 40), (1, 2), (10, 14), (16, 17), (19, 20)]) testing_lib.add_quantized_chord_steps_to_sequence( expected_quantized_sequence, [1, 16]) testing_lib.add_quantized_control_steps_to_sequence( expected_quantized_sequence, [8, 16]) quantized_sequence = sequences_lib.quantize_note_sequence_absolute( self.note_sequence, steps_per_second=4) self.assertProtoEquals(expected_quantized_sequence, quantized_sequence)
def testInferChordsForSequence(self): # Test non-quantized sequence. sequence = copy.copy(self.note_sequence) testing_lib.add_track_to_sequence( sequence, 0, [(60, 100, 1.0, 3.0), (64, 100, 1.0, 2.0), (67, 100, 1.0, 2.0), (65, 100, 2.0, 3.0), (69, 100, 2.0, 3.0), (62, 100, 3.0, 5.0), (65, 100, 3.0, 4.0), (69, 100, 3.0, 4.0)]) expected_sequence = copy.copy(sequence) testing_lib.add_chords_to_sequence( expected_sequence, [('C', 1.0), ('F/C', 2.0), ('Dm', 3.0)]) sequences_lib.infer_chords_for_sequence(sequence) self.assertProtoEquals(expected_sequence, sequence) # Test quantized sequence. sequence = copy.copy(self.note_sequence) sequence.quantization_info.steps_per_quarter = 1 testing_lib.add_track_to_sequence( sequence, 0, [(60, 100, 1.1, 3.0), (64, 100, 1.0, 1.9), (67, 100, 1.0, 2.0), (65, 100, 2.0, 3.2), (69, 100, 2.1, 3.1), (62, 100, 2.9, 4.8), (65, 100, 3.0, 4.0), (69, 100, 3.0, 4.1)]) testing_lib.add_quantized_steps_to_sequence( sequence, [(1, 3), (1, 2), (1, 2), (2, 3), (2, 3), (3, 5), (3, 4), (3, 4)]) expected_sequence = copy.copy(sequence) testing_lib.add_chords_to_sequence( expected_sequence, [('C', 1.0), ('F/C', 2.0), ('Dm', 3.0)]) testing_lib.add_quantized_chord_steps_to_sequence( expected_sequence, [1, 2, 3]) sequences_lib.infer_chords_for_sequence(sequence) self.assertProtoEquals(expected_sequence, sequence)
def testQuantizeNoteSequence(self): testing_lib.add_track_to_sequence( self.note_sequence, 0, [ (12, 100, 0.01, 10.0), (11, 55, 0.22, 0.50), (40, 45, 2.50, 3.50), (55, 120, 4.0, 4.01), (52, 99, 4.75, 5.0), ], ) testing_lib.add_chords_to_sequence(self.note_sequence, [("B7", 0.22), ("Em9", 4.0)]) expected_quantized_sequence = copy.deepcopy(self.note_sequence) expected_quantized_sequence.quantization_info.steps_per_quarter = self.steps_per_quarter testing_lib.add_quantized_steps_to_sequence( expected_quantized_sequence, [(0, 40), (1, 2), (10, 14), (16, 17), (19, 20)] ) testing_lib.add_quantized_chord_steps_to_sequence(expected_quantized_sequence, [1, 16]) quantized_sequence = sequences_lib.quantize_note_sequence( self.note_sequence, steps_per_quarter=self.steps_per_quarter ) self.assertProtoEquals(expected_quantized_sequence, quantized_sequence)
def testQuantizeNoteSequenceAbsolute(self): testing_lib.add_track_to_sequence( self.note_sequence, 0, [(12, 100, 0.01, 10.0), (11, 55, 0.22, 0.50), (40, 45, 2.50, 3.50), (55, 120, 4.0, 4.01), (52, 99, 4.75, 5.0)]) testing_lib.add_chords_to_sequence( self.note_sequence, [('B7', 0.22), ('Em9', 4.0)]) testing_lib.add_control_changes_to_sequence( self.note_sequence, 0, [(2.0, 64, 127), (4.0, 64, 0)]) expected_quantized_sequence = copy.deepcopy(self.note_sequence) expected_quantized_sequence.quantization_info.steps_per_second = 4 testing_lib.add_quantized_steps_to_sequence( expected_quantized_sequence, [(0, 40), (1, 2), (10, 14), (16, 17), (19, 20)]) testing_lib.add_quantized_chord_steps_to_sequence( expected_quantized_sequence, [1, 16]) testing_lib.add_quantized_control_steps_to_sequence( expected_quantized_sequence, [8, 16]) quantized_sequence = sequences_lib.quantize_note_sequence_absolute( self.note_sequence, steps_per_second=4) self.assertProtoEquals(expected_quantized_sequence, quantized_sequence)