How to Write a Melody