CS 111 Lecture 12: LabNotes3 Decrease the pitch of a sound

50 views2 pages
30 Nov 2016
School
Course
Professor

Document Summary

Def main(): fname = pickafile() s1 = makesound (fname); soundresult = increasepitch ( s1 ) explore (soundresult) def increasepitch ( sound ): # get a samplem list from the sound and the total number of samples samplelist = getsamples(sound) length = getlength(sound) sresult = makeemptysound ( length/2 ) 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 = i * 2 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+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Questions