## 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
parzival7
Posts: 3
Joined: Mon Oct 30, 2017 8:57 am
Operating System: Windows 10

### Spectrum calculation

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
Posts: 47301
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

### Re: Spectrum calculation

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

### Re: Spectrum calculation

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
Posts: 47301
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

### Re: Spectrum calculation

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)``