[PD] [OT] spectral irregularity to measure noisiness (was Re: about fiddle~)

Jamie Bullock jamie at postlude.co.uk
Fri Jan 18 17:52:10 CET 2008


On Fri, 2008-01-18 at 15:47 +0100, matteo sisti sette wrote:
> Thank you very much :)
> 
> By the way, I have just tried Spectral Flatness (as defined in
> Wikipedia) and it seems promising.
> 
> I attach an abstraction that outputs spectral flatness in PD-vanilla.

That's not actually a correct implementation of spectral flatness. What
you've done is more like the arithmetic mean of the log-magnitude
spectrum over arithmetic mean of the mag spectrum. Whereas the SFM is
the _geometric_ mean of the mag spectrum over over its arithmetic mean.

The problem is that in order to obtain the geometric mean, you need to
ignore bins containing 0, otherwise you will get an overall value of 0
if there are '0 bins' present. See attached for a more 'correct'
implementation.

There is also an external that implements SFM in the CVS:

http://pure-data.cvs.sourceforge.net/pure-data/externals/postlude/flib/src/

See sfm~.c

However, the flib library in general is deprecated, and libxtract should
be used instead.


At any rate, both of the Pd implementations using [fexpr~] are horribly
inefficient, and SFM is inefficient to compute at the best of times
because it requires at least two iterations over the the input vector.
That's why I recommended Irregularity. It tells you roughly the same
thing, but is a nicer feature in terms of computation cost, and things
like avoiding NaNs and infs.

Jamie

-- 
www.postlude.co.uk
-------------- next part --------------
#N canvas 571 170 686 626 12;
#X obj 35 49 inlet~;
#X obj 26 148 *~;
#X obj 66 148 *~;
#X obj 26 189 sqrt~;
#X obj 24 392 snapshot~;
#X obj 192 393 snapshot~;
#X obj 192 426 / \$1;
#X obj 125 517 /;
#X obj 179 162 t b b b;
#X obj 174 103 bang~;
#X obj 121 594 outlet;
#X msg 116 194 clear;
#X text 292 23 \$1: block size;
#X obj 111 392 loadbang;
#X obj 111 420 f \$1;
#X obj 111 445 swap 1;
#X obj 121 480 /;
#X obj 295 82 block~ \$1;
#X obj 35 101 fft~;
#X obj 26 317 fexpr~ if($x > 0 && $x[-1] > 0 \, $x[-1] * $x \, 0);
#X obj 37 425 pow;
#X obj 124 556 expr 10 * log10($f1);
#X obj 419 318 fexpr~ $x[-1]+$x;
#X connect 0 0 18 0;
#X connect 1 0 3 0;
#X connect 2 0 3 0;
#X connect 3 0 19 0;
#X connect 3 0 22 0;
#X connect 4 0 20 0;
#X connect 5 0 6 0;
#X connect 6 0 7 1;
#X connect 7 0 21 0;
#X connect 8 0 11 0;
#X connect 8 1 4 0;
#X connect 8 2 5 0;
#X connect 9 0 8 0;
#X connect 11 0 19 0;
#X connect 11 0 22 0;
#X connect 13 0 14 0;
#X connect 14 0 15 0;
#X connect 15 0 16 0;
#X connect 15 1 16 1;
#X connect 16 0 20 1;
#X connect 18 0 1 0;
#X connect 18 0 1 1;
#X connect 18 1 2 0;
#X connect 18 1 2 1;
#X connect 19 0 4 0;
#X connect 20 0 7 0;
#X connect 21 0 10 0;
#X connect 22 0 5 0;


More information about the Pd-list mailing list