Fourier Transform: Musical instruments

1.2k Views Asked by At

How do I Fourier Analyse the music produced by a musical instrument? What I mean is that what tools/applications are best suited to Fourier Analyse waves from musical instruments?

1

There are 1 best solutions below

2
On BEST ANSWER

Since I'm a Matlab user, here's how I would do it. A lot of professional audio suites have Fourier analysis built in, they just call it "spectrum analysis".

  1. Record the instrument using an audio recording software such as Audacity. Or, you could just record a cell phone video, then use one of many applications to extract audio from cell phone videos (do a Google search to find one).
  2. Export the audio as a .wav or .mp3 file (at least, these are the most common).
  3. Import the .wav file into Matlab using the audioread function. This will represent your (digitized) music as a vector, where each element in the vector is a single digital sample. For example, a .wav file will have 44,100 samples for every second of audio - i.e. your vector will live in $\Bbb{R}^{44,100\cdot T}$ if your audio is mono (as opposed to stereo) and $T$ seconds. Actually, digital audio is also quantized, meaning you don't get an actual real number for each sample, but rather an integer.
  4. Once you have this vector, you can then run whatever Fourier analysis you want - fft, wavelet transforms, etc.

    If you don't have Matlab, octave and python have similar packages for working with audio files (a quick Google will let you know what's out there).

Here's a quick example using Radiohead's song "Burn the Witch". I imported it using audioread('file.mp3'). This gives me a matrix $x$ that is $9728781\times 2$ (two columns because it's a stereo recording). Here's a plot of the first second of the song - one channel is blue, the other is red.

enter image description here

I can do an FFT on this vector by calling $X = fft(x)$. Here's a plot of the modulus of $X$:

enter image description here

Now that your song is just a vector, you can do all sorts of fun things like filter it, use it as the initial condition for a heat equation and see what the result sounds like, you dream it!