summaryrefslogtreecommitdiff
path: root/tests/test_partial_tracking.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_partial_tracking.cpp')
-rw-r--r--tests/test_partial_tracking.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/test_partial_tracking.cpp b/tests/test_partial_tracking.cpp
index 2363c9d..31e0473 100644
--- a/tests/test_partial_tracking.cpp
+++ b/tests/test_partial_tracking.cpp
@@ -112,6 +112,34 @@ void TestSMSPartialTracking::test_basic() {
}
}
+void TestSMSPartialTracking::test_change_num_partials() {
+ int hop_size = 256;
+ int frame_size = 2048;
+ int num_samples = 4096;
+ int max_partials = 10;
+
+ _pd.clear();
+ _pt.reset();
+
+ _pd.hop_size(hop_size);
+ _pd.frame_size(frame_size);
+
+ _pd.max_peaks(max_partials);
+ _pt.max_partials(max_partials);
+
+ std::vector<sample> audio(_sf.frames(), 0.0);
+ _sf.read(&audio[0], (int)_sf.frames());
+
+ Frames frames = _pd.find_peaks(num_samples,
+ &(audio[(int)_sf.frames() / 2]));
+ frames = _pt.find_partials(frames);
+
+ for(int i = 0; i < frames.size(); i++) {
+ CPPUNIT_ASSERT(frames[i]->num_peaks() == max_partials);
+ CPPUNIT_ASSERT(frames[i]->num_partials() == max_partials);
+ }
+}
+
void TestSMSPartialTracking::test_peaks() {
int num_frames = 8;
Frames frames;
@@ -145,6 +173,35 @@ void TestSMSPartialTracking::test_peaks() {
}
}
+void TestSMSPartialTracking::test_streaming() {
+ int hop_size = 256;
+ int frame_size = 2048;
+ int num_frames = 10;
+ int max_partials = 10;
+
+ _pd.clear();
+ _pt.reset();
+
+ _pd.hop_size(hop_size);
+ _pd.frame_size(frame_size);
+
+ _pd.max_peaks(max_partials);
+ _pt.max_partials(max_partials);
+
+ std::vector<sample> audio(_sf.frames(), 0.0);
+ _sf.read(&audio[0], (int)_sf.frames());
+
+ for(int i = 0, n = (int)_sf.frames() / 2; i < num_frames; i++, n += hop_size) {
+ Frame f(frame_size, true);
+ f.audio(&(audio[n]), frame_size);
+
+ _pd.find_peaks_in_frame(&f);
+ _pt.update_partials(&f);
+
+ CPPUNIT_ASSERT(f.num_partials() > 0);
+ }
+}
+
// ---------------------------------------------------------------------------
// TestLorisPartialTracking