CSC111 Homework 7

From CSclasswiki
Jump to: navigation, search

--Thiebaut 15:15, 24 March 2009 (UTC)

Homework #7

This assignment is due next monday night (3/30/09), at midnight.

For the homework, hand in only

  • Your .py file
  • Your resulting .wav file

Do not hand in any .pylog, .pybak, or any other files. Please name the files with your first initial, last name, and HW7. For example, my files would be and DThiebautHW7.wav. Please put your files into a folder with your first initial and last name and HW7: 'DThiebautHW7' as the folder name, with the two files inside this.

The program you hand in must be well-organized, with clear and concise comments, and enough white space (blank lines) to make it easy to read. Be sure to include your name(s), CSC 111 HW7, the date, and a general program description in the comments at the top of the program.

Here is a suggestion for loading the two files in your program:

def main():
  fileName1 = r"\\rescent\pc\COURSES\CSC\CSC111\Sound Files\thisisatest.wav"
  sound1 = makeSound( fileName1 )
  blockingPlay( sound1 )
  fileName2 = r"\\rescent\pc\COURSES\CSC\CSC111\Sound Files\e4.wav"
  sound2 = makeSound( fileName2 )
  blockingPlay( sound2 )


Write a program that starts with two sound files, thisisatest.wav and e4.wav, and creates a composite of the two.

Your program will create and save to disk a new wave file that is 6 seconds long, and that contains the sentence "A test this is", where the words are taken from the original thisisatest.wav file, and there is not delay between the words. In other words there shouldn't be a long delay between the words, as exists in the original file.

Furthermore, the sentence will be normalized, and the wave file will contain an echo. That means that the sentence "A test this is" overlaps with itself many times, at fixed intervals of 10,000 samples.

The first echo, which will start at index 10,000, will be half the intensity of the original waveform. The second echo, which will start at Index 20,000 will be a quarter of the amplitude of the samples from the original waveform, and so on.

Finally, your program will add the contents of the first half of the e4.wav file to the end of your 6-second waveform.


You can listen to an example of what your finished wav file will sound like: CSC111Hw7Demo.wav

Note that the demo says "This a test is", while your file should say "a test This is."


Make your program compute the various quantities that are needed rather than using the actual integer number in your program. If you use actual numbers your program cannot work with files that may be different in length or contents from the two you're working with for this assignment. Making programs work with different files without having to change them is a great feature.

For example, when placing the first half of e4.wav at the end of the 6-second waveform, you should make your program compute the length of the e4.wav file, the length of the 6-second wav file, and figure out at what index to start copying e4.wav into the larger file.

General algorithm

Here is a graphical representation of what you need to do, along with a general algorithm (steps you need to take) on the right hand side.

CSC111 hw7 algorithm.png