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

You might also like to view...

The OLE Object data type allows for cross-application editing

Indicate whether the statement is true or false

Computer Science & Information Technology

The heading lines of a memo are bold.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology