logo

Crowdly

Browser

Add to Chrome

Complete playthattune.py by selecting one of the given code snippets below. Th...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Complete playthattune.py by selecting one of the given code snippets below. The code snippet you select must enable playthattune.py to play the notes depicted in Figure A when it is executed. 

Voltooi playthattune.py deur een van die gegewe kode uitreksels te kies. Die kode uitreksel wat jy kies moet playthattune.py in staat stel om die note wat in Figuur A uitgebeeld word te kan speel wanneer dit uitgevoer word. 

#playthattune.py

import stdaudio

import

math

import stdarray

def playnotes(pitch, duration):

    sps =

44100

    n = int(sps*duration)

    for k in range(0,len(pitch)):

        hz =

440*math.pow(2,pitch[k]/12.0)

        a =

stdarray.create1D(n+1,0.0)

        for i in

range(0,n+1):

            a[i] =

math.sin((2*math.pi*i*hz)/sps)

       

stdaudio.playSamples(a)

    

def

main():

    #YOUR CHOSEN CODE SNIPPET GOES

HERE

    playnotes(A,0.5)

if __name__ == "__main__": main()

 

                                 Figure A/Figuur A

More questions like this

Want instant access to all verified answers on stemlearn.sun.ac.za?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome