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
```
You might also like to view...
What is an optimal substructure?
a. It contains solutions to sub-problems b. It is a priority queue c. It is an efficient hash table d. It determines the greedy choice
The Repeat: Until End of Slide is a timing option associated with animated shape placed on a ________
Fill in the blank(s) with correct word
In a worksheet, columns have numerical headings and rows have alphabetical headings
Indicate whether the statement is true or false.
What is an event listener?
What will be an ideal response?