From 44387fc6606057393b5026ce0d2707a016037347 Mon Sep 17 00:00:00 2001
From: John Glover <j@johnglover.net>
Date: Fri, 20 Jul 2012 17:46:30 +0100
Subject: [peak_detection] Add C++ implementation of SndObj peak detection.

---
 tests/test_peak_detection.py | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

(limited to 'tests/test_peak_detection.py')

diff --git a/tests/test_peak_detection.py b/tests/test_peak_detection.py
index f339818..cd124f0 100644
--- a/tests/test_peak_detection.py
+++ b/tests/test_peak_detection.py
@@ -5,6 +5,7 @@ import simpl.peak_detection as peak_detection
 
 PeakDetection = peak_detection.PeakDetection
 SMSPeakDetection = peak_detection.SMSPeakDetection
+SndObjPeakDetection = peak_detection.SMSPeakDetection
 
 float_precision = 5
 frame_size = 512
@@ -59,14 +60,11 @@ class TestSMSPeakDetection(object):
         assert len(pd.frames[0].peaks)
 
     def test_size_next_read(self):
-        """
-        Make sure SMSPeakDetection is calculating the correct value for the
-        size of the next frame.
-        """
         audio, sampling_rate = simpl.read_wav(audio_path)
 
         pd = SMSPeakDetection()
         pd.hop_size = hop_size
+        pd.static_frame_size = False
         pd.max_peaks = max_peaks
         current_frame = 0
         sample_offset = 0
@@ -102,3 +100,20 @@ class TestSMSPeakDetection(object):
             assert frame.num_peaks <= max_peaks, frame.num_peaks
             max_amp = max([p.amplitude for p in frame.peaks])
             assert max_amp
+
+
+class TestSndObjPeakDetection(object):
+    def test_peak_detection(self):
+        audio, sampling_rate = simpl.read_wav(audio_path)
+
+        pd = SndObjPeakDetection()
+        pd.max_peaks = max_peaks
+        pd.hop_size = hop_size
+        frames = pd.find_peaks(audio[0:num_samples])
+
+        assert len(frames) == num_samples / hop_size
+
+        for frame in frames:
+            assert frame.num_peaks <= max_peaks, frame.num_peaks
+            max_amp = max([p.amplitude for p in frame.peaks])
+            assert max_amp
-- 
cgit v1.2.3