Music: Practice & Theory Stack Exchange is a question and answer site for musicians, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm a beginner in music but I also like to fool around with simple computer programs . So I found a little python library to generate MIDI files . So what I do now is that I have a few rhythm signatures or time delays which I've fed in along with a few scales like the major , minor , blues . So I randomly step around the scales in step with the pre - fed rhythm signatures . I'm just looking for some tips from you guys on where I can go from here , what techniques I can use . Also if there are any mistakes or oversights in my present approach. This is my first question here , I hope you guys wont close this question as being too open ended or vague .

EDIT : This page makes for a fascinating read but is short on technical details I have been searching for a few weeks on computer music and the page has some sample tracks as well . This is the best that has been achieved in algorithmic composition to the best of my knowledge.

EDIT 2 : This answer was very helpful .Thanks jadarnel27!
How can I generate nice-sounding random chord progressions?

EDIT 3: This is a pretty impressive demonstration of algorithmic composition Here is the paper+source code for it.

share|improve this question
Well, I'm kind of afraid the question is a little too open-ended. This site works with a Q&A format, as you may know. Because this question is so open-ended, no answer is more right than another. That makes it not that great of a fit for this site's format. However, if you do have any objective questions, feel free to ask! – American Luke Nov 4 '12 at 14:06
I think this should stay open. It's about techniques for composing music, which seems to me to be well within our guidelines for musical practice and performance. – user1044 Nov 4 '12 at 19:15
You might be able to mitigate the open-endedness somewhat by reducing the vagueness. Show a little more of what you're doing. What are your rhythm signatures? What kind of results are you getting? ... Try different random number generators (particularly the bad ones), and expand the "steps" into randomly selected two- or three- note figures. – luser droog Nov 4 '12 at 19:50
Any useful algorithm should be adaptable to different time signatures and scales. Perhaps we could make this a one-algorithm-per-answer community wiki? – naught101 Nov 5 '12 at 8:00
my problem with the question is the word "random" it does not define goals , do you want produce historically or experimental music ? scales are just some tools like math they doesn´t do much alone, techniques aren´t musical.. define your goal.... do you want to learn about scales in western music? – martin rudowski Nov 8 '12 at 22:47
up vote 20 down vote accepted


has been around for 20 years.

Max gives you the parts to create unique sounds, stunning visuals, and engaging interactive media. These parts are called ‘objects’ – visual boxes that contain tiny programs to do something specific. Each object does something different. Some make noises, some make video effects, others just do simple calculations or make decisions. In Max you add objects to a visual canvas and connect them together with patchcords. You can use as many as you like. By combining objects, you create interactive and unique software without ever writing any code (you can do that too if you really want to).

Are you aware that algorithmic composition is something that started centuries ago, in one form or another? In recent years, algorithmic composition has received a lot of academic study.

There is a Wikipedia article on Algorithmic Composition. The article itself provides a cursory overview of this field. It doesn't have a lot of practical information but it has a bibliography that you could use to look for more information.

The Wikipedia article also provides a long list of commercial and open-source music software apps for algorithmic composition. It would be worth your while to try some of those and see what you can learn from them. Some of them are for creating avant-garde experimental music, and some of them, like Band in a Box, are for composing recognizable mainstream jazz. There is a modular toolkit for algorithmic composition with a graphical user interface called Max which is in use all over the world, particularly in academic circles.

As an interesting aside, Wolfgang Amadeus Mozart published an algorithmic music system in 1787, called the Musical Dice Game. It involved arranging musical phrases (composed by Mozart himself) in different combinations according to the roll of dice and a set of rules. This comes under the category of what is referred to as stochastic composition. You can Google "Mozart musical dice game" for more references. Here is one reference worth reading.

Other topics to look into from the pre-computer era would be aleatoric composition (championed by the 20th-century composer John Cage) and 12-tone serial composition (championed by 20th-century composer Arnold Schoenberg and explored by many other composers since then). Many pieces (most of them extremely dissonant and atonal) by these composers are now in the standard repertoire of 20th-century classical music.

