CS 111 Lecture 10: LabNotes1 Change the pitch of a sound based on the value given by a parameter
Document Summary
Def main(): fname = pickafile() s1 = makesound (fname); soundresult = modifypitch ( s1, 0. 80) explore (soundresult) def modifypitch ( sound , delta): # get a samplem list from the sound and the total number of samples samplelist = getsamples(sound) length = getlength(sound) sresult = makeemptysound ( int(length * delta) ) sresultlength = getlength(sresult) sresultlist = getsamples(sresult) # loop for all samples in the sound for i in range (0, sresultlength): # access the sample from position i in the sample list origi = int (i / delta) sample = samplelist[origi] # store the new amplitude value back into the sound modi = i rsample = sresultlist[modi] setsamplevalue (rsample, value) return sresult def reverse ( sound ): # get a samplem list from the sound and the total number of samples samplelist = getsamples(sound) length = getlength(sound) sresult = makeemptysound ( length ) sresultlist = getsamples(sresult)