I am working at a small program to generate random melodies. So far I have an array of notes with their frequencies, the program picks a random element from the array and plays its frequency. The problem is that the melody “sounds bad”: as if you sat in front of the piano and played random keys. I need an algorithm to generate a melody, with frequencies and timings and so on. I don’t need anything elaborate, just make a melody that sounds good.
Share
Use existing music (MIDI?) to train a Markov model or Markov chain
. You may want to transpose the input to the same key(s) e.g. C major, A minor. The pitch*duration will probably have to be encoded (enumerated) into a single dimension (x*7*5, or x*12*5) . [x := number of octaves in your input range, 5=duration, 1 downto 1/16th ]
Extra bonus for loops and variations, but that will be much harder…