This is a Python 3.6 implementation of Wolfgang Amadeus Mozart's "musical dice", which he claimed would allow someone without any knowledge of music to compose.
The idea is simple. Mozart gives a pool of 176 measures, of which 16 must be chosen for the final composition. Clearly, if these were to be chosen in a totally random way, the end result would not sound very good. Instead, for each measure, two 6-sided dice would be rolled, and the measure would be selected based on their sum:
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |
#1 | 96 | 32 | 69 | 40 | 148 | 104 | 152 | 119 | 98 | 3 | 54 |
#2 | 22 | 6 | 95 | 17 | 74 | 157 | 60 | 84 | 142 | 87 | 130 |
#3 | 141 | 128 | 158 | 113 | 163 | 27 | 171 | 114 | 42 | 165 | 10 |
#4 | 41 | 63 | 13 | 85 | 45 | 167 | 53 | 50 | 156 | 61 | 103 |
#5 | 105 | 146 | 153 | 161 | 80 | 154 | 99 | 140 | 75 | 135 | 28 |
#6 | 122 | 46 | 55 | 2 | 97 | 68 | 133 | 86 | 129 | 47 | 37 |
#7 | 11 | 134 | 110 | 159 | 36 | 118 | 21 | 169 | 62 | 147 | 106 |
#8 | 30 | 81 | 24 | 100 | 107 | 91 | 127 | 94 | 123 | 33 | 5 |
#9 | 70 | 117 | 66 | 90 | 25 | 138 | 16 | 120 | 65 | 102 | 35 |
#10 | 121 | 39 | 136 | 176 | 143 | 71 | 155 | 88 | 77 | 4 | 20 |
#11 | 26 | 126 | 15 | 7 | 64 | 150 | 57 | 48 | 19 | 31 | 108 |
#12 | 9 | 56 | 132 | 34 | 125 | 29 | 175 | 166 | 82 | 164 | 92 |
#13 | 112 | 174 | 73 | 67 | 76 | 101 | 43 | 51 | 137 | 144 | 12 |
#14 | 49 | 18 | 58 | 160 | 136 | 162 | 168 | 115 | 38 | 59 | 124 |
#15 | 109 | 116 | 145 | 52 | 1 | 23 | 89 | 72 | 149 | 173 | 44 |
#16 | 14 | 83 | 79 | 170 | 93 | 151 | 172 | 111 | 8 | 78 | 131 |
So, in total, the two dice will be rolled 16 times. When game.py
is run, a simulation of this is carried out, and the resulting waltz will be played through audio output.