Für Elise

soundwave.py: 22 points


Now that we can construct a note and save it as an audio file, we need some way to string notes together into a song. Add a method called extend(self, s2) to your SoundWave class. This method should take a single parameter s2—a second SoundWave object that will be concatenated to the end of the calling SoundWave object. To do this, you’ll want to add each of the numbers in the samples of s2 to the end of the samples of the self. In this way, we are chaining notes together into a single SoundWave object.

To add all of the values of s2.samples to self.samples, we can use the list’s extend function, which adds everything from one list into another without needing a for loop.

Playing Für Elise

You should now be able to run the provided file furelise.py. Running this program should create a new wave file called furelise.wav that you can play similar to the middlec.wav in the previous part of the lab.

Here’s what your file should sound like: