Page 1 of 3

Musical: automatic music generation

Posted: Fri Oct 19, 2012 10:09 am
by Robin
This is a small thingy, which I'm writing for a future game (which will be so large I'm going to make it piece by piece).

The melody in this demo is short, only a bit random (it repeats the same fragment over and over again with minor differences) and not at all good. I hope to collaborate with someone with a background in music for the actual game.

It generates the music in small chunks, which are put into a queue. The music generator thread sleeps as long as there is no demand for a new piece of music.

Keys:
  • space: toggle soft notes
  • d: toggle dampening
  • escape: quit

Re: Musical: automatic music generation

Posted: Fri Oct 19, 2012 11:07 am
by Roland_Yonaba
Looks great (and atrociously complex, too :D). Sound programming scares me... :awesome:
It will be better (maybe ?) to print some informations, such as the dampening state, actual queue size (seems to be always <3), softnotes status...

Re: Musical: automatic music generation

Posted: Fri Oct 19, 2012 11:16 am
by Robin
Roland_Yonaba wrote:Looks great (and atrociously complex, too :D). Sound programming scares me... :awesome:
Really? I thought it was fairly simple. What seems so complex to you?
Roland_Yonaba wrote:It will be better (maybe ?) to print some informations, such as the dampening state, actual queue size (seems to be always <3), softnotes status...
Yeah, I will make lots of improvements and add a heap of cool stuff. This is just some things I threw together that seemed to work pretty neatly.

By the way, my plan was to always keep the queue short, so that the game can respond quickly to changes in the situation (suddenly, you're under attack. At that exact moment, the calm, quiet music changes in something frantic and slowly turns bombastic as the battle heats up). So to make the music not lag behind several seconds, the game will flush the queue when something like that happens. That means it would be useless to make the queue grow to a large size, because some of that will be thrown away without playing it anyway. Might as well not generate too much of that stuff in the first place. Realistically, with how fast each chunk is "rendered", I suspect that the game will rarely need a queue size of > 1 anyway.

Re: Musical: automatic music generation

Posted: Fri Oct 19, 2012 3:39 pm
by qaisjp
Definitely looks interesting.

Re: Musical: automatic music generation

Posted: Fri Oct 19, 2012 3:44 pm
by paritybit
That's very cool. I'm so sound stupid. Where would somebody go to try to understand why that code seems to be so short but does so much? I expected that prerecorded sounds were being strung together or something. I guess I have a lot to learn.

Re: Musical: automatic music generation

Posted: Fri Oct 19, 2012 8:44 pm
by Robin
paritybit wrote:Where would somebody go to try to understand why that code seems to be so short but does so much?
You can start at sound and then look at frequency. Short answer: math.sin is really cool.

Re: Musical: automatic music generation

Posted: Thu Nov 22, 2012 8:27 pm
by qaisjp
What license is the code released in?

Re: Musical: automatic music generation

Posted: Thu Nov 22, 2012 11:07 pm
by Robin
None yet. But it's going to be part of a game which I might release under the MIT license for.

Re: Musical: automatic music generation

Posted: Fri Nov 23, 2012 2:17 am
by Tesselode
I can help you with musical stuff if you want.

Re: Musical: automatic music generation

Posted: Fri Nov 23, 2012 4:52 am
by Jamie
I love it, definitely going to be experimenting with this and posting what I find.