Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Procedural Music Generation  (Read 6477 times)

Lord Dullard

  • Bay Watcher
  • Indubitably.
    • View Profile
    • Cult: Awakening of the Old Ones
Procedural Music Generation
« on: May 09, 2011, 08:47:07 pm »

I think there may have been a thread about this at some point but I'm having no luck with the search function (then again, it may have just been an offshoot discussion in an unrelated topic).

At any rate, since just about everything in Cult is procedurally generated to a greater or lesser extent, lately I've been considering the possibility of procedural music generation. I know there have been some attempts at this and that so far the verdict is that it's not really possible, or at least not without an incredible amount of resources and time at your disposal.

I think perhaps the problem is that the approach so far has been all wrong. People trying to make procedurally generated music have been trying to start from scratch; that is, their program is generating EVERYTHING in a 'composition'. My original attempt at a procedural name generator was something like this. I had it generating everything about a language, including the frequency of every letter in the alphabet, acceptable vowel and consonant clusters for each language, and so on... and the result, despite all of the intricacy, was gobbledegook.

However, with a much simpler and more elegant piece of code that determined acceptable letter combinations by reading from a premade set of base names for a language, I was instantly generating pronounceable (and often even authentic-sounding) names. Imagine that...

So, here's what I've been thinking about: would procedural music work if, rather than having the computer create truly 'random' music, it was instead based upon prearranged (read: human-arranged) pieces of music to begin with? Which notes/note combinations could follow others would be determined in the same way that letter selection in a name generator would be. Ditto note length. Of course, generating a song would be infinitely more complicated than generating a name, because there are multiple instruments to create tracks for, and you would have to create some type of algorithm to ensure that the song would sound harmonious (or at least as harmonious as the original base song(s)).

I have a feeling it could be done, though. Acceptable notes played by each instrument in a song at any given moment could be determined in the same way acceptable note patterns for an individual instrument and temporal patterns would be: by using the original song or songs as a basis and cannibalizing them into their simplest patterns.
« Last Edit: May 09, 2011, 08:49:46 pm by Lord Dullard »
Logged

Mondark

  • Bay Watcher
    • View Profile
Re: Procedural Music Generation
« Reply #1 on: May 09, 2011, 09:43:21 pm »

There's been a fair amount of work done in this area, actually.  Markov chains apply just about as well to music as they do to names and text, but there's also some really neat stuff based on Cellular Automata that you might find interesting.  Wolfram has some nifty articles and a demo over here.
Logged
Fefeshnelmargalip

Lord Dullard

  • Bay Watcher
  • Indubitably.
    • View Profile
    • Cult: Awakening of the Old Ones
Re: Procedural Music Generation
« Reply #2 on: May 09, 2011, 09:46:16 pm »

Ah, so this has already been done. Go figure.
Logged

Mondark

  • Bay Watcher
    • View Profile
Re: Procedural Music Generation
« Reply #3 on: May 09, 2011, 09:59:49 pm »

Bah!  What reason is that not to go and do it over again!?  Besides, there's not enough games that actually *use* procedural music.  Actually, I can't think of any, of the top of my head.  Some of the CA stuff would be just about perfect as background music for certain games.
Logged
Fefeshnelmargalip

Lord Dullard

  • Bay Watcher
  • Indubitably.
    • View Profile
    • Cult: Awakening of the Old Ones
Re: Procedural Music Generation
« Reply #4 on: May 09, 2011, 10:21:38 pm »

Well, I didn't say I wasn't going to attempt it (eventually)! To be fair, that link you posted generates some interesting stuff, but it's hardly what I'd call worthy of being used as game soundtracks. I think there's a lot of perfecting and tweaking to be done.
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Procedural Music Generation
« Reply #5 on: May 09, 2011, 10:24:36 pm »

