1

Suppose I want to write an application to compose music.

I'd like to feed a set of musical scores of a composer - e.g. Bach's Well tempered clavier' - and the program should prepare new scores in a similar style.

Are algorithms or even libraries known for this task?

WikiPedia provides this page about algorithmic music composition.

SteAp
  • 11,853
  • 10
  • 53
  • 88
  • 3
    This question is far too broad. There are doctoral dissertations written on this topic. Too big an answer to put here. You could literally fill up a home library with all the possible answers. – Jonathan M Nov 26 '11 at 22:08
  • @JonathanM I don't feel that it is broader than this popular and non-closed question - http://stackoverflow.com/questions/7540227/strategies-for-simplifying-math-expressions – SteAp Nov 26 '11 at 22:20
  • ... One could easily give an university level course on term rewriting system. Actually, users are often happy with non-complete ad hoc infos or broad information. So am I. Give a day for answers, please. – SteAp Nov 26 '11 at 22:27
  • Last comment: If only keep this question open for my elaborate answer of mathematical formula simplification / TRS http://stackoverflow.com/questions/7540227/strategies-for-simplifying-math-expressions/7542438#7542438 ... – SteAp Nov 26 '11 at 22:34
  • Glad you got an answer. Cheers. – Jonathan M Nov 27 '11 at 03:58
  • Quite unlikely, that much more are going to coming in... – SteAp Nov 27 '11 at 14:27

1 Answers1

5

You could make something basic using Markov chains. The principle is to first produce some unit of music (a single note, for example) and then, based on the last produced unit, randomly select the next unit.

First, pass through the input music. Each time you see a particular note/other unit of music, simply record in the table what came after it. When you have gone trough the entire input material, you will have a frequency table of which units follow which (After 'A', 'B' appeared 29 times, 'C' appeared 12 times and 'A' appeared twice; after 'B' ... etc).

Now select an initial note. Select the next one randomly according to the frequencies recorded in the table. Repeat until satisfied.

This will probably not yield good results if applied to individual notes, instead try short phrases. Also, the quality will improve if you have access to a large corpus of source music.

Viktor Dahl
  • 1,942
  • 3
  • 25
  • 36
  • 1
    Thx! I'm going to investigate Markov chains. – SteAp Nov 26 '11 at 22:21
  • Rick Taube discusses Markov chains in a chapter of _Notes from the Metalevel_. See the examples for that chapter in Lisp [here](http://www.moz.ac.at/sem/lehre/lib/cm/Notes%20from%20the%20Metalevel/19/markov.html). I implemented them in Python (included nth-order Markov chaining). It's on Github [here](https://github.com/curtisullerich/cmix/blob/master/metalevel/markov.py). – Curtis Jan 13 '13 at 21:50