Write a function that inputs a frequency, a maximum amplitude, and length in seconds. Create two sounds, one a square and one a triangle, using the same inputs. Add the sounds together. What do you get?
Note: The easiest way to create this function is to just call the squareWave and triangleWave (Chapter 9, Pages 271-272) functions individually.
You get a series of shapes halfway between a triangle and a square.
def combineShapeSounds(freq, amplitude, seconds):
```
square = squareWave(freq, amplitude, seconds)
triangle = triangleWave(freq, amplitude, seconds)
canvas = makeEmptySoundBySeconds(seconds)
for index in range(0, getLength(canvas)):
triSample = getSampleValueAt(triangle, index)
squareSample = getSampleValueAt(square, index)
newSample = triSample + squareSample
setSampleValueAt(canvas, index, newSample)
return canvas
```
Computer Science & Information Technology