To obtain the frequency spectrums of each note, we must take the time domain signal and apply the FFT algorithm to it. The FFT is widely used in most of the data and proccesing systems, it it a fundamental tool for many engineering applications.
A fast Fourier transform (FFT) algorithm computes the Discrete Fourier Transform (DFT) of a sequence, or its inverse. Fourier Analysis converts a signal from its original domain (often time or space) to a representation in the frequency domain. An FFT rapidly computes such transformations by factorizing the DFT matrix into a product of sparse (mostly zero) factors.As a result, it manages to reduce the complexity of computing the DFT from O(n^2) which arises if one simply applies the definition of DFT, to O(n\log n), where n is the data size.
In Matlab, Y = fft(X) implements the Fourier transform of a vector. For X and Y of length n, this transform is defined as follows: