Spectrum calculation

Anything you think is missing, or needs enhancement, goes here.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
parzival7
Posts: 3
Joined: Mon Oct 30, 2017 8:57 am
Operating System: Windows 10

Spectrum calculation

Post by parzival7 » Mon Oct 30, 2017 9:22 am

Hello,

I am struggling with units in dB on the vertical axis (y-axis) in the calculated spectrum in Audacity (say for a rectangular window). In my opinion the relevant formula for calculation is

20 * log10( [(2*Delta^2/T)|FFT|^2]^1/2) where Delta is the sampling interval (e.g. Delta = 1/fs = 1/44100) and T is the time of the segment of the FFT.

(I know that the real formula is more complicated due to averaging of neighbouring segments and windows etc).

My concern/question is about the constant since I am not able to reproduce the results by (say) MATLAB. I am obtaining the same shape of the spectrum but about 22 dB larger than Audacity (with 44100Hz and size 4096)

So my question is only about the norming 2*Delta^2/T = 2/(fs*N) (in this representation fs is the sampling rate, eg fs=44100Hz, and N is the number of data, eg N=4096).

Can please someone let me know what constant has been used in Audacity. Thank you very much. Kind regards.

steve
Site Admin
Posts: 47301
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Spectrum calculation

Post by steve » Mon Oct 30, 2017 12:14 pm

9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

parzival7
Posts: 3
Joined: Mon Oct 30, 2017 8:57 am
Operating System: Windows 10

Re: Spectrum calculation

Post by parzival7 » Mon Nov 06, 2017 10:39 am

I am referring to Plot Spectrum (if I understand it correctly the spectrogram view only provides the magnitude of the spectrum in colours and not in dB).


(sorry for the slow response - I missed to activate the button "Notify me when a reply is posted)

steve
Site Admin
Posts: 47301
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Spectrum calculation

Post by steve » Mon Nov 06, 2017 12:01 pm

The amplitude (dB) values in Plot Spectrum are normalized (scaled) such that a 0 dB (peak level) sine wave is plotted at 0 dB.

By implication, this means that if there are two sine waves, each with peak amplitudes of 0 dB, falling in the same FFT bin, then that bin will have a value of +3 dB.

Code: Select all

10 * log(1 + 1)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

parzival7
Posts: 3
Joined: Mon Oct 30, 2017 8:57 am
Operating System: Windows 10

Re: Spectrum calculation

Post by parzival7 » Mon Nov 06, 2017 6:45 pm

Thank you very much!! So I think this means that the Fourier transform is devided by window sum / 2 before taking the 10*log10()-transform.

Post Reply