CSCI-128 Coding for Problem Solving
Lab #7

Date: March 18, 2021
Due date: March 25, 2021

Question 1:

Complete the following function that take in input the sound and a percentage. The
percentage indicates how far into the sound to go before changing from increasing to
decreasing the volume.

def increaseAndDecrease(sound, percentage):

Question 2:

Complete the following function. The function should normalize the first second of the sound,
then slowly decrease the sound in steps of 1/5 for each following second. getSamplingRate give
you the number of samples per second in a given sound.

def increaseAndDecrease2(sound):

Question 3:

Complete the following function. The function increases linearly the first half of the sound then
decrease linearly the sound until it reach 0 in the second half.

def increaseAndDecrease3(sound):

Question 4:

Transform the reverse function done in class to use the index array notation instead. The
beginning of the function is given:

def reverse2(source):
target = makeEmptySound(getLength(source))
targetSamples = getSamples(target)
sourceSamples = getSamples(source)
for sourceIndex in range(0,getLength(source)):

Question 5:

Transform the copy function done in class to use the index array notation instead. The
beginning of the function is given:

def copy2(source,target,start):
targetIndex = start
sourceSamples = getSample(source)
targetSamples = getSample(target)
for sourceIndex in range(0,getLength(source))

Question 6:

Transform the clip function done in class to use the index array notation instead. The beginning
of the function is given:

def clip2(source,start,end):
target = makeEmptySound(end - start)
sourceSamples = getSamples(source)
targetSamples = getSamples(target)
for targetIndex in range(0 ,getLength(target)):