def testSequenceNotePitchVectors(self): sequence = music_pb2.NoteSequence() testing_lib.add_track_to_sequence(sequence, 0, [ (60, 100, 0.0, 0.0), (62, 100, 0.0, 0.5), (60, 100, 1.5, 2.5), (64, 100, 2.0, 2.5), (67, 100, 2.25, 2.75), (70, 100, 2.5, 4.5), (60, 100, 6.0, 6.0), ]) note_pitch_vectors = chord_inference.sequence_note_pitch_vectors( sequence, seconds_per_frame=1.0) expected_note_pitch_vectors = [ [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.5, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ] self.assertEqual(expected_note_pitch_vectors, note_pitch_vectors.tolist())
def testSequenceNotePitchVectorsVariableLengthFrames(self): sequence = music_pb2.NoteSequence() testing_lib.add_track_to_sequence( sequence, 0, [(60, 100, 0.0, 0.0), (62, 100, 0.0, 0.5), (60, 100, 1.5, 2.5), (64, 100, 2.0, 2.5), (67, 100, 2.25, 2.75), (70, 100, 2.5, 4.5), (60, 100, 6.0, 6.0), ]) note_pitch_vectors = chord_inference.sequence_note_pitch_vectors( sequence, seconds_per_frame=[1.5, 2.0, 3.0, 5.0]) expected_note_pitch_vectors = [ [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.5, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], ] self.assertEqual(expected_note_pitch_vectors, note_pitch_vectors.tolist())