use core::num::NonZeroU32;
use mediatime::Timebase;
pub const SAMPLE_RATE_HZ: u32 = 16_000;
#[cfg_attr(not(tarpaulin), inline(always))]
const fn nz(n: u32) -> NonZeroU32 {
match NonZeroU32::new(n) {
Some(n) => n,
None => panic!("expected nonzero u32"),
}
}
const SAMPLE_RATE_NZ: NonZeroU32 = nz(SAMPLE_RATE_HZ);
pub const ANALYSIS_TIMEBASE: Timebase = Timebase::new(1, SAMPLE_RATE_NZ);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn analysis_timebase_is_one_over_16k() {
assert_eq!(ANALYSIS_TIMEBASE.num(), 1);
assert_eq!(ANALYSIS_TIMEBASE.den().get(), 16_000);
}
#[test]
fn sample_rate_constant_matches_timebase() {
assert_eq!(SAMPLE_RATE_HZ, ANALYSIS_TIMEBASE.den().get());
}
}