Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411275 Posts in 69323 Topics- by 58380 Members - Latest Member: bob1029

March 28, 2024, 07:53:11 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperAudioProcedurally Generated Music
Pages: [1] 2
Print
Author Topic: Procedurally Generated Music  (Read 5509 times)
Feral_P
Level 1
*


View Profile
« on: August 04, 2011, 04:43:20 PM »

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 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, or a musical phrase) are 'strung together' by my program. Which notes (or parts of a rhythm, etc.) are chosen, is determined by music theory. Notes (etc.) 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 Smiley
The quality of output can vary greatly, of course Wink

Feedback, comments, criticism, encouragement, advice, or anything else of the sort would be greatly appreciated Smiley
« Last Edit: October 02, 2011, 10:38:14 PM by Feral_P » Logged
Brother Android
Level 10
*****


View Profile
« Reply #1 on: August 06, 2011, 07:47:13 AM »

these songs are terrible, what's wrong with you

Nah, this is really cool; it could accidentally generate something of interest I'm sure. It's hard to comment though, due to the nature of the thing - I mean, I didn't find the songs "good" (the fifth one was close though) but I think that is just a matter of chance - what you're doing here is interesting and worthwhile. Although... the voices are terrible.

Also, you make it sound like compliance with music theory is only probable, not guaranteed - can you adjust the probability? That might produce output that's interesting, either for its melodicness or lack thereof.
Logged

BattleBeard
Level 6
*


please touch me


View Profile
« Reply #2 on: August 06, 2011, 08:03:40 AM »

 I like the first one...

Very unique, indeed!
Logged
Feral_P
Level 1
*


View Profile
« Reply #3 on: August 06, 2011, 02:12:42 PM »

Thank you, both Smiley

Also, you make it sound like compliance with music theory is only probable, not guaranteed - can you adjust the probability? That might produce output that's interesting, either for its melodicness or lack thereof.
Yeah, I can adjust the 'penalties' applied for each thing (for lack of a better term) it doesn't comply with. A bit of fine-tuning is needed, I suspect Tongue

I'll try to play some of the generated music through a decent synthesiser at some point, and post it here.
Logged
Brother Android
Level 10
*****


View Profile
« Reply #4 on: August 06, 2011, 02:32:37 PM »

Is the output MIDI? just curious.
Logged

Feral_P
Level 1
*


View Profile
« Reply #5 on: August 06, 2011, 02:47:12 PM »

No, I'm using Python to generate a CSound file (.csd), which is then read by CSound (obviously...) and turned into a .aif. MIDI might be a better choice of synthesiser, though(?). Well, I suppose anything would be
Logged
Brother Android
Level 10
*****


View Profile
« Reply #6 on: August 06, 2011, 03:08:39 PM »

No, I'm using Python to generate a CSound file (.csd), which is then read by CSound (obviously...) and turned into a .aif. MIDI might be a better choice of synthesiser, though(?). Well, I suppose anything would be
Well, MIDI would not be a better choice of synthesizer precisely, but you could use the generated data with pretty much any softsynth
Logged

s0
o
Level 10
*****


eurovision winner 2014


View Profile
« Reply #7 on: August 06, 2011, 03:20:23 PM »

Yeah, generating MIDI files, one for each voice, would probably be the superior choice here.
Logged
baconman
Level 10
*****


Design Guru


View Profile WWW
« Reply #8 on: August 07, 2011, 09:52:22 PM »

Before my computer crashed (and I lost my sounds library ;.Wink, I was working on something similar called DMG (Dynamic Music Generator)... though it did work a bit differently, since chords (lead guitar ones in particular) were sampled seperately. What it did was create a string of 1/48th notes (in groups of 5 correlating notes, ala GH/RB; usually like [12356]), and then filter ones outside of a "beat filter." (The most important factor in the notestrings is that sequences of them be actually fun to pull off.)

The beat filters corresponded with different musical structures... so "folk" and "blues" stuff would remain in 1/12s, where pop would mostly be 1/8s, and rave/tropical/trance was more oriented around 3/16s. And sometimes you just needed those hard rolls/riffs in a part, too! Was trying to work out some kind of "dynamic guitar/piano solo" sort of thing, too; along with a few ending variations like fadeouts, "big rock endings," or a short "bridgey" section with one or a few dramatic closer notes. I mostly focused on song sections, and tied one "beat filter" to each instrument... although careful not to mix the 1/12 and 1/16 ones at once.

I only got it about 20% done, however, and it's been lost to the wind and on my "stuff to catch back up on" list. (Bear in mind, I lost 1.5 YEARS worth of work on that crash. THAT EFFIN' HURT.) You can catch some of the conceptual framework typed out in my iMAGE Zero devlog (linked in my siggy).

Of course, on top of direct-recording (preferably to MP3/OGG output), it was also designed to output corresponding files (the same way) for use with StepMania and Frets of Fire, too.
Logged

Feral_P
Level 1
*


View Profile
« Reply #9 on: August 08, 2011, 12:18:51 PM »

