From 065ed900731fe668ab1216e83e66b84c63da2f8b Mon Sep 17 00:00:00 2001 From: Polochon_street Date: Fri, 13 Sep 2024 16:08:20 +0200 Subject: [PATCH] Write more tests --- TODO.md | 1 + src/temporal.rs | 10 ++++++++++ src/timbral.rs | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 5cc344a..ab896cf 100644 --- a/TODO.md +++ b/TODO.md @@ -35,6 +35,7 @@ ask questions if you want to tackle an item. Hopefully will make playlists not drift - Improve bliss-python somehow / use it in a small demo project maybe? A blissify in python? +- Investigate what type SAMPLE_RATE is in Aubio - maybe u16 is enough ## Done - Split out ffmpeg (see https://github.com/Polochon-street/bliss-rs/issues/63 and https://users.rust-lang.org/t/proper-way-to-abstract-a-third-party-provider/107076/8) diff --git a/src/temporal.rs b/src/temporal.rs index a66d3e1..4b2a84e 100644 --- a/src/temporal.rs +++ b/src/temporal.rs @@ -114,6 +114,16 @@ mod tests { assert!(0.01 > (0.378605 - tempo_desc.get_value()).abs()); } + #[test] + fn test_tempo_error_creating_aubio_tempo() { + assert_eq!( + BPMDesc::new(0).err().unwrap(), + BlissError::AnalysisError(String::from( + "error while loading aubio tempo object: creation error" + )) + ) + } + #[test] fn test_tempo_artificial() { let mut tempo_desc = BPMDesc::new(22050).unwrap(); diff --git a/src/timbral.rs b/src/timbral.rs index d80fbc5..83599d9 100644 --- a/src/timbral.rs +++ b/src/timbral.rs @@ -267,7 +267,7 @@ mod tests { #[test] fn test_zcr_boundaries() { - let mut zcr_desc = ZeroCrossingRateDesc::default(); + let mut zcr_desc = ZeroCrossingRateDesc::new(SAMPLE_RATE); let chunk = vec![0.; 1024]; zcr_desc.do_(&chunk); assert_eq!(-1., zcr_desc.get_value()); @@ -278,7 +278,7 @@ mod tests { .flatten() .cloned() .collect::>(); - let mut zcr_desc = ZeroCrossingRateDesc::default(); + let mut zcr_desc = ZeroCrossingRateDesc::new(SAMPLE_RATE); zcr_desc.do_(&chunks); assert!(0.001 > (0.9980469 - zcr_desc.get_value()).abs()); }