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
```
You might also like to view...
Which of the following statements about cloud computing is true?
a) Cloud computing allows you to use software and data stored in the “cloud”—i.e., accessed on remote computers (or servers) via the Internet and available on demand—rather than having it stored on your desktop, notebook computer or mobile device. b) Cloud computing allows you to instantaneously scale your computing resources (e.g., storage and processing power) to meet their occasional peak levels, making it more cost effective than purchasing expensive hardware. c) Microsoft’s Windows Azure is a cloud computing platform that allows you to develop, manage and distribute your apps in the cloud. d) All of the above.
Answer the following statements true (T) or false (F)
Consider the following declarations as you determine if each of assignment statements 1 - 7 is valid. ``` #define HALF_CENT 50 #define A_SIZE 26 char a_list[HALF_CENT], b_list[HALF_CENT], a_char = 'v'; int nums[A_SIZE], vals[A_SIZE], i = 1; ``` 1. nums[0] = nums[25]; 2. nums = vals + 1; 3. a_list[50] = 'd'; 4. b_list[30] = 0.37 * vals[1]; 5. a_list = b_list; 6. nums[5] = (int)a_char 7. for (i = 1; i <= A_SIZE; ++i) nums[A_SIZE - i] = i;
What is the last step in the six step troubleshooting method covered in this chapter?
A. Plan the fix B. Resolve the problem C. Document D. Verify and prevent
Photoshop features an extensive ____________________ system that you can use to access definitions, explanations, and useful tips.
Fill in the blank(s) with the appropriate word(s).