Musical: automatic music generation

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Musical: automatic music generation

Post 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
Attachments
musical.love
(1.79 KiB) Downloaded 616 times
Help us help you: attach a .love.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Musical: automatic music generation

Post 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...
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Musical: automatic music generation

Post 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.
Help us help you: attach a .love.
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: Musical: automatic music generation

Post by qaisjp »

Definitely looks interesting.
Lua is not an acronym.
User avatar
paritybit
Citizen
Posts: 53
Joined: Thu Sep 06, 2012 3:52 am

Re: Musical: automatic music generation

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Musical: automatic music generation

Post 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.
Help us help you: attach a .love.
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: Musical: automatic music generation

Post by qaisjp »

What license is the code released in?
Lua is not an acronym.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Musical: automatic music generation

Post by Robin »

None yet. But it's going to be part of a game which I might release under the MIT license for.
Help us help you: attach a .love.
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: Musical: automatic music generation

Post by Tesselode »

I can help you with musical stuff if you want.
Jamie
Prole
Posts: 5
Joined: Fri Nov 23, 2012 4:26 am

Re: Musical: automatic music generation

Post by Jamie »

I love it, definitely going to be experimenting with this and posting what I find.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests