Skip to main content

log_spectrum

Function log_spectrum 

Source
pub fn log_spectrum(
    mag: &[f32],
    floor_db: f32,
    out_log: &mut [f32],
) -> Result<usize, AudioError>
Expand description

Convert a one-sided magnitude spectrum mag to a log-magnitude (dB) spectrum written into out_log.

Each bin becomes 20·log10(max(|X[k]|, floor_linear)) dB, where floor_linear = 10^(floor_db / 20). The floor bounds silent bins so their dB value clamps to floor_db instead of -inf.

Zero-heap: single pass into the caller-supplied out_log.

§Errors