There are a lot of good questions and answers on this subject on SO already, but a few general pointers:
- the spectrum of your sample will typically be time-varying
- you usually choose a window size (== FFT size) where there will be little short-term change in the spectrum, e.g. 10 ms (frequency resolution requirements may affect this choice), so if your sample rate is e.g. 44.1 kHz then you you might choose an FFT size of say 4096.
- the total sample is usually processed using successive windows (i.e. blocks of samples - these typically overlap, e.g. by 50%), so you actually get a sequence of time-varying spectra
- getting frequency info from spectra is covered by this excellent SO answer
- you need to apply a window function to each successive block of samples, prior to calculating the FFT
- the input to the FFT will be real values (from your block of samples) - if you use a normal complex-to-complex FFT then set the imaginary parts of the input to 0
- the output of the FFT will be complex values containing amplitude and phase information - for a real input the output is (conjugate) symmetric so only the first N/2 output bins are actually useful
- to get a dB magnitude value from an output bin use
mag_dB = 10 * log10(re*re + im*im)
- you can plot the sequence of output spectra as a spectrogram, using colour for dB magnitude, with frequency and sample block index (== time) as the two axes
See also: