pub fn flatness_sfx(envelope: &[f32]) -> Result<f32, AudioError>Expand description
FlatnessSFX of an amplitude envelope: the ratio of its geometric mean to
its arithmetic mean, computed over the rectified (absolute) values. The
result lies in [0, 1]: a perfectly flat envelope returns ≈ 1, while a
spiky, impulsive envelope returns a value near 0.
A tiny floor is added before the log to keep the geometric mean finite for envelopes that contain exact zeros.
§Errors
AudioError::InvalidParameterif the envelope is empty or its arithmetic mean is zero.