Skip to main content

energy_band_ratio

Function energy_band_ratio 

Source
pub fn energy_band_ratio(
    mag: &[f32],
    sample_rate: f32,
    f_lo1: f32,
    f_hi1: f32,
    f_lo2: f32,
    f_hi2: f32,
) -> Result<f32, AudioError>
Expand description

Ratio of the spectral energy in band 1 to that in band 2.

Both bands are evaluated over the one-sided magnitude spectrum mag with crate::features::spectral::energy_band(): the numerator is the energy in [f_lo1, f_hi1] Hz and the denominator the energy in [f_lo2, f_hi2] Hz. The result is E1 / E2, a scale-invariant balance measure (e.g. high-band vs low-band brightness).

Zero-heap: two passes, scalar result.

ยงErrors

  • Any error from energy_band for either band (bad sample_rate, too few bins, or malformed frequency bounds).
  • AudioError::InvalidParameter if the denominator band has zero energy (the ratio would be undefined).