第二份题目:
(请容我慢慢的看题目)
We will build on the functions provided to you in Lab 6. What is needed is a program that will attempt to smooth out the random noise present in a noisy sound file firstly by averaging two consecutive samples and then secondly by averaging three consecutive samples.
Write a program that will:
Using the functions from Lab 6, create a noisy sound by adding random noise to this sound file, but implement appropriate changes so that the given functions can be called by a main or calling program.
In the main program, adjust this noisy sound by creating a new current value, for each sample, based on the average of the previous sample and the current sample. The first sample can be averaged with an initial value of 0 for the "previous sample."
Now adjust the the same original noisy sound in part 1 by creating a new current value, for each sample, based on the average of the previoustwo samples and the current sample.The first sample can be averaged with an initial value of 0 for both the "previous samples."
In order to 'see' the sounds produced, invoke the function openSoundTool(sound) three times within your program, displaying the original noisy sound, then the smoothed sound from 2., and then finally the smoothed sound from 3. (There is no need to return any sound from the main/calling program.) For interest, here is a picture of the three windows, but tiled for convenience. Please press the 'Zoom In' button on each Sound Tool window, and ensure that the index is at 1 before copying the window, as this makes it easier to mark!
For submission, a single execution of your program could be:
>>> smoothSound(file, 2500)
where 'file' is the same sound file used in the lab 6, and the value of 2500 is the maximum amplitude for the added noise. For your submission, capture the output (Zoomed in, index at 1), in order, of the three invocations of the Sound Tool.