Generalize your general blend function even more. Take in the number of samples to use from the first sound before the blend begins and the number of samples to blend.

Note: The question does not specify the number of samples to use for the second sound, so the function below just uses the same number for the first sound. However, this is not required.

Additionally, this function needs to change the line that instantiates the canvas regardless of the value used in order to throw an error when it attempts to access an index that isn’t there.

```
def blend3(sound ,sound2, numSamples, numBlend):
canvas = makeEmptySound(numSamples*2+numBlend)
for index in range(0, numSamples):
soundSample = getSampleValueAt(sound,index)
setSampleValueAt(canvas ,index ,soundSample)
for index in range (0 ,numBlend):
soundSample = getSampleValueAt(sound,index+numSamples)
sound2Sample=getSampleValueAt(sound2,index)
newSample = 0.5* soundSample + 0.5* sound2Sample
setSampleValueAt(canvas ,index+numSamples,newSample)
for index in range (numBlend ,numSamples+numBlend):
sound2Sample = getSampleValueAt(sound2,index)
setSampleValueAt(canvas ,(index+numSamples),sound2Sample)
play(canvas)
return canvas
```

Computer Science & Information Technology

You might also like to view...

In OpenOffice Writer, ________ is the editing mode that tracks all changes made to a document

Fill in the blank(s) with correct word

Computer Science & Information Technology

Unless you specify a style for a document, Word uses the ________ style

A) Default B) Custom C) New D) Normal

Computer Science & Information Technology