summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2012-07-20 17:46:30 +0100
committerJohn Glover <j@johnglover.net>2012-07-20 17:46:30 +0100
commit44387fc6606057393b5026ce0d2707a016037347 (patch)
tree17257ddebaf80ff102839738cafa5d22d5a01ba7 /tests
parentc8eef2c4f0f9b22babc9aef9e0d4cef133475c9b (diff)
downloadsimpl-44387fc6606057393b5026ce0d2707a016037347.tar.gz
simpl-44387fc6606057393b5026ce0d2707a016037347.tar.bz2
simpl-44387fc6606057393b5026ce0d2707a016037347.zip
[peak_detection] Add C++ implementation of SndObj peak detection.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_peak_detection.py23
1 files changed, 19 insertions, 4 deletions
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