Markov Chain Melody Generator

Example of a melody generated by the markov model.
Graph displaying results of generated melodies compared to original melody. The questionnaire was on a scale of 0 to 10 where 0 was “this melody was definitely computer generated” and 10 was “this melody was definitely written by a human.”

Project information

  • Dates: Spring 2021
  • Skillset: Java
Check out my paper!
Github repo

Having taken a music class and discrete maths/probability class, I wanted to combine what I had learned and implement a program that scans an inputted MIDI melody, generates a Markov model, and composes a melody based on the Markov model. Using Java and Midi, I was able to successfully create a program that would generate a melody based on an inputted melody.

I was able to write a paper about the results of the Markov Model, asking people to guess if a melody was written by the program depending on the order of the markov model (ie. 3rd order versus 5th order markov chain). While not always successful, I found that a a 5th order markov chain was able to generate a melody that was able to fool some participants into thinking that it was written by a person.