spectral flatness calculator
Spectral Flatness Calculator guide
Spectral flatness measures how evenly power is distributed among selected frequency bins. Enter a short list of nonnegative linear powers taken from one analysis frame. Choose the frequency band before computing the result and use the same bin selection for every comparison. A positive constant spectrum gives a reference value of one.
Play the instrument ↑- Default result
- 1 spectral flatness
Calculation and units
Divide the geometric mean of bin powers by their arithmetic mean. For positive bins the calculator averages their logarithms, subtracts the logarithm of the arithmetic mean and exponentiates the difference. This avoids multiplying a long sequence of disparate powers. The decibel result uses ten times the base-ten logarithm of the power ratio.
Worked examples
Select a named case in the Worked example control to load these values. You can then edit any input to compare the result.
Uniform positive powers
Linear bin powers = 1 1 1 1.
1 spectral flatness. Arithmetic mean power 1.00000. Geometric mean power 1.00000. Flatness in decibels: 0 dB over 4 bins.
Both means equal the common power. This is an exact finite-bin check and does not establish that an underlying signal is white noise.
Dominant single bin
Linear bin powers = 1 1 1 16.
0.4210526 spectral flatness. Arithmetic mean power 4.75000. Geometric mean power 2.00000. Flatness in decibels: -3.75664 dB over 4 bins.
Keep three bins fixed while increasing one. The arithmetic mean follows the large value more strongly than the geometric mean.
Scale all powers
Linear bin powers = 10 10 10 160.
0.4210526 spectral flatness. Arithmetic mean power 47.5000. Geometric mean power 20.0000. Flatness in decibels: -3.75664 dB over 4 bins.
Multiply every bin in the preceding peaked spectrum by ten. The two means scale together, leaving the flatness ratio unchanged.
One silent bin
Linear bin powers = 2 0 2 2.
0 spectral flatness. Arithmetic mean power 1.50000. Geometric mean power 0.00000. Flatness in decibels: −∞ dB over 4 bins.
An exact zero forces the product and the geometric mean to zero. This convention gives negative infinity when the ratio is expressed in decibels.
Two neighboring levels
Linear bin powers = 1 4.
0.8 spectral flatness. Arithmetic mean power 2.50000. Geometric mean power 2.00000. Flatness in decibels: -0.9691 dB over 2 bins.
These powers have a geometric mean of two and an arithmetic mean of two and a half. Dividing them gives a hand-checkable ratio.
Power floor comparison
Linear bin powers = 0.001 1 1 1.
0.2370249 spectral flatness. Arithmetic mean power 0.750250. Geometric mean power 0.177828. Flatness in decibels: -6.25206 dB over 4 bins.
Replacing an exact zero with a small floor changes the metric. Keep the floor convention consistent when comparing analysis systems.
Interpreting the result
Compare frames from the same transform length, window and band. A smaller ratio indicates more disparity among the selected powers. Sort order does not affect either mean, so flatness cannot tell where a peak lies. Combine the result with a plot or a frequency-location descriptor when two spectra have similar ratios but sound noticeably different.
Measurement and model limits
An exact zero gives a zero geometric mean provided another bin carries positive power. A wholly silent frame has no defined relative distribution here. Some analysis systems floor their power values before taking a logarithm, which changes low-level and silent-bin results. Apply the same explicit floor outside the calculator if matching such a system.
Answers before you play
Common questions
Can I paste a decibel spectrum?
Convert power levels to positive linear values first using ten raised to the power of the decibel value divided by ten. Negative decibel values are valid levels but unsuitable as direct powers.
What does one mean here?
Every selected positive bin has equal power. For a single positive bin this also yields one, even though it conveys no information about spectral shape across a band.
Can I enter FFT magnitudes?
Square nonnegative magnitudes first if a power-spectrum flatness is required. Flatness computed directly from magnitude can be a different descriptor.
Does a louder recording have lower flatness?
Uniform positive scaling cancels in the ratio. A changing noise floor, clipping, or different analysis settings can nevertheless change the relative powers across bins.