So, I've had a bit of a crazy idea about using Markov chains to create procedurally generated music.
I've started by using the
Python midi package to record all midi events in a .mid file as parts in a single list. I just now got this to successfully work 100%, and have tested it by porting it back out as a new .mid file (which is, of course, identical to the original - but the important part is that I got the recording and list-interpreting algorithms to work correctly).
I'm now going to use these lists to, hopefully, create Markov chains which will be used to create 'new' songs. In reality they'll just be cannibalized patterns from existing midi files, but there are a few very cool advantages about doing this.
1. It will hopefully sound more 'human-composed' than typical algorithmically generated music, since it will focus on cannibalizing 'real' music instead of creating truly computer-generated sounds.
2. It will allow users to alter the types of music they want to generate by simply replacing/augmenting the pool of midi files.
3. It will allow a near-infinite amount of variety. Aside from being able to replace the midis themselves, I'm also going to try to get the program to mix and match Markov chains from *different* songs. This might get a bit wonky when dealing with songs in different keys/tempos, so I'm going to have to give some thought as to how I want to approach the problem.
I'll make any updates to progress. If I can get this to work, I plan on throwing it into Cult with a variety of options like saving favorite randomly generated tracks and assigning them to locations/characters, etc.