diff options
author | John Glover <j@johnglover.net> | 2013-06-07 16:33:53 +0200 |
---|---|---|
committer | John Glover <j@johnglover.net> | 2013-06-07 16:33:53 +0200 |
commit | 5fa3a7b126c169bd5c3607cbbd503b002093e2ca (patch) | |
tree | 1e919cbcf882993b99985bce44ef873ff41f9c49 /tests | |
parent | d60bbc935a1c7137c766792bf569ea7d6800fba9 (diff) | |
download | simpl-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.cpp | 57 | ||||
-rw-r--r-- | tests/test_partial_tracking.h | 4 |
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(); }; // --------------------------------------------------------------------------- |