Recorded myself playing C3, E3, and G3 on the piano and then a Cmajor tonic chord (all three together).

Then, imported the audio to my computer using librosa.

Let's play around with the Fourier Transform!
Here's the waveform for the whole video
As you can see, each note's amplitude decays as a function of time, so we can divide out the envelope, to get a roughly uniform wave over the relevant time interval
Now we take the Fourier Transform of the normalized amplitude.

But, what is the Fourier Transform? Roughly, it takes in your signal as input and spits out a "recipe" to reconstruct the signal using sines and cosines of different frequencies
Here's the Fourier Transform for the first note (C3):

According to Wikipedia the base frequency for C3 is 130.8 Hz. But look! It's not just that frequency that shows up in the "recipe", there are a bunch of other frequencies as well! These are called the "overtones"
E3 and G3 have this property as well.

In general, the overtones for any note correspond to an octave above, an octave and a fifth above, two octaves above, two octaves and a third above, two octaves and a fifth above, etc.

Here are the FTs of E3 and G3:
Note: the notes plotted in colors are pulled directly from piano key frequencies on Wikipedia, not built in to the analysis at all!

The only necessary assumption for the analysis was getting the iPhone headphone sampling frequency right (22.05 kHz)
And now, the pièce de résistance:

Here's the FT of the full Cmajor chord!
Keep in mind the only notes I *played* in the chord were C3, E3 and G3, but those notes together contain *all* of these frequencies within them. This full overtone series (and the rest of the spectrum, really) is what gives a piano its distinctive sound.
Even better, using only the most powerful notes in the spectrum, you can do a reasonably good job reconstructing the waveform for an individual note!

Here's the reconstructed waveform for C3 (5 cycles) with the top 5 strongest frequencies
. @3blue1brown, thought you might like this.

If anyone hasn't seen them, check out @3blue1brown's videos on music and measure theory, and the Fourier Transform!

Also, shout-out to @FiveThirtyEight for the Matplotlib plot style builtins. Makes everything look great with zero effort.
https://twitter.com/dcwych/status/1231333310187524096?s=20
You can follow @dcwych.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: