Generating structured music using quality metrics based on Markov models