OK, I moved it to a MIDI file and imported it into a soft-synth. Great idea, it worked like a charm Wink

This is a pretty bad example track (I set it to repeat to much, all the voiced use the same instrumnet, I think using three melodies and chords is too much, and I still need to tweak the settings quite a lot), but since I won't be working on it more for a couple of days, I thought I'd post it here anyway. Here you go:

http://voxygen.bandcamp.com/track/output-six-version-2

baconman: That sounds interesting, I'll check it out when I have some more time Smiley
Logged
Feral_P
Level 1
*


View Profile
« Reply #10 on: August 11, 2011, 09:23:40 AM »

More examples using the soft-synth:
http://voxygen.bandcamp.com/track/output-seven-version-2
http://voxygen.bandcamp.com/track/output-eight-version-2
http://voxygen.bandcamp.com/track/output-nine-version-2
http://voxygen.bandcamp.com/track/output-ten-version-2
Logged
Pineapple
Level 10
*****

~♪


View Profile WWW
« Reply #11 on: August 11, 2011, 09:39:30 AM »

This is really very interesting.
Logged
Feral_P
Level 1
*


View Profile
« Reply #12 on: August 11, 2011, 11:36:16 AM »

Do you guys think it's worth continuing? I doubt I could improve the actual composition MUCH more, however I could improve structure, making it into whole songs, or work with instruments/timbres (which do wonders for creating a mood) and/or add percussion...

But I don't actually know what I could *do* with this. What it produces is actually quite good IMO, but it's never going to compare to a human composer.

Logged
bauer
Level 1
*


Codes games & makes music


View Profile WWW
« Reply #13 on: August 12, 2011, 04:50:25 AM »

I apologize if I've missed this info somewhere, but I'm curious to know how/if you can "direct" the music. Do you have any (or if not, would it be possible to do) variables for controlling stuff like tempo, major/minor feel, agressive/soft, etc etc?

What I'm thinking is that if this could be adjusted dynamically it would be quite awesome to integrate this in somekind of music game or similar. Should have a competition with games that integrate it! Beer!

Edit:
I mean I've seen that you have settings for "minor" etc, but I guess my main question is if it is able to switch from minor to major (and others) dynamically without screwing up. Smiley
Logged

Geeze
Level 5
*****


Totally.


View Profile
« Reply #14 on: August 12, 2011, 05:50:16 AM »

Self-quote:
Maybe one day we'll be able to just procedurally generate entire games.
Next TIGCommunity project?
Evil
Logged

Feral_P
Level 1
*


View Profile
« Reply #15 on: August 13, 2011, 12:50:01 PM »

I apologize if I've missed this info somewhere, but I'm curious to know how/if you can "direct" the music. Do you have any (or if not, would it be possible to do) variables for controlling stuff like tempo, major/minor feel, agressive/soft, etc etc?

What I'm thinking is that if this could be adjusted dynamically it would be quite awesome to integrate this in somekind of music game or similar. Should have a competition with games that integrate it! Beer!

Edit:
I mean I've seen that you have settings for "minor" etc, but I guess my main question is if it is able to switch from minor to major (and others) dynamically without screwing up. Smiley
Well, I'm afraid it isn't built to generate anything on-the-fly. Rather, it will generate a whole song at once, and output it. With some work, it could be adapted, though I suppose... Smiley

The 'main' variables I have control over are: tempo, scale, time signature and 'mood' (although how much this variable actually sways anything is debateable). The other variables I control are more 'weights' - how high a penalty/bonus is given to notes/note durations/whatever which do/n't comply with certain rules.
Logged
baconman
Level 10
*****


Design Guru


View Profile WWW
« Reply #16 on: August 14, 2011, 12:06:08 AM »

Well... if you had a notechart editor as a midway point, you could use the PGC as an "inspirational piece," and then users could reorchestrate notes to fit. IE: make it more a tool and less a certain-output. I started off with something similar to GHTunes from World Tour, but something like Mario Paint may work just as well.

As far as starts go, what I was gonna do with DMG was have a main-focused "lead" instrument and a secondary open with a first chorus part that doesn't contain the others (IE: one instrument lead in leads to a second joining, and then the song "begins" afterwards at the point yours does); and finale with a reemphasized one-bar, but it's also good to keep those parts optional in case people are building looping tracks instead of full songs. It could also be possible to compile those parts seperately for game-coding purposes - like an intro that begins a "song loop" at it's end, and the outro that functions as a "level beaten" or something along those lines.

