3
$\begingroup$

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. enter image description here

$\endgroup$
4
$\begingroup$

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$.

$\endgroup$
4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – leftaroundabout Nov 12 '17 at 23:52
  • $\begingroup$ 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. $\endgroup$ – Gilles Nov 13 '17 at 0:00
  • $\begingroup$ 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? $\endgroup$ – Zimenez Nov 13 '17 at 1:29
  • $\begingroup$ the data was sampled at 44100. 44100/2 =22500. Its called the Nyquist frequency. $\endgroup$ – Stanley Pawlukiewicz Nov 13 '17 at 1:31
  • $\begingroup$ actually I made a mistake. 44100/2=22050. will fix in answer $\endgroup$ – Stanley Pawlukiewicz Nov 13 '17 at 1:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.