forge
Explore
Log in

Don't you dare go Hollow

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 commit

55f05c3306d126462f828a77ea8b27874017cc69Ahmet Kaan GümüşParent: 9557dcb
crates/ec-dsp/src/mdct.rsmodified+4 -0
@@ -173,6 +173,10 @@ impl<T: Real> Mdct<T> {
173173 }
174174 }
175175
176+}
177+
178+#[cfg(test)]
179+impl<T: Real> Mdct<T> {
176180 /// Runs three overlapped frames of pseudo-random audio through
177181 /// analysis and synthesis with `window` and returns the worst absolute
178182 /// reconstruction error in the fully overlapped region.
crates/ec-dsp/src/window.rsmodified+16 -12
@@ -148,18 +148,6 @@ impl<T: Real> Window<T> {
148148 }
149149 }
150150
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- }
163151 }
164152
165153 /// Modified Bessel function of the first kind, order zero, by its power
@@ -181,6 +169,22 @@ fn bessel_i0(x: f64) -> f64 {
181169 sum
182170 }
183171
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+
184188 #[cfg(test)]
185189 mod tests {
186190 use super::*;