# Relation between samplingrate and frequency

I am working on Fourier Transformation, and applying this for recognizing an audioclip.

I have a 9 second long audio clip of a guitar strumming an A-Minor. The audioclip has a sampling rate of 44100 Amplitudes per second, and a bitdepth of 16 bits.

I do a fourier Transform of the audiofile(green graph), and get a spectrum where the samples are the x-axis. I want to have frequencies along the x-axis, for being able to recognize the pitches, so I again can recognize the chord that is being played.

Instead I get samples. How can I convert this to frequency?

Here is a photo of my spectrums, one of them zoomed in on the samples from 0 to 10 000.

You're looking at a full spectrum as displayed on the second figure where the second half is a flipped replica of the first half. You're doing a DFT to get your spectrum; by definition the frequency spacing between each of your DFT samples will depend on the length $N$ of the Discrete Fourier Transform (DFT). For a length-$N$ DFT the frequency $f_k$ in $\rm Hz$ corresponding to DFT sample $k$ is given by $$f_k = \frac{F_s}{N}k, \quad k=0, 1, \ldots, N-1.$$ You have samples on $x$-axis as $k$, you have $F_s = 44100\ \rm Hz$, then check the $N$ (i.e. $NFFT$) used in your spectrum computation and you have your frequencies in $\rm Hz$.

• +1 even though you're not the real Gilles. Nov 13 '17 at 1:49

you have 9 $\times$ 44100 = 396900 samples. I assume you did a single FFT and you should take the first , 198450 complex points for your plot after taking the magnitude square. The last 198450 points out of the FFT are a mirror image of the first 198450 points so you can neglect them. The first kept point corresponds to $f=0$ and the last kept point to $f=22050$ Hz. which makes each bin .1111 wide

• Right. For brief explanation: the latter half of the spectrum actually corresponds to negative frequencies (wrapped around to the positive end, for reasons of convention), but a real-valued signal makes no distinction between positive and negative frequency, hence you might as well ignore the negative-freq amplitudes which are simply a mirror image of the positive ones. Nov 12 '17 at 23:52
• Each bin won't be necessarily $22050/(396900/2) = 0.1111\ \rm Hz$ unless OP is using the full length, which he does not mention. Nov 13 '17 at 0:00
• Thanks guys! I did do a DFT and then took the absolute value of the result for removing the complex values, for convenience of plotting the result. However, why will the last kept point be 22500Hz? What determines the upper limit? Nov 13 '17 at 1:29
• the data was sampled at 44100. 44100/2 =22500. Its called the Nyquist frequency.
– user28715
Nov 13 '17 at 1:31