summaryrefslogtreecommitdiff
path: root/simpl/peak_detection.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'simpl/peak_detection.pyx')
-rw-r--r--simpl/peak_detection.pyx11
1 files changed, 10 insertions, 1 deletions
diff --git a/simpl/peak_detection.pyx b/simpl/peak_detection.pyx
index 2c07c8f..b2628e6 100644
--- a/simpl/peak_detection.pyx
+++ b/simpl/peak_detection.pyx
@@ -79,7 +79,7 @@ cdef class PeakDetection:
self.frames = []
cdef int pos = 0
- while pos < len(audio) - self.hop_size:
+ while pos <= len(audio) - self.frame_size:
if not self.static_frame_size:
self.frame_size = self.next_frame_size()
frame = Frame(self.frame_size)
@@ -103,6 +103,15 @@ cdef class SMSPeakDetection(PeakDetection):
del self.thisptr
self.thisptr = <c_PeakDetection*>0
+ def find_peaks(self, np.ndarray[dtype_t, ndim=1] audio):
+ self.frames = []
+ cdef vector[c_Frame*] output_frames = self.thisptr.find_peaks(len(audio), <double*> audio.data)
+ for i in range(output_frames.size()):
+ f = Frame(output_frames[i].size(), False)
+ f.set_frame(output_frames[i])
+ self.frames.append(f)
+ return self.frames
+
cdef class SndObjPeakDetection(PeakDetection):
def __cinit__(self):