# Middle C

soundwave.py: 22 points

We’ve implemented a constructor for our SoundWave class, but now we need some way to save the tone we’ve generated. Let’s do this by adding a method called save(self, filename) to our Soundwave class. This method should take one parameter, filename, (in addition to self, since all methods take self as their first parameter). The save() method will need to make use of the audio.py module that has been provided to you.

The audio.py module contains several useful functions for converting your waveform samples into a format necessary for saving WAV audio files. Be sure to import audio at the top of your soundwave.py file. Note that you shouldn’t need to change any code in audio.py.

The audio module function that you’ll need to call is audio.save(filename, samples, sample_rate). As you can see in the function definition, this function requires you to pass a filename, self.samples, and self.sample_rate as arguments.

You should now be able to run the provided file middlec.py. When you run this program, it should create a new file in the Files pane on the left side of your replit project called middlec.wav. If you click on that file and push the play button (the triangle pointing to the right) in the middle of your browser, you should hear a single note (middle C) for approximately 2 seconds. If it works, great, continue onward! Otherwise you’ll need to track down some bugs.