Skip to main content

log_spectral_distance

Function log_spectral_distance 

Source
pub fn log_spectral_distance(
    reference_mag: &[f32],
    degraded_mag: &[f32],
) -> Result<f32, AudioError>
Expand description

Log-spectral distance in dB between two magnitude spectra.

  • reference_mag: reference magnitude spectrum (|X_ref[k]|, linear, ≥ 0).
  • degraded_mag: degraded magnitude spectrum, same number of bins.

Each bin is converted to a power dB value 10*log10(mag^2 + eps) (equivalently 20*log10(mag) with a small floor to bound silence), and the result is sqrt(mean_k (dB_ref[k] - dB_deg[k])^2).

Returns AudioError::InvalidParameter if the slices are empty or of differing length.