Problem 2. (Playing the Waltz) Write a program called playwaltz.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 (zessage) 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], exit 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]".

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section4.3: Nested If Statements
Problem 7E
icon
Related questions
Question
Problem 2. (Playing the Waltz) Write a program called playwaltz.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], exit 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]".
- "/vorkspace/project3
$ python3 generatewaltz.py < data/mozart.txt | python3 playwaltz. py
Directions:
• Read the waltz measures from standard input into a 1D list.
• Handle the input errors described above.
• Play each of the first 16 minuet measures by calling stdaudio.playFile(f), where i is the filename of the minuet (eg, if the
measure is 123, then : = 'data/M123').
• Play each of the last 16 trio measures by calling stdaudio.playFile (f), where i is the filename of the trio (eg, if the measure
is 57, then : - 'data/T57').
Transcribed Image Text:Problem 2. (Playing the Waltz) Write a program called playwaltz.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], exit 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]". - "/vorkspace/project3 $ python3 generatewaltz.py < data/mozart.txt | python3 playwaltz. py Directions: • Read the waltz measures from standard input into a 1D list. • Handle the input errors described above. • Play each of the first 16 minuet measures by calling stdaudio.playFile(f), where i is the filename of the minuet (eg, if the measure is 123, then : = 'data/M123'). • Play each of the last 16 trio measures by calling stdaudio.playFile (f), where i is the filename of the trio (eg, if the measure is 57, then : - 'data/T57').
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning