CSC108H1 Lecture : september 23 notes
yifanyang and 39659 others unlocked
21
CSC108H1 Full Course Notes
Verified Note
21 documents
Document Summary
Import sound, generate copy of sound file w/o left channel. Sound song is unchanged. : import sound, def zero_left(song), song = sound. load_sound( doglake. wav , song_zeroed = zero_left(song) #or play directly: sound. play(zero_left(song), sound. play(song_zeroed) new_song = sound. copy(song) # makes a new copy for sample in new_song: sound. set_left(sample, 0) return new_song. Change song directly, no new file: import sound, def zero_left(song): for sample in new_song: Return sound song with the left channel turned off. sound. set_left(sample, 0) # no return new_song; left channel in song removed in memory: song = sound. load_sound( doglake. wav , song_zeroed = zero_left(song) #or play directly: sound. play(zero_left(song), sound. play(song_zeroed) Local song value same as the global sound value; changes made to the file in memory. Do not name a variable sound: import sound, sound = sound. load_sound( laught. wav ) # removes the sound library, sound. play(sound) Return a new copy of sound song with the left channel muted.