pub fn spectral_complexity(
mag: &[f32],
threshold: f32,
min_distance: usize,
scratch_pos: &mut [f32],
scratch_mag: &mut [f32],
) -> Result<usize, AudioError>Expand description
Spectral complexity of a one-sided magnitude spectrum mag.
Complexity is the number of significant spectral peaks: local maxima at or
above threshold, no two closer than min_distance bins (the weaker of a
too-close pair is dropped). A pure tone yields ~1; a dense, noisy, or
polyphonic spectrum yields many. Implemented over
detect_peaks.
scratch_pos / scratch_mag are caller-supplied working buffers (they
receive the peak positions and magnitudes as a side effect); their common
length bounds how many peaks can be counted.
Zero-heap: all storage is caller-supplied.
ยงErrors
AudioError::InvalidParameterifthresholdis not finite.AudioError::OutputBufferTooSmallif more significant peaks are present than the scratch buffers can hold.