CS 111 Lecture 10: LabNotes1 Change the pitch of a sound based on the value given by a parameter

51 views2 pages
30 Nov 2016
School
Course
Professor

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)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers