summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2012-07-26 19:00:41 +0100
committerJohn Glover <j@johnglover.net>2012-07-26 19:00:41 +0100
commit8870ab2cd4ab50f61c919af7222015d863c5eba4 (patch)
tree022ee1fb6e32d6fa4c4f94568c1c4c0dcf2e4eac
parentd78ca5b8052bc7c4be1d18f14b407614f2e0726a (diff)
downloadsimpl-8870ab2cd4ab50f61c919af7222015d863c5eba4.tar.gz
simpl-8870ab2cd4ab50f61c919af7222015d863c5eba4.tar.bz2
simpl-8870ab2cd4ab50f61c919af7222015d863c5eba4.zip
[peak_detection] Set frame peaks in find_peaks_in_frame
instead of in find_peaks
-rw-r--r--simpl/peak_detection.pyx10
1 files changed, 7 insertions, 3 deletions
diff --git a/simpl/peak_detection.pyx b/simpl/peak_detection.pyx
index 0b598b8..2c07c8f 100644
--- a/simpl/peak_detection.pyx
+++ b/simpl/peak_detection.pyx
@@ -16,12 +16,14 @@ cdef class PeakDetection:
def __cinit__(self):
self.thisptr = new c_PeakDetection()
- self.frames = []
def __dealloc__(self):
if self.thisptr:
del self.thisptr
+ def __init__(self):
+ self.frames = []
+
property sampling_rate:
def __get__(self): return self.thisptr.sampling_rate()
def __set__(self, int i): self.thisptr.sampling_rate(i)
@@ -70,18 +72,20 @@ cdef class PeakDetection:
peak = Peak(False)
peak.set_peak(c_peaks[i])
peaks.append(peak)
+ frame.peaks = peaks
return peaks
def find_peaks(self, np.ndarray[dtype_t, ndim=1] audio):
self.frames = []
+
cdef int pos = 0
- while pos < len(audio):
+ while pos < len(audio) - self.hop_size:
if not self.static_frame_size:
self.frame_size = self.next_frame_size()
frame = Frame(self.frame_size)
frame.audio = audio[pos:pos + self.frame_size]
frame.max_peaks = self.max_peaks
- peaks = self.find_peaks_in_frame(frame)
+ self.find_peaks_in_frame(frame)
self.frames.append(frame)
pos += self.hop_size