Bay 12 Games Forum

Please login or register.

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

Author Topic: Procedurally Generated Music  (Read 4382 times)

Chris_24

  • Bay Watcher
    • View Profile
Procedurally Generated Music
« on: August 11, 2011, 12:30:35 pm »

I thought you guys might appreciate this...

I've been working on this Python program on and off for a few of months, now. It generates - entirely on its own - rhythms, melodies, chords and small-scale phrase structures.

While most attempts at computer generated music use algorithms that are either genetic (they alter their output based on people's ratings of it), computer-science/mathematics-based (eg. fractals or cellular automata) or analytical (analyse a piece of music and 'learn' to make something similar) to produce their music, I chose to use a music-theory based approach.

Essentially, notes (or parts of a rhythm, or chords, musical phrases) are 'strung together' by my program. Which notes (or parts of a rhythm, etc.) are chosen, is determined by music theory. So, notes which comply with music theory are more likely to be picked as next in the sequence than those that don't.

Latest Version:
http://dl.dropbox.com/u/10171005/Procedural_Music.zip
Download, unzip and run "Procedural Music.exe". Pressing "Generate Music" creates (or overwrites) "output.mid", which you should then be able to play, or load into a soft-synth and edit. It should run under wine as well :)
The quality of output can vary greatly, of course ;)

Feedback, comments, criticism, encouragement, advice, or anything else of the sort would be greatly appreciated :)
« Last Edit: September 22, 2011, 12:11:32 pm by Chris_24 »
Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: Procedurally Generated Music
« Reply #1 on: August 11, 2011, 12:50:28 pm »

Not bad. :)
Logged

klingon13524

  • Bay Watcher
  • The Mongols are cool!
    • View Profile
Re: Procedurally Generated Music
« Reply #2 on: August 11, 2011, 01:34:45 pm »

Now to couple it with a DF-like lyrics generator...
Logged
By creating a gobstopper that never loses its flavor he broke thermodynamics
Maybe it's parasitic. It never loses its flavor because you eventually die from having your nutrients stolen by it.

Draco18s

  • Bay Watcher
    • View Profile
Re: Procedurally Generated Music
« Reply #3 on: August 11, 2011, 01:42:46 pm »

I'd like to see different music styles.
Rock, Country, etc.  Right now it sounds...classical/religious?
(By religious, I mean, it has that bell choir feel to it that I'd hear in church)
Logged

Chris_24

  • Bay Watcher
    • View Profile
Re: Procedurally Generated Music
« Reply #4 on: August 11, 2011, 02:27:04 pm »

Yeah, I'd quite like to see that. Unfortunately I have no idea how to... Instruments would be a large part, but AFAIK the music theory behind each genre is largely the same. When I was programming this, I just hoped 'genres' would emerge... well, emergently. I might try changing chords a bit (7th chords for jazz, power chords for rock) and using different modes (other than major/minor) might help as well. Other than that, I can't really think of anything. I can alter the average note speeds, but I'm not sure that would make much difference.
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Procedurally Generated Music
« Reply #5 on: August 11, 2011, 04:40:31 pm »

The instruments bug me, a lot. I would love to get my hands on one of the midis to mess with in FL. The music by itself reminds me of video-game stuff, catchy background themes. Not necessarily a bad thing, but far from universal.

Allowing the program to vary note speed/spread per phrase would give a lot more flavor to the music. Right now the progressions are very predictable. The songs go somewhere, and that's something most procedural music never accomplishes, but as soon as you've heard one part of it you can safely ignore the part after. Does that make sense?
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

Chris_24

  • Bay Watcher
    • View Profile
Re: Procedurally Generated Music
« Reply #6 on: August 11, 2011, 05:26:44 pm »

Thanks for the feedback (and compliments) ;)

Yeah, I think I understand what you mean.

To make myself clear, I'll go into a bit more detail about how the structure is generated:
I tell each 'voice' how many bars I want it to fill, then I tell it when to start and how many times to repeat. It then generates a 'structure'. For example, I may tell my melody to generate a structure that's 4 meters long, and repeats three times. In which case it might generate:
[A1, A2, A1, A2] x 3
The letter representing the rhythm, and the number representing the melody to go with the rhythm. So basically, this structure would repeat the same rhythm four times, with a single variation on the melody.

The repetitive-ness is why I think you find it predictable. Unfortunately it only "goes somewhere", as you put it, because I programmed it to 'build up'. This was mostly because I didn't figure people would give it more than one listen, and I didn't want to scare people off by starting off with as much complexity as it ends up with.

