APCO 1P00 - Week 3 Lecture Slides

# APCO 1P00 - Week 3 Lecture Slides - Week 3 More Sound...

This preview shows pages 1–10. Sign up to view the full content.

1 Week 3 More Sound, Conditionals, and Casting (Mostly from Chapters 7-8)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 A note on last weeks array issue: Before using a new array, we have to create it. Two options exist: myArray = range(1, 101) Would create a new array that looks like [1, 2, 3, 4, 5, etc.] myArray = [0] * 100 Would create a new array that looks like [0, 0, 0, 0, 0, etc.]
3 Example  (Walkthrough in Class) def normalize ( sound ): largest = 0 for s in getSamples ( sound ): largest = max( largest , getValue ( s )) multiplier = 32767.0 / largest for s in getSamples ( sound ): newValue = getValue ( s ) * multiplier setValue ( s , newValue ) play ( sound )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 What does max(a, b) do?? JES has a number of mathematical functions built in. max(a, b) takes in 2 (or more!) numbers as parameters, and returns the larger of the two. >>> someVar = max(25, 10) >>> print someVar 25 min(a, b) takes in 2 (or more!) numbers as parameters, and returns the smaller of the two.
5 def echo ( delay ): myFile = pickAFile () mySound = makeSound ( myFile ) newSound = makeSound ( myFile ) length = getLength ( mySound ) for index in range( delay + 1, length ): value = getSampleValueAt ( mySound , index - delay ) * 0.5 value2 = getSampleValueAt ( newSound , index ) setSampleValueAt ( newSound , index , value2 + value ) play ( newSound ) A more complicated example… We’ll walk through this on the next slide

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 mySound 1000 6880 -300 0 70 -10 1000 6880 -300 0 70 -10 newSound   ( using a delay of 2 ) 1000 6880 200 0 70 -10 1000 6880 200 3440 70 -10 1000 6880 200 3440 -80 -10 1000 6880 200 3440 -80 -10 1000 6880 200 3440 -80 -10 Initial State Index = 3 Index = 4 Index = 5 Index = 6 Final State
7 Merging Sounds Since sound is simply a series of waves, it is possible to create more interesting sounds by merging waves. Two compressions that meet, add together to make a larger compression. Two rarefactions that meet, add together to make a larger rarefaction. A rarefaction meeting with a compression cancel each other out (completely if the amplitudes are exactly opposite each other!)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 -1.5 -1 -0.5 0 0.5 1 1.5 1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 101 106 111 116 121 126 131 136 141 146 151 156 -1.5 -1 -0.5 0 0.5 1 1.5 8 15 22 29 43 50 57 64 78 85 92 99 113 120 127 134 148 155 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
9 Modern Music Synthesis On old music synthesizers, sounds were created by adding sine waves together (this is called Additive Synthesis).

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 38

APCO 1P00 - Week 3 Lecture Slides - Week 3 More Sound...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online