Spectral flatness measure sign

with bufspectralshape~ and bufstats~ I am isolating the spectral flatness measure’s mean and median over a sound file. Is the dB value meant to be positive or should I interpret ‘24’, for example, as -24? Indeed, testing on obvious sound files (noise vs sin) and flipping the sign manually I get results I expect.

Sine:

25.272526 25.33378

Noise

8.154908 8.185095

Here I would defer to @groma : we could flip the division, in effect giving you a higher number for flatter signal indeed.

More flatness = bigger number makes sense to me. Aren’t you just converting a 0 to 1 value anyway where 1 is flat?

A sine is a peak in the spectrum so it is the opposite of flat, whereas noise is more flat. The ratio is indeed between 0 and 1 where 1 would be totally flat so 0dB. Here’s a wikipedia explanation:

The ratio produced by this calculation is often converted to adecibel scale for reporting, with a maximum of 0 dB and a minimum of −∞ dB.

This is my understanding of it, and what I see from implementing a the algo in something like FrameLib.

I don’t understand you question then. In the helpfile, test code, you get -103 for a sinewave (very low flatness) and -1.5 for white noise (very high flatness) - this is in line with the definition Gerard points at. Flipping the numbers will make it wrong. The way to get it positive would be to add 110. that way you sine would have a very low positive number, and your noise a very high positive number. I don’t know what you get though.

I don’t know what file you are referring to, but this is an error on my part with how I was doing bufstats :frowning:. I was in fact bufstatting the wrong channel. Is buffer channel referencing still 0 counting and not 1?

culprit is @startchan 6

1 Like

The spectralshape helpfile has a sexy tutorial (which doubles as sanity checker for me)…