An Algebra for
Tree-Based Music Generation

About this project

We present an algebra whose operations act on musical pieces, and show how this algebra can be used to generate music in a tree-based fashion. Starting from input which is either generated by a regular tree grammar or provided by the user via a digital keyboard, a sequence of top-down tree transducers is applied to generate a tree over the operations provided by the music algebra. The evaluation of this tree yields the musical piece generated.


The music algebra has been realised in the software system Treebag. To try it out, first check that you have Java 5.0 SE installed on your computer. Second, download the files treebag.jar and jmusic.jar and type

java -cp :treebag.jar:jmusic.jar gui.worksheet

at the prompt. If everything works correctly, then this should bring up Treebag. To look at the examples, download and decompress the file examples.tar.gz. This results in two directories titled algebra/canon and algebra/variations, respectively, each containing a worksheet file. These worksheets can be loaded into Treebag by choosing the item Load in the Worksheet menu (which is found in the upper-left corner). To listen to the generated pieces, select Play Midi in the menu Show of the Music Display. For more information about Treebag, please see the systems homepage.

Download / Links

Treebag [jar]
JMusic [jar]
Examples [tar.gz]

Generated pieces
Variation 1 [mid]
Variation 2 [mid]
Variation 3 [mid]
Variation 4 [mid]
Canon 1 [mid]
Canon 2 [mid]

Treebag [html]
JMusic [html]

Last updated Jun 11 2007 by Johanna Högberg.