Skip to main content

spectral_flux

Function spectral_flux 

Source
pub fn spectral_flux(prev: &[f32], cur: &[f32]) -> Result<f32, AudioError>
Expand description

Half-wave-rectified spectral flux between a previous and current magnitude spectrum.

Flux is the sum over bins of the positive part of the bin-to-bin change, Σ_k max(cur[k] - prev[k], 0). Only rising energy contributes, so the value is an onset-sensitive novelty: 0 for identical frames and strictly positive when spectral energy increases in any bin. This is the true per-bin flux (contrast with the frame-energy novelty used by music.rs).

prev and cur must be the same non-zero length (both one-sided magnitude spectra of the same FFT size).

Zero-heap: single pass, scalar result.

§Errors