## Spectrum calculation

Anything you think is missing, or needs enhancement, goes here.

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

### 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.
parzival7

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

### Re: Spectrum calculation

steve

Posts: 46549
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

### 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)
parzival7

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

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

Posts: 46549
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

### Re: Spectrum calculation

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

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