U13: move Window::princen_bradley_error and Mdct::perfect_reconstruction_error into cfg(test); only ec-dsp's own tests call them
Browse files at this commit55f05c3306d126462f828a77ea8b27874017cc69Parent: 9557dcb2 changed files +20 -12
- crates/ec-dsp/src/mdct.rs +4 -0
- crates/ec-dsp/src/window.rs +16 -12
crates/ec-dsp/src/mdct.rsmodified+4 -0
| @@ -173,6 +173,10 @@ impl<T: Real> Mdct<T> { | ||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | +} | |
| 177 | + | |
| 178 | +#[cfg(test)] | |
| 179 | +impl<T: Real> Mdct<T> { | |
| 176 | 180 | /// Runs three overlapped frames of pseudo-random audio through |
| 177 | 181 | /// analysis and synthesis with `window` and returns the worst absolute |
| 178 | 182 | /// reconstruction error in the fully overlapped region. |
crates/ec-dsp/src/window.rsmodified+16 -12
| @@ -148,18 +148,6 @@ impl<T: Real> Window<T> { | ||
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - /// Worst deviation from the Princen-Bradley condition | |
| 152 | - /// `w[n]^2 + w[n + len/2]^2 == 1`, the property MDCT overlap-add needs. | |
| 153 | - pub fn princen_bradley_error(&self) -> f64 { | |
| 154 | - let half = self.samples.len() / 2; | |
| 155 | - (0..half) | |
| 156 | - .map(|n| { | |
| 157 | - let a = self.samples[n].to_f64(); | |
| 158 | - let b = self.samples[n + half].to_f64(); | |
| 159 | - (a * a + b * b - 1.0).abs() | |
| 160 | - }) | |
| 161 | - .fold(0.0, f64::max) | |
| 162 | - } | |
| 163 | 151 | } |
| 164 | 152 | |
| 165 | 153 | /// Modified Bessel function of the first kind, order zero, by its power |
| @@ -181,6 +169,22 @@ fn bessel_i0(x: f64) -> f64 { | ||
| 181 | 169 | sum |
| 182 | 170 | } |
| 183 | 171 | |
| 172 | +#[cfg(test)] | |
| 173 | +impl<T: Real> Window<T> { | |
| 174 | + /// Worst deviation from the Princen-Bradley condition | |
| 175 | + /// `w[n]^2 + w[n + len/2]^2 == 1`, the property MDCT overlap-add needs. | |
| 176 | + pub fn princen_bradley_error(&self) -> f64 { | |
| 177 | + let half = self.samples.len() / 2; | |
| 178 | + (0..half) | |
| 179 | + .map(|n| { | |
| 180 | + let a = self.samples[n].to_f64(); | |
| 181 | + let b = self.samples[n + half].to_f64(); | |
| 182 | + (a * a + b * b - 1.0).abs() | |
| 183 | + }) | |
| 184 | + .fold(0.0, f64::max) | |
| 185 | + } | |
| 186 | +} | |
| 187 | + | |
| 184 | 188 | #[cfg(test)] |
| 185 | 189 | mod tests { |
| 186 | 190 | use super::*; |