Question: mozart _ walz _ generator playwaltz . py , line 4 6 , in stdaudio.playFile ( filename ) File . . .
mozartwalzgeneratorplaywaltzpy line in
stdaudio.playFilefilename
File stdaudio.py line in playFile
a readf
File stdaudio.py line in read
temp.appendfloatsamplesi floatxfff
TypeError: only length arrays can be converted to Python scalars
import stdio
import stdaudio
import sys
# readAllInts is already a list, store our input in measures
measures stdio.readAllInts
# write an if statement if the input is no equal to also use lenmeasures to check the number of input
# if not equal to print the message by using sysexit
if lenmeasures:
# write the message if not equal to
sysexitstrA waltz must contain exactly measures"
# write for i in range from measures to measures because we want to check the first value is from minuet measure
for i in range:
# write if is not between and
if not measuresi:
# if not we print a status say it must between and
sysexitstrA minuet measure must be from
# write for loop i in range form to the last elements that we want to access
for i in range:
# we use if statement to check is the value between and
if not measuresi:
# if not between, we print a status say it must between and
sysexitstrA trio measure must be from
# set a for loop v in range from to we want at to have the first value
for v in range:
# we store the value in waltz each time
waltz measuresv
# we set the file name
filename fdataMwaltz
# we use stdaudio.playFile to play the music which choose from Mwav
stdaudio.playFilefilename
# set a for loop v in range from to we want at to have the last value
for v in range:
# we store the value in trio each time
trio measuresv
# we set the file name
filename fdataTtrio
# we use stdaudio.playFile to play the music which choose from Twav
stdaudio.playFilefilename
Part II Mozart Waltz Generatorcdot Problem Playing the Waltz
playwaltz.py
Standard input
a sequence of measures of a waltz
Standard audio the waltz
~workspacemozartwaltzgenerator
python generatewaltz.py datamozarttxt python playwaltz.py
Part II Mozart Waltz Generatorcdot Problem Playing the Waltz
Set measures to a list of ints representing measures of a waltz read from standard input use stdio.readAliInts
Exit the program with the message "A waltz must contain exactly measures" if measures does not contain values use sysexit
Exit the program with the message "A minuet measure must be from if the any of the first values of measures is not from the interval use sysexit
Exit the program with the message "A trio measure must be from if the any of the last values of measures is not from the interval use sysexit
For each v of the first values in measures
Set filename to "dataMv
Play the audio file with the name filename use stdaudio.playFile
For each v of the last values in measures
Set filename to "dataTv
Play the audio file with the name filename use stdaudio.playFile
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
