/usr/share/SuperCollider/HelpSource/Classes/SpecFlatness.schelp is in supercollider-common 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | class:: SpecFlatness
summary:: Spectral Flatness measure
categories:: UGens>FFT
related:: Classes/SpecCentroid, Classes/SpecPcile
description::
Given an link::Classes/FFT:: strong::chain:: this calculates the emphasis::Spectral Flatness:: measure, defined as a power spectrum's geometric mean divided by its arithmetic mean. This gives a measure which ranges from approx 0 for a pure sinusoid, to approx 1 for white noise.
The measure is calculated linearly. For some applications you may wish to convert the value to a decibel scale - an example of such conversion is shown below.
classmethods::
method:: kr
argument:: buffer
an link::Classes/FFT:: chain.
examples::
code::
s.boot;
b = Buffer.alloc(s,2048,1);
(
{ // Example - vary mixture of white noise and pure tone with the mouse
var in, chain, flat, flatdb, flatdbsquish;
in = XFade2.ar(WhiteNoise.ar, SinOsc.ar, MouseX.kr(-1,1));
chain = FFT(b, in);
Out.ar(0, in * 0.1);
flat = SpecFlatness.kr(chain);
flatdb = 10 * flat.log; // Convert to decibels
flatdbsquish = LinLin.kr(flatdb, -45, -1.6, 0, 1).max(-10); // Rescale db roughly to 0...1.
flat.poll(10, "flatness: ");
flatdb.poll(10, "flatness (db): ");
Out.kr(0, [flat, flatdbsquish]);
}.scope;
)
(
{ // Now try with your own voice
var in, chain;
in = SoundIn.ar([0,1]).mean;
chain = FFT(b, in);
Out.kr(0, [in, SpecFlatness.kr(chain).poll(1, "flatness: ")]);
}.scope;
)
::
|