Using map and filter, maximize a sound—if a sample’s value is greater than or equal to 0, make the sample value 32, 767, and if not, make it ?32, 768.
Note: Since filter will only return elements that meet the method requirements, its necessary to have two methods: one to capture positive samples, and one to capture negative samples.
```
def extremify(sound):
map(maximize,filter(positiveSample, getSamples(sound)))
map(minimize,filter(negativeSample, getSamples(sound)))
def maximize(sample):
setSampleValue(sample, 32767)
def minimize(sample):
setSampleValue(sample, -32767)
def positiveSample(sample):
val = getSampleValue(sample)
if val>=0:
return 1
else:
return 0
def negativeSample(sample):
val = getSampleValue(sample)
if val<0:
return 1
else:
return 0
```
You might also like to view...
Select the ________ option to have an action occur when the cursor points to an action button
Fill in the blank(s) with correct word
What are the three distinct categories of networking cabling?
What will be an ideal response?
Describe an Intrusion Detection System.
What will be an ideal response?
A bridge can selectively forward data packets.
a. true b. false