Menu Home

Computer music

The Iamus computer composer

According to this article:

“We have taught a computer to write musical scores,” says Gustavo Diaz-Jerez, software consultant and pianist.

“Now we can produce modern classical music at the touch of a button.”

Awesome! Let’s hear some examples!


I’ll keep working on my own attempt for now. I want my Mozart Symphony Generator.

In the meantime, here’s Emily Howell creator David Cope performing some John Cage:

Computer generated sea chanteys!

How often have you been sitting there thinking: “Oh my gosh! I wish I had some new sea chantey melodies to play on an instrument and/or write lyrics to!”  Probably more times than you care to count, eh?

Well, fear no more!  The sea chantey melody generator is finally here!  That’s right; in less than a second, the sea chantey melody generator will generate hundreds of sea chantey melodies for you, filled with those catchy memorable sea chantey melody patterns.

Here is a sample of 100 sea chantey melodies as generated by the generator.  Feel free to write lyrics for them and add them to your collection of sea chantey goodness.

The sea chantey melody generator is available for just 5 easy payments of $50,000.

Seriously, though, I’ve been working on getting my melody generator to compose in “styles” and sea-chantey-style was my first experiment.  I look forward to trying some other styles.  As usual, the melody generator is restricted to 8-bar melodies in 4/4 time, a restriction I still haven’t programmed my way out of, but trying to get the generator to work with styles has been a more interesting endeavor recently.

1,000 computer generated melodies…

For the past couple days, I’ve been working on getting my melody generation program to output MIDI files so I wouldn’t have to convert them manually from a text file, which takes an annoying amount of time. And… I’ve done it, haha! So now I can tell my program… hey, I want 1,000 melodies, go. And it spits it all out over the course of a couple minutes. So here are 1,000 short little MIDI files my program wrote just a few moments ago, in a zip file:

Zip file with 1000 computer generated melodies

Some notes:

1. – Again, the program is currently restricted to 8-bar melodies in 4/4 time, and must start with the I chord and end on the tonic.

2. – For the sake of a little variety, I set the tempo to be a random BPM between 80 and 150, and the key signature to be random between A major and D major (it starts in C major then just shifts all notes up or down).

3. – There is one small bug you might hear in some of the melodies: the bass notes are shifted offbeat. I’m workin’ on it. Fortunately it doesn’t seem to happen often.

Yet even more computer generated melodies…

Here are yet more computer generated melodies from my in-development automatic melody generator. I have made a lot of changes to the algorithm since I posted the last set of examples, but I’m not sure how much you can actually hear. Still more work to be done… anyway, here are 12 more melodies…

Computer generated melodies


I’ll probably spend another week on the main algorithms, then I’ll start trying to add more diverse capabilities, like different time and key signatures.

More computer generated melodies! Woohoo!

Even though I’ve still got plenty of work to do on my automatic melody generator, it’s at the point now where I’m finding it quite addicting. Here are a bunch of melodies it came up with today (I think there are 12 altogether, each stated twice):

Computer generated melodies

Again, I don’t think the melodies sound super fantastic by themselves, but there are definitely some surprisingly good phrases, in my opinion.

Some notes:

1 – Again, it’s still limited to 8-bar melodies in 4/4 time in C major that begin and end on the I chord and can only use the basic triads. I still have algorithmic changes to make before I start expanding its abilities in this area. (For the audio above, I transposed it up a step to D major; sounded just a bit better to me.)

2 – The program is “creating” its own “melodic knowledge” and, as you might hear, the biggest problem this creates is that it likes to write large melodic leaps every now and then, which can sound funky. It didn’t do this before because it based its melodies on observations, and large melodic leaps like that would never (or rarely) be observed. So I’m going to have to hardwire an interval limit into the algorithm, perhaps letting the user set it.

3 – In the last two melodies, I gave the program the ability to use to 16th notes. You don’t hear them in the other melodies because the program wasn’t allowed to use them, but it’s an easy ability to give the program. Triplets, on the other hand, will be tricky… I guess I’ll have to figure out those at some point. Meh… that can come much later…

4 – The program outputs a text file with note values and accompanying chords; it doesn’t actually output the sound you hear in the MP3 … I had to manually enter the info into Overture 4 and use Garritan Personal Orchestra to create the actual sounds.

Melody generator update…