share|improve this answer
Fascinating answer. I had no idea so much research went into algorithmic composition before computers exist, and I'm excited to try Mozart's dice game! – evanrmurphy Nov 6 '12 at 19:27
Are fractals any good ? I dont find their output to be any better than random . Mozarts dice game is pretty amazing. – coderboy Nov 7 '12 at 15:57

well, what I've done so far (I'm prototyping in perl and if it's useful, moving it to c++) is make chord progressions following this:

Giving the chords a certain number of beats,

And putting the chords into certain rhythm arrangements that'll still fit a real pair of hands. As in

That's as far as I've got. But there is a world of possibilities if ya ask me.

share|improve this answer

I also recommend looking into Supercollider

SuperCollider is an environment and programming language for real time audio synthesis and algorithmic composition. It provides an interpreted object-oriented language which functions as a network client to a state of the art, realtime sound synthesis server.

It is open-source, with good community support and powerful compositional and synthesis methods.

share|improve this answer

You mention that you are really impressed with, but that you didn't know the author's techniques. Here's the underlying code (not mine) on Github:

share|improve this answer

My opinion is that you can not use music theory for music composition to create some algorithms that produce music understandable by humans. My view (opinion) is that I should not look at music composition like a programmer; a programmer does a very different job. Like in number theories, you can create patterns with Algorithms, but does it sound great? does an arpeggiator sound great? Sure, but is it composing something? Why are some piano players great and some not so great if they are playing the same notes? Music works on so many layers that until now, no music instrument builder has developed a Turing machine-like approach like they have in computer science.

I think Algorithm composing is the wrong tool for this job.

  1. Experimental music

You do not want to make music that's based on something that's not new or known to us and an Algorithm could only work with known solutions (Determinism problem).

You cannot prove some thing in music; music has no right or wrong state. What is the right state in music? How can an Algorithm prove that it has produced a good music piece when the problem is deeper. Music is an experience thing without meaning; it is like feeling something. Until now, we do not have some thing like AI. All we got are some pattern recognition algorithms that can see patterns; you can't make music without Consciousness.

  1. Historical music (pop music pattern , rock, techno , baroque, etc.)

There are known pattern for this music. Music theory is not something that is creating those patterns; music theory is more an analytical approach.

Maybe I can recommend you the book of Roger Penrose, "The Emperor's New Mind"

Penrose presents the argument that human consciousness is non-algorithmic, and thus is not capable of being modeled by a conventional Turing machine-type of digital computer.

I think consciousness is a Precondition to create human understandable music or you can not produce Culture without the human factor.

Well, I'm not sure if you can get my point.

To shorten it up:

Music theory is more an analytical approach, but you have to have some data to analyse (limits of music theory -> lack of Creativity)

Know the limits of an Algorithm (like

If you know these limits, you can get good tools to produce.

share|improve this answer
Please read this and tell me if you still hold the same opinion – coderboy Nov 10 '12 at 19:29
My opinion does not change after reading this page & i have used notes generators -> and , i also like the karma-labs stuff but this not change my opinion on this topic, since i have read the in c intrucions from terry riley (…) and the writings of the stockhausen and the records of Iannis Xenakis i am a pretty fan of rules and orders in music but this does not reduce the human factor which needs consciousness – martin rudowski Nov 10 '12 at 22:39
bad example of Algorithms for music composition – martin rudowski Nov 10 '12 at 22:50
As a programmer learning to compose, the whole point of exploring algorithmic composition is not to replace the composer, but to better understand music, human perception, the basic rules and some of the principles and workflows used by composers to create music. Given enough algorithms and guiding rules used by composers to explore, I might finally be able to come up with my own understanding of what works and what doesn't, and perhaps be able to devise my own workflows and principles of composition. – JBeurer Jan 7 '13 at 19:01
-1 While I agree that music is art and composers cannot be replaced by machines, creating an algorithm to generate music is itself a form of composition, and one that, as the other answers can attest, is receiving quite a bit of attention. – Kevin Feb 17 '15 at 0:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.