From d91fc3a5b7b9d7a4ca85882b029fefe2c8daa156 Mon Sep 17 00:00:00 2001 From: John Glover Date: Sat, 16 Feb 2013 15:22:46 +0000 Subject: [mq] Add C++ implementation of TWM --- tests/test_peak_detection.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/test_peak_detection.cpp') diff --git a/tests/test_peak_detection.cpp b/tests/test_peak_detection.cpp index 3cb9c1a..e0eba9e 100644 --- a/tests/test_peak_detection.cpp +++ b/tests/test_peak_detection.cpp @@ -71,6 +71,28 @@ void TestMQPeakDetection::test_find_peaks_change_hop_frame_size() { } +// --------------------------------------------------------------------------- +// TestTWM +// --------------------------------------------------------------------------- +void TestTWM::test_basic() { + int num_peaks = 100; + int base_freq = 110; + Peaks peaks; + + for(int i = 0; i < num_peaks; i++) { + Peak* p = new Peak(); + p->amplitude = 0.4; + p->frequency = base_freq * (i + 1); + peaks.push_back(p); + } + + CPPUNIT_ASSERT_DOUBLES_EQUAL(base_freq, twm(peaks), PRECISION); + + for(int i = 0; i < num_peaks; i++) { + delete peaks[i]; + } +} + // --------------------------------------------------------------------------- // TestLorisPeakDetection // --------------------------------------------------------------------------- -- cgit v1.2.3