My obsession with programming an automatic melody generator (that actually gives good results, unlike just about every other melody generator out there) continues. Again, the program works by analyzing existing melodies and “learning” from them. In my 2008 version, the program analyzed the given melodies while it composed new ones from them. Now the program stores its “knowledge” so it doesn’t have to analyze a melody more than once. Of course, there’s still the problem of getting the program to find the right sort of knowledge and to use it appropriately. But what I have is coming up with some interesting results. I’ll post more later, but here’s one melody the program wrote early this morning: MelodyExperiment2.mid (melody stated and repeated ad nauseam in pizzicato… the output of the program just gives chords and melody numbers; the tempo, the instrument choice, and alberti bass were added by me)

EDIT: By the way, obviously some of the melodies it outputs sound much worse than that. That’s one of the better ones…

Unfortunately there are still a lot of limits in the program that need to be dealt with:

1. It can still only compose an 8-bar melody in 4/4 time. I need to give it a wider range of time signatures (3/4, 2/4, and 6/8 at the very least), and I need to let it be able to compose 16 and 32 bar melodies, and “extended” melodies, such as a 10-bar melody which is really just an 8-bar melody that takes two extra bars to resolve. Ideally the user could choose the bar length and time signature.

2. It can only compose in C major. That might seem trivial; can’t the program just transpose the melody up and down afterward generating it? Unfortunately that can lead to notes that are way too high or way too low. To keep the melody within a certain range, we’ll have to deal with this.

3. It can only compose diatonic melodies. It can not yet shift into other keys or limit itself to a certain scale. Fortunately I don’t think this would be very hard functionality to add; it’s just a matter of giving the program more options, and making sure it uses them appropriately.

4. It can only compose within a certain range of notes. Which is fine, but ideally the user could decide what range is allowed, and what interval leaps are allowed.

5. There are limits on chord progressions. It must always start and end with the I chord. This makes it sound nice and complete, but it should have the ability to start on a different chord or something. It also sometimes comes up with some pretty odd chord progressions that are technically fine, but just odd. It would be interesting to program an “inventive” variable, telling the program how much it should do whatever it wants with the chord progression (within reason), and how much it should adhere to what it “knows.” Also, it currently only recognizes the main triads; it ignores major 7ths, major 9ths, sustains, etc. I’m not sure that matters much; a listener could always change that himself if he wants to use the melody for something, so if I do add that feature, it will probably be the last thing I concern myself with.

And then matters of practicality:

6. It outputs numbers in a text file which then have to be laboriously converted manually into a MIDI file, which takes too long. It should be able to output a MIDI file (or files) by itself, or at least a much easier to read text file.

7. It’s programmed in Java. To get it to work on the Internet (if that’s what I decide I want), it will probably have to be converted to PHP, and we better make sure it’s not too computationally heavy for that. (I don’t think it would be.)

That’s all! Enjoy that beautiful melody! Look out for more!

Computer, write a melody in G major, please…

I’ve been finding it hard to focus on my animation studies this week. I had a little musical epiphany, and my mind is now once again obsessed with working on my book on writing melodies and the “melody generator” computer program to go with it. The program is now capable of outputting some pretty nice stuff, a huge improvement compared to the 2008 version. But you’ll just have to take my word for it because I’m not quite ready to share samples just yet. But soon, I hope. I also think I’m pretty close to getting it to generate complete songs (in melody + chords format, not entire instrumental arrangements), at least algorithm-wise; then I still have to program it. I’m tempted to expand the topic of the book from melody composition to musical composition in general; after all, couldn’t one define any polyphonic piece as just a bunch of melodies played together? It’s the natural extension of my work, so why not just go for it? But who knows how long that would take…

Anyway, I’m extremely excited, and I’m pretty confident that within this decade, perhaps even within the next few years, we’ll have some great computer music generating programs (from me or from someone else) that will provide us with a lot of inspiration. I’m confident because I have it now. In baby form, at least.

But I’m probably getting way ahead of myself. “Don’t get excited.” It’s in the artist’s creed. Gah, it’s hard…

I’m not really sure why I’m posting this. I don’t have anything useful or interesting to share yet. I guess I just wanted to let out my excitement.

Oh, I’ve also been composing endless melodies. When you’re writing a book on the subject, the ideas just pour from the mind. I suppose that’s part of what’s fueling my obsession… melodies, melodies everywhere…