import numpy, scipy, matplotlib.pyplot as plt, pandas, librosa
Let's download and listen to a file:
import urllib
urllib.urlretrieve('http://audio.musicinformationretrieval.com/c_strum.wav')
x, fs = librosa.load('c_strum.wav', sr=44100)
from IPython.display import Audio
Audio(x, rate=fs)
The Fourier Transform is one of the most fundamental operations in applied mathematics and signal processing.
It transforms our time-domain signal into the frequency domain. Whereas the time domain expresses our signal as a sequence of samples, the frequency domain expresses our signal as a superposition of sinusoids of varying magnitudes, frequencies, and phase offsets.
To compute a Fourier transform in NumPy or SciPy, use scipy.fft
:
X = scipy.fft(x)
X_mag = numpy.absolute(X)
plt.plot(X_mag) # magnitude spectrum
Zoom in:
plt.plot(X_mag[:5000])
In Essentia, you can also use essentia.standard.Spectrum
to compute a magnitude spectrum.