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
//! Spectral flatness matching `librosa.feature.spectral_flatness`.
use crateMatrix;
/// Compute spectral flatness from a magnitude spectrogram.
///
/// Matches `librosa.feature.spectral_flatness(S=S, amin=amin, power=power)`.
///
/// Spectral flatness is the ratio of geometric mean to arithmetic mean
/// of the (power-raised, thresholded) spectrum per frame.
/// Values near 1.0 indicate noise-like signal, near 0.0 indicate tonal signal.
///
/// - `s`: magnitude spectrogram (rows = frequency bins, cols = frames).
/// Note: librosa internally computes magnitude (power=1.0) spectrogram,
/// so pass magnitude (not power) spectrogram.
/// - `amin`: minimum threshold for numerical stability (default: 1e-10)
/// - `power`: exponent applied to the magnitude spectrogram (default: 2.0)