Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please go off by the code I include, make any edits or corrections, python only, I already have problem 1 answered. The problem 2 code

Please go off by the code I include, make any edits or corrections, python only, I already have problem 1 answered. The problem 2 code should play the music which is already stored in the data.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Project 3 (Mozart Waltz Generator) This document only contains the project problems. For the programming exercises on concepts needed for the project, please refer to the project checklist. Goal The purpose of this project is to write a program to generate a two-part waltz by pasting together 32 of 272 pre- composed musical elements at random, and another program to play the waltz. In 1787, Wolfgang Amadeus Mozart created a dice game (Mozart's Musikalisches Wrfelspiel). In the game, you compose a two part waltz by pasting together 32 of 272 pre-composed musical elements at random. The Waltz The waltz consists of two parts the minuet and the trio. Each is comprised of 16 measures, which are generated at random according to a fixed set of rules, as described below. Minuet The minuet consists of 16 measures. There are 176 possible minuet measures, named M1.wav through 1176.wav in the data directory. To determine which one to play, roll two fair dice, and use the following table: 1 2 3 9 10 11 12 13 14 15 16 2 4 5 6 7 8 9 10 11 12 96 32 69 40 148 104 152 119 98 3 54 22 6 95 17 74 157 60 84 142 87 130 141 128 158 113 163 27 171 114 42 165 10 41 63 13 85 45 167 53 50 156 61 103 105 146 153 161 80 154 99 140 75 135 28 122 46 55 2 97 68 133 86 129 47 37 11 134 110 159 36 118 21 169 62 147 106 30 81 24 100 107 91 127 70 117 66 90 25 138 16 120 65 102 35 121 39 139 176 143 71 155 88 77 4 20 26 9 9 126 56 15 132 7 34 64 125 150 29 57 175 48 166 19 82 31 164 108 92 112 174 73 67 76 101 43 51 137 144 12 49 18 58 160 136 162 168 115 38 59 124 109 116 145 52 1 23 89 72 149 173 44 14 83 79 170 93 151 172 111 8 78 131 94 123 33 For example, if you roll a 4 and 6 for measure 8, then play measure 123 (ie, data/1123.wav). Trio The trio also consists of 16 measures. There are 96 possible trio measures named T1.vay through 196.wav in the data directory. To determine which one to play, roll one fair die, and use the following table: 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 72 6 59 2 56 82 42 3 75 39 54 40 73 16 5 83 3 28 6 18 45 62 25 81 41 89 74 14 7 26 1 65 43 15 68 29 55 2 53 37 17 44 38 4 27 52 13 36 5 71 76 20 80 9 34 61 22 67 70 63 85 94 11 92 46 79 64 84 93 48 49 77 32 96 24 86 30 95 19 8 35 47 69 58 90 57 87 33 12 23 50 51 60 78 66 88 21 10 91 31 For example, if you roll a 4 for measure 29, then play measure 57 (ie, data/T57.wav). Data The 272 measures are available as .vav files in the data directory. The file dataozart.txt contains the values of the minuet and trio tables. Composition The file dataozart.wav is a sample waltz generated using the process described above. There are 1116 x 616 different possible results, some of which are more likely than others. Since this is over 1023 different possibilities, each time you play the game you are likely to compose a piece of music that has never been heard before! Mozart carefully constructed the measures to obey a rigid harmonic structure, so each waltz reflects Mozart's distinct style. Unfortunately, due to the rigidity, the process never results in anything truly extraordinary. Problem 2. (Playing the Waltz) Write a program called playvaltz.py that accepts from standard input, a sequence of 32 integers representing the 32 measures of a waltz, and plays the waltz to standard audio. Before playing any audio, your program must check if the inputs are correct, and if they are not, must call sys.exit(message) to exit the program with an appropriate error message. The following errors must be handled: If the number of measures is not 32, exit with the message "A waltz must contain exactly 32 measures". If a minuet measure is not from (1,176), exil with the message "A minuet measure must be from (1, 176)". If a trio measure is not from (1,96), exit with the message "A trio measure must be from (1, 96). >- */workspace/project3 $ python3 generatevaltz.py - */workspace/project3 $ python3 generatevaltz.py

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

What is Aufbau's rule explain with example?

Answered: 1 week ago