Right now it's not at a stage where it can transition from one 'part' of a song to another (eg. chorus to verse), nor can it generate particularly meaningful structures, with the right amount of progression vs. catchiness, on it's own (hence me setting it to repeat). If I tell it to generate, for example, a 12-bar structure, it might generate something similar to:
A1, A2, B1, A2, B1, A2, B1, A2, B1, A2, B1, A2
Getting 'stuck in a loop', essentially (due to the way I programmed it). It is difficult to generate a balanced structure (ie. it's catchy but not boring) - especially since there are four voices to balance - but that'll be my next task. Any suggestions would be helpful (as there's not a lot of music theory referencing how to structure compositions).

I can change how likely the note lengths are to vary from the 'average' I've set - I'll mess about with it when I get back from my short holiday on Sunday.

In fact, I was thinking of side-lining this project, however if you guys think it has some potential, I might carry on with it in parallel to my other (as yet undecided) project... I may give it has a GUI, meaning I can distribute it - that way, you guys can play around with some of the values used to generate the music.

As for the MIDI files...
Here's "Output Ten": http://dl.dropbox.com/u/10171005/output_ten.mid
And here's a newly generated one, just for you: http://dl.dropbox.com/u/10171005/output_eleven%20%28new%29.mid
;)
Sorry all the voices are in one file (you can work out which voice is which by which octave it's in, and at what point the voice comes in) and that it's so long/repetitive, but I'd be really happy to see you upload a version with different instruments :)

EDIT: Also, "Output Ten" is written in 3/4, so you might have to account for that in your soft-synth, so it doesn't display notes all weirdly ;)
Logged

Armok

  • Bay Watcher
  • God of Blood
    • View Profile
Re: Procedurally Generated Music
« Reply #7 on: August 11, 2011, 05:49:33 pm »

This is amazing!
Logged
So says Armok, God of blood.
Sszsszssoo...
Sszsszssaaayysss...
III...

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Procedurally Generated Music
« Reply #8 on: August 11, 2011, 09:23:55 pm »

http://www.fileden.com/files/2011/5/11/3131898//Eleven.mp3
http://www.fileden.com/files/2011/5/11/3131898//ten.mp3
This after a couple minutes fiddling, haha. Nothing that special. The second one I cheated like hell on, with arp presets and no FX tweaking. The first I did more with, but I was still pretty lazy. I didn't want to change any of the actual notes, but with a few modifications it could be a lot better, and the start of a real song.

What you've got is already useful to generate ideas with. Keep working on it, show it to sequencer communities, and you'll get a following, I can guarantee.
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

Draco18s

  • Bay Watcher
    • View Profile
Re: Procedurally Generated Music
« Reply #9 on: August 11, 2011, 09:33:11 pm »

There's some high-pitched background noise in that first one.
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Procedurally Generated Music
« Reply #10 on: August 11, 2011, 09:38:20 pm »

Intentional, an artifact of the Squeeze effect linked with a peak controller. I think it adds character :3 Though probably everyone else in the universe would consider it annoying.
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

Draco18s

  • Bay Watcher
    • View Profile
Re: Procedurally Generated Music
« Reply #11 on: August 11, 2011, 09:44:45 pm »

Intentional, an artifact of the Squeeze effect linked with a peak controller. I think it adds character :3 Though probably everyone else in the universe would consider it annoying.

For me....

Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Procedurally Generated Music
« Reply #12 on: August 11, 2011, 09:57:07 pm »

Then this is probably even more annoying yay!
http://www.fileden.com/files/2011/5/11/3131898//Eagleon - bitSet.mp3
(sorry)
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044

Chris_24

  • Bay Watcher
    • View Profile
Re: Procedurally Generated Music
« Reply #13 on: August 12, 2011, 02:09:15 am »

Thanks for doing that :)
I like them, especially the arpeggio on the second, and some of the effects. And I didn't really notice the squealing ;)

As a (pretty good, if you ask me) composer yourself, have you got any tips on structuring your piece? Sorry to put you on the spot :P
Logged

Eagleon

  • Bay Watcher
    • View Profile
    • Soundcloud
Re: Procedurally Generated Music
« Reply #14 on: August 12, 2011, 11:09:19 am »

I've never actually studied music theory, just kind of play it by ear, so I really don't know how useful I am. I've noticed with a lot of songs, there's a few common grouping patterns, and many times multiple layers of rhythm. If the rhythm (at any level) breaks down in a way you can't compensate for in your head, it's not as good. People have different tolerances for that, and that's what I think a lot of music theorists miss about actual music - symmetry is boring to a lot of people, and there's a psychological component to every piece of music that wasn't made by rote.

I could go on about vague ideas of how music works, but really I'd be talking about my music, not music in general. You're better off talking with someone that has a clue, haha.
Logged
Agora: open-source, next-gen online discussions with formal outcomes!
Music, Ballpoint
Support 100% Emigration, Everyone Walking Around Confused Forever 2044
Pages: [1] 2 3