Coming up with a technique "solo" scripting was stumping me, however. The non-lead instruments would still play a normal verse/chorus, only the lead instrument would be changed to solo mode. But "what of it I got to" was totally focused on fun-to-execute techniques (like slides, heavy-riffing, polyrhythms, etc.); it just seemed a little too randomized. It just focused one verse with an alternate-notechart focused more on showoffy/fun/complex stuff; but still within the range of notes presented (although I considered a bit of a mixup there at first, songs with particularly high- and low-pitched tones didn't work with that so well, especially when crossed from one extreme to the other).

One thing that did make hammer-ons/pull-offs and piano/organ melodies surprisingly smooth sounding was simply beginning those "notes" 0.35-0.45 ms into the samples. Just enough to take off the "hard strum" sound. Many of the drum samplings I used (from "tictacshutup" IIRC) also had 3 different taps on many of the drums/cymbals (snare and hi-hat most especially); so randomizing between each set gave it more of an "authentic drumming" sensation about it. (Even real drummers are creatures of habit, and hit the same points on a drum more often than you might expect a non-automated person to do!)
Logged

Feral_P
Level 1
*


View Profile
« Reply #17 on: August 14, 2011, 02:00:17 AM »

Well, right now it produces MIDI files, and has to be converted into a .wav or whatever by a soft-synth anyway. So you could use the soft-synth to edit the notes (a good idea, btw).

Have you got any recordings of your generated music? I'd like to give it a listen Smiley
How did you find the melodies went with eachother and the chords? The way I imagine you doing it, it sounds like they'd be a little too dissonant/ not 'gel' well together...

EDIT: In fact, I have MIDI files here, in case anyone wants a look/to edit them:
Output Ten: http://dl.dropbox.com/u/10171005/output_ten.mid
And a new song: http://dl.dropbox.com/u/10171005/output_eleven%20%28new%29.mid

Someone on my Bay12 thread (here) changed the instruments about, and produced these:
http://www.fileden.com/files/2011/5/11/3131898//ten.mp3
http://www.fileden.com/files/2011/5/11/3131898//Eleven.mp3
« Last Edit: August 14, 2011, 02:09:55 AM by Feral_P » Logged
easynam
Level 5
*****



View Profile WWW
« Reply #18 on: August 15, 2011, 03:19:09 PM »

This is a cool project :v

It's something I've wanted to do for a while too, but I'd have no idea where to start. Good job with this so far Smiley

I wish there was an easy synth to work with for this stuff.
Logged

baconman
Level 10
*****


Design Guru


View Profile WWW
« Reply #19 on: August 16, 2011, 03:42:31 AM »

Sadly, no. I only got as far as working on the notechart algorhythms, never got as far as recording or outputting. :S Or this place would've instantly hit the spot. I think keeping the notework that meshes together just comes for 10 years of musical gaming experience, it's not hard to pick up on recurring patterns of patterns, or remembering stuff that's fun to pull off, like for example, the "Boston Hammer." It's a recurring little sequence of four 1/12 hammer-on-pull-off notes that often occurs during the chorus of most popular songs by Boston.

Different note-timing structures often occur in popular music genres as well, so the other half was just to use those kind of like a "screening filter" for full note sequences. The full sequences were easier to concieve in 1/12s and 1/16s, naturally. Usually the 1/12-based notes were mildly-altered variations of the 1/16 ones, and the rest of the notes were just jammed in as fillers. Sometimes one "note color" would also be screened out completely, just to increase the song variation.

Heavy-riff patterns were actually easiest, because it was just a matter of when to change the note - everything else was constantly hammering that one button. Another simple sequence took the 1/8 notes and mapped them in various patterns across the higher notes, then filling the 1/16s between them with the lowest "green" note. There were also some similar layouts using 3/16 patterns in rave and tropical beat layouts, and with 2 greens between each.

It's really all about keeping it simple! Even "good hard songs" to play often stick with the fun-in-fundamentals, they just do it faster and with a little more structural complexity... IE: 4 sets of 8 bars, instead of 8 sets of 4 bars, if that makes sense.

The other trick that made the melodies work was simply by pre-bundling the notesets, so that only 5 "in tune" notes were used at any given time. For example, the organ key sets associated with (1-2-3-5-6) finger positioning. Then, for each instrument, I usually used a selection between 3 bundles; a high-scale, a mid-scale, and a low-scale. Just not with drums or dance steps.

Also, the "Epic/Prog" cross-mashing styles were still theory-on-paper, I didn't get around to implementing those styles before the crash, either. The idea was simple, it basically composes two songs, along with one intro and one finale, at whatever different styles/tempos. Then in Prog: after every chorus, it would cross to the other song's verse (modeled after Carry On Wayward Son or Aqualung). In Epic it would just play the entirety of one song/type into a bridge, and then play the second song as a continuation of the first (more inspired by Free Bird or Stairway to Heaven, or maybe "A" or Healing Vision from DDR/Beatmania IIDX).

I'm kind of remotivated to pick this back up and do it over, but I can't for the flick of me find where I got my guitar-strum/chord samples! X$ GRR!! (Yes, it's a cheap copout, but Lead Guitar had prerecorded chords that just triggered multi-color strum targets...) Plus, I was using Game Maker Pro, and GM is admittedly HORRIBLE at audio-memory management. I had to intermittently save, close (the program), and reopen the project SIX TIMES just to load all of the sounds without it crashing on me!

Should I be a little more Pro with GM, I think I would just have it do notecharting internally, and then associate the charts with the audio samples afterwards/externally.
« Last Edit: August 16, 2011, 03:52:29 AM by baconman » Logged

Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic