pub mod knob;
pub mod meter;
pub mod band_strip;

pub fn band_freq_labels(freqs: &[f32; 5]) -> Vec<String> {
    let active = (0..5).filter(|&i| freqs[i] > 0.0).count() + 1;
    (0..6).map(|b| {
        if b == 0 { format!("<{}", fmt_hz(freqs[0])) }
        else if b >= active { "—".to_string() }
        else if b == active - 1 { format!(">{}", fmt_hz(freqs[b-1])) }
        else { format!("{}-{}", fmt_hz(freqs[b-1]), fmt_hz(freqs[b])) }
    }).collect()
}

fn fmt_hz(f: f32) -> String {
    if f >= 1000.0 { format!("{:.0}k", f/1000.0) } else { format!("{:.0}", f) }
}