Here's a project one of RIT's professors took on at one point; Gen Jam: http://www.ist.rit.edu/~jab/GenJam.html
It sounds really quite good and he can even play off against it with his trumpet, with the software trumpet's reply supposedly being better than most human trumpet players he plays off against. He demo'd it in the class I had with him last quarter. It uses a variety of midi, using a microphone hooked up to an analog to midi converter so as to create music based on what the trumpet player is playing.

And some various other AI in music: http://en.wikipedia.org/wiki/Music_and_artificial_intelligence

Game music, like most sound in games, is largely overlooked in general, and dynamically generated soundtracks usually even more so than normal. Take Portal 2's dynamically generated music-like-substance you hear in the form of annoying things based on the player's current actions and movement during some of the game.

Then there are the multi-layer things in which multiple theme tracks (usually one for each or a group of instruments) which are laid over one another to create the piece. Elemental: War of Magic had this to create its music, which was relatively passable considering the music compositions themselves were done by the same composer who created the horrific music of GalCiv:2 (oh gods, that same musical theme repeated every 30 seconds for the entire duration of every piece of music in the game still makes me raeg).
« Last Edit: May 09, 2011, 10:32:11 pm by alway »
Logged

Lord Dullard

  • Bay Watcher
  • Indubitably.
    • View Profile
    • Cult: Awakening of the Old Ones
Re: Procedural Music Generation
« Reply #6 on: May 10, 2011, 12:19:11 am »

How about: code a genetic algorithm to produce songs (preferably in something better-sounding than MIDI) which are then streamed to a user via a website. The user selects whether they liked the song and how much. If they liked the song, more songs incorporating elements of that one would be more likely to occur. If they didn't, elements of that song would occur less.
Logged

Biag

  • Bay Watcher
  • Huzzah!
    • View Profile
Re: Procedural Music Generation
« Reply #8 on: May 10, 2011, 04:04:18 pm »

Now if only it was possible to randomly fill out a grid.

That thing is absolutely genius to the highest degree. Simplicity at its finest!
Logged

Biag

  • Bay Watcher
  • Huzzah!
    • View Profile
Re: Procedural Music Generation
« Reply #10 on: May 10, 2011, 10:21:47 pm »

I actually prefer the first one, because it's easier to work out the timing. :P Plus, pentatonic goodness means that nothing can go wrong.
Logged

Lord Dullard

  • Bay Watcher
  • Indubitably.
    • View Profile
    • Cult: Awakening of the Old Ones
Re: Procedural Music Generation
« Reply #11 on: May 10, 2011, 10:28:34 pm »

@Max: Both of those are neat, but neither is a proper procedural music generator.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Procedural Music Generation
« Reply #12 on: May 10, 2011, 11:40:53 pm »

No, they in themselves are not, but they are good proof of concept. Just close your eyes and click random squares and you have a song, so it is easy to have a program fill out squares for you. If I had the code of that first one, I could mod it to randomly produce music in minutes.

Biag

  • Bay Watcher
  • Huzzah!
    • View Profile
Re: Procedural Music Generation
« Reply #13 on: May 11, 2011, 12:06:30 am »

Admittedly, the music would never change chord, but that is also easily fixed. Set a certain number of notes per chord, and once you get to the "switch chord" point, change the root note to any note in the current pentatonic scale. Then construct a new pentatonic off of that, rinse, and repeat. Hell, it would sound pretty good even without changing the grid patterns at all- the same music, switching keys.

Then, throw the blue note in there and alter the pattern generation code a bit, and you can give Cult its very own jazz improvisation soundtrack. :P
Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: Procedural Music Generation
« Reply #14 on: May 11, 2011, 06:02:04 pm »

There's been a fair amount of work done in this area, actually.  Markov chains apply just about as well to music as they do to names and text, but there's also some really neat stuff based on Cellular Automata that you might find interesting.  Wolfram has some nifty articles and a demo over here.

That's really cool.  I'll have to play around with it some more in the future.
« Last Edit: May 12, 2011, 10:10:27 am by Draco18s »
Logged
Pages: [1] 2