# Get frequency and amplitude from an audio sample [closed]

I'm wondering how can i get the frequency and the amplitude from a 16 bits sample. I have actually an array of 16 bits signed int and I would like to get the frequency and the amplitude of each sample. I've heard from FTT and stuff but I'm kinda new to signal processing about audio. Any advice would be appreciated,

Thanks.

• It would be better if you gave more information about the audio signal you're working with; then people could give more specific advice for you. Note that an audio signal (ex. recorded sound) is just an array of numbers. Each individual number is what we call a sample. Also note that the type of number (in your case, 16 bit signed int) will not affect your measurement of amplitdue and frequency. – goldrik Dec 18 '17 at 21:46

I'm wondering how can i get the frequency and the amplitude from a 16 bits sample

That makes no sense. A single sample is just a number.

A number doesn't have a frequency.

The number itself is the amplitude.

It depends of what you want: Do you want to write your own code, or just to find the solution? In the first case, you have to learn a lot: https://en.wikipedia.org/wiki/Fourier_transform, or simply use Matlab or Octave functions. They have very good help. If you want just to do some basic analysis, you may try with Audacity free tool that does have spectral analysis and will be able to load your file with samples.

• I want to write my own code that retrieves the frequency and magnitude at any time of the sound (with the SFML library in C++) – Ay0m3 Dec 18 '17 at 19:05
• OK, you have fftw.org FFTW library that does FFT. Some theory of FFT can be find all around the net, for example here: dspguide.com/ch12/2.htm – VladP Dec 18 '17 at 19:13
• Ye I was wondering if I could do that alone but I guess not then – Ay0m3 Dec 18 '17 at 19:37
• You may try it to do it from scratches, but there is a lot of theory to cover. Basically, FFT is a sum of sin and cos of the array of samples, multiplied by some coefficients. Try it first with someone else's functions. Also, if you like my answer, click up-vote. – VladP Dec 18 '17 at 20:36

I don't know if this will be helpful answer but a single sample can be considered as the following signal $x[n]=a\delta[n]$ just for $n=0$, then under this interpretation of a single sample the associated discrete-time Fourier transform will be: $$X(e^{j\omega}) = \sum_{n=-\infty}^{\infty} x[n] e^{-j\omega n} = \sum_{n=0}^{0} a e^{-j\omega n} = a$$

Hence we have $X(e^{j\omega})= a$ whose frequency is all (with a magnitude of a) and phase is zero...