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]".

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education