summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2013-06-07 16:33:53 +0200
committerJohn Glover <j@johnglover.net>2013-06-07 16:33:53 +0200
commit5fa3a7b126c169bd5c3607cbbd503b002093e2ca (patch)
tree1e919cbcf882993b99985bce44ef873ff41f9c49 /tests
parentd60bbc935a1c7137c766792bf569ea7d6800fba9 (diff)
downloadsimpl-5fa3a7b126c169bd5c3607cbbd503b002093e2ca.tar.gz
simpl-5fa3a7b126c169bd5c3607cbbd503b002093e2ca.tar.bz2
simpl-5fa3a7b126c169bd5c3607cbbd503b002093e2ca.zip
Fix memory leaks in partial tracking processes
Diffstat (limited to 'tests')
-rw-r--r--tests/test_partial_tracking.cpp57
-rw-r--r--tests/test_partial_tracking.h4
2 files changed, 61 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
diff --git a/tests/test_partial_tracking.h b/tests/test_partial_tracking.h
index bd59b7f..c548984 100644
--- a/tests/test_partial_tracking.h
+++ b/tests/test_partial_tracking.h
@@ -39,7 +39,9 @@ protected:
class TestSMSPartialTracking : public CPPUNIT_NS::TestCase {
CPPUNIT_TEST_SUITE(TestSMSPartialTracking);
CPPUNIT_TEST(test_basic);
+ CPPUNIT_TEST(test_change_num_partials);
CPPUNIT_TEST(test_peaks);
+ CPPUNIT_TEST(test_streaming);
CPPUNIT_TEST_SUITE_END();
public:
@@ -51,7 +53,9 @@ protected:
SndfileHandle _sf;
void test_basic();
+ void test_change_num_partials();
void test_peaks();
+ void test_streaming();
};
// ---------------------------------------------------------------------------