From 4d00d10a308c4a0337f56d4c95b5f62596bbb69e Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 21 Jan 2013 22:08:31 +0100 Subject: [partial_tracking,sms] Fix bug in SMS partial tracking. GetNextClosestPeak was missing peaks in some situations. Some general tidy up of SMS partial tracking code. --- tests/test_partial_tracking.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'tests/test_partial_tracking.cpp') diff --git a/tests/test_partial_tracking.cpp b/tests/test_partial_tracking.cpp index 4d7d7f6..b4872cd 100644 --- a/tests/test_partial_tracking.cpp +++ b/tests/test_partial_tracking.cpp @@ -48,7 +48,7 @@ void TestMQPartialTracking::test_peaks() { for(int i = 0; i < num_frames; i++) { Peak* p = new Peak(); - p->amplitude = 0.2; + p->amplitude = 0.4; p->frequency = 220; Peak* p2 = new Peak(); @@ -68,7 +68,7 @@ void TestMQPartialTracking::test_peaks() { for(int i = 0; i < num_frames; i++) { CPPUNIT_ASSERT(frames[i]->num_peaks() > 0); CPPUNIT_ASSERT(frames[i]->num_partials() > 0); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.2, frames[i]->partial(0)->amplitude, + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4, frames[i]->partial(0)->amplitude, PRECISION); CPPUNIT_ASSERT_DOUBLES_EQUAL(220, frames[i]->partial(0)->frequency, PRECISION); @@ -99,7 +99,9 @@ void TestSMSPartialTracking::setUp() { std::string(TEST_AUDIO_FILE)); } - _pt.realtime(1); + _pt.realtime(true); + _pt.max_frame_delay(2); + _pt.max_partials(5); } void TestSMSPartialTracking::test_basic() { @@ -136,7 +138,7 @@ void TestSMSPartialTracking::test_peaks() { for(int i = 0; i < num_frames; i++) { Peak* p = new Peak(); - p->amplitude = 0.2; + p->amplitude = 0.4; p->frequency = 220; Peak* p2 = new Peak(); @@ -153,10 +155,10 @@ void TestSMSPartialTracking::test_peaks() { } _pt.find_partials(frames); - for(int i = 0; i < num_frames; i++) { + for(int i = 1; i < num_frames; i++) { CPPUNIT_ASSERT(frames[i]->num_peaks() > 0); CPPUNIT_ASSERT(frames[i]->num_partials() > 0); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.2, frames[i]->partial(0)->amplitude, + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4, frames[i]->partial(0)->amplitude, PRECISION); CPPUNIT_ASSERT_DOUBLES_EQUAL(220, frames[i]->partial(0)->frequency, PRECISION); @@ -222,7 +224,7 @@ void TestLorisPartialTracking::test_peaks() { for(int i = 0; i < num_frames; i++) { Peak* p = new Peak(); - p->amplitude = 0.2; + p->amplitude = 0.4; p->frequency = 220; Peak* p2 = new Peak(); @@ -242,7 +244,7 @@ void TestLorisPartialTracking::test_peaks() { for(int i = 0; i < num_frames; i++) { CPPUNIT_ASSERT(frames[i]->num_peaks() > 0); CPPUNIT_ASSERT(frames[i]->num_partials() > 0); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.2, frames[i]->partial(0)->amplitude, + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4, frames[i]->partial(0)->amplitude, PRECISION); CPPUNIT_ASSERT_DOUBLES_EQUAL(220, frames[i]->partial(0)->frequency, PRECISION); -- cgit v1.2.3