def testInferChordsForSequenceWithBeats(self): sequence = music_pb2.NoteSequence() testing_lib.add_track_to_sequence( sequence, 0, [ (60, 100, 0.0, 1.1), (64, 100, 0.0, 1.1), (67, 100, 0.0, 1.1), # C (62, 100, 1.1, 1.9), (65, 100, 1.1, 1.9), (69, 100, 1.1, 1.9), # Dm (60, 100, 1.9, 3.0), (65, 100, 1.9, 3.0), (69, 100, 1.9, 3.0), # F (59, 100, 3.0, 4.5), (62, 100, 3.0, 4.5), (67, 100, 3.0, 4.5) ]) # G testing_lib.add_beats_to_sequence(sequence, [0.0, 1.1, 1.9, 1.9, 3.0]) chord_inference.infer_chords_for_sequence(sequence) expected_chords = [('C', 0.0), ('Dm', 1.1), ('F', 1.9), ('G', 3.0)] chords = [(ta.text, ta.time) for ta in sequence.text_annotations if ta.annotation_type == CHORD_SYMBOL] self.assertEqual(expected_chords, chords)
def testInferChordsForSequenceWithBeats(self): sequence = music_pb2.NoteSequence() testing_lib.add_track_to_sequence( sequence, 0, [(60, 100, 0.0, 1.1), (64, 100, 0.0, 1.1), (67, 100, 0.0, 1.1), # C (62, 100, 1.1, 1.9), (65, 100, 1.1, 1.9), (69, 100, 1.1, 1.9), # Dm (60, 100, 1.9, 3.0), (65, 100, 1.9, 3.0), (69, 100, 1.9, 3.0), # F (59, 100, 3.0, 4.5), (62, 100, 3.0, 4.5), (67, 100, 3.0, 4.5)]) # G testing_lib.add_beats_to_sequence(sequence, [0.0, 1.1, 1.9, 1.9, 3.0]) chord_inference.infer_chords_for_sequence(sequence) expected_chords = [('C', 0.0), ('Dm', 1.1), ('F', 1.9), ('G', 3.0)] chords = [(ta.text, ta.time) for ta in sequence.text_annotations if ta.annotation_type == CHORD_SYMBOL] self.assertEqual(expected_chords, chords)