diff --git a/crates/ec-dsp/src/mdct.rs b/crates/ec-dsp/src/mdct.rs index 86b545ec..ac600a19 100644 --- a/crates/ec-dsp/src/mdct.rs +++ b/crates/ec-dsp/src/mdct.rs @@ -173,6 +173,10 @@ impl Mdct { } } +} + +#[cfg(test)] +impl Mdct { /// Runs three overlapped frames of pseudo-random audio through /// analysis and synthesis with `window` and returns the worst absolute /// reconstruction error in the fully overlapped region. diff --git a/crates/ec-dsp/src/window.rs b/crates/ec-dsp/src/window.rs index 7c238c65..72fffd04 100644 --- a/crates/ec-dsp/src/window.rs +++ b/crates/ec-dsp/src/window.rs @@ -148,18 +148,6 @@ impl Window { } } - /// Worst deviation from the Princen-Bradley condition - /// `w[n]^2 + w[n + len/2]^2 == 1`, the property MDCT overlap-add needs. - pub fn princen_bradley_error(&self) -> f64 { - let half = self.samples.len() / 2; - (0..half) - .map(|n| { - let a = self.samples[n].to_f64(); - let b = self.samples[n + half].to_f64(); - (a * a + b * b - 1.0).abs() - }) - .fold(0.0, f64::max) - } } /// Modified Bessel function of the first kind, order zero, by its power @@ -181,6 +169,22 @@ fn bessel_i0(x: f64) -> f64 { sum } +#[cfg(test)] +impl Window { + /// Worst deviation from the Princen-Bradley condition + /// `w[n]^2 + w[n + len/2]^2 == 1`, the property MDCT overlap-add needs. + pub fn princen_bradley_error(&self) -> f64 { + let half = self.samples.len() / 2; + (0..half) + .map(|n| { + let a = self.samples[n].to_f64(); + let b = self.samples[n + half].to_f64(); + (a * a + b * b - 1.0).abs() + }) + .fold(0.0, f64::max) + } +} + #[cfg(test)] mod tests { use super::*;