Mozart's Dice Game

While browsing through some very very old Usenix proceeding papers, I stumbled upon one concerning the construction of a MIDI synthesizer program that play music on Unix systems. Having no other source of MIDI files, they turned to Mozart's dice game to write them some music. Curious, thought I--surely there should be some mention of such a program on the Internet. With a little research I found a sample implementation (offsite) which I decided to enhance for my own amusement. Evidently I start trying to deconstruct grammars out of everything when I'm bored and it's too cold in Portland to go out.

For those not familiar with Mozart's Dice Game, the brief version is that in 1787 Wolfgang Amadeus Mozart wrote out 176 measures that could be combined in various ways to generate a 16-measure minuet and a 16-bar trio. He also created a table specifying which measures could be used for a given measure. Players could then roll a pair of dice and select the appropriate measure from the table to compose a musical score that would sound roughly Mozartian. The program takes three key inputs--a table whose columns represent the possible measures and whose rows represent the measures; a list of MIDI instrument numbers, and the number of parts that will be featured in the score. A random number generator is used to select which parts and to write out a score for all parts. Other technical jibber jabber is used to sew some MIDI files representing the scores into one huge MIDI file that is the actual "work".

The format of the input files is very simple: For the measure configuration file, the first line is the number of measures that could be selected. The second line is the number of measures, and the rest of the file is a big table of comma separated numbers that represent the measures. Each of those numbers must correspond to a file "measures/Mnumber.mid". For the symphony configuration file, the first line is the number of instruments in the list, and what follows is a list of numbers that correspond to MIDI instruments. There of course must be a directory measures/ that contains the measures in MIDI format.

Asociated files: dice.c, Makefile, trio.csvminuet.csv (measure configuration files), piano_duo, piano_solo, string_trio (orchestra configuration files), measures/ (MIDI measures), some sample outputs, and a MIDI to MP3 conversion script if you have Timidity and lame installed.

Copyright ©1996-2017, Darrick Wong. All Rights Reserved. Send feedback.