CS 111 Lecture 16: LabNotes7 Example code to show how the break statement end a loop early

53 views2 pages
30 Nov 2016
School
Course
Professor

Document Summary

Def main(): fname = pickafile() s1 = makesound (fname) fname = pickafile() s2 = makesound (fname) soundresult = join ( s1, s2 ) explore (soundresult) savefilename = pickafile() writesoundto(soundresult, savefilename) def join( sound , sound2 ) : # get a samplem list from the sound and the total number of samples samplelist = getsamples(sound) length = getlength(sound) samplelist2 = getsamples(sound2) length2 = getlength(sound2) sresult = makeemptysound ( length + length2 ) sresultlist = getsamples(sresult) # loop for all samples in the sound for i in range (0 , length): # store the new amplitude value back into the sound modi = i rsample = sresultlist[modi] setsamplevalue (rsample, value) # loop for all samples in the sound for i in range (0 , length2): # access the sample from position i in the sample list sample2 = samplelist2[i] # get the amplitude value at the sample value2 = getsamplevalue (sample2)

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