summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2012-10-03 17:07:26 +0200
committerJohn Glover <j@johnglover.net>2012-10-03 17:07:26 +0200
commitaa1a18cf13c5fe1e9d46fdcf562e855e043bbf4e (patch)
tree1935d09fbad3a48708635b5a6c6511c310630cd5
parent98d77b676e13eb362ce85146035bc2f5d098e4f6 (diff)
downloadsimpl-aa1a18cf13c5fe1e9d46fdcf562e855e043bbf4e.tar.gz
simpl-aa1a18cf13c5fe1e9d46fdcf562e855e043bbf4e.tar.bz2
simpl-aa1a18cf13c5fe1e9d46fdcf562e855e043bbf4e.zip
[peak_detection] Bug fix: Make sure
that the number of frames produced by the Python PeakDetection.find_peaks method is the same as the corresponding C++ method.
-rw-r--r--simpl/peak_detection.pyx2
-rw-r--r--simpl/synthesis.pyx10
2 files changed, 6 insertions, 6 deletions
diff --git a/simpl/peak_detection.pyx b/simpl/peak_detection.pyx
index 4db67bf..cd143bf 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):
+ while pos <= len(audio) - self.hop_size:
if not self.static_frame_size:
self.frame_size = self.next_frame_size()
diff --git a/simpl/synthesis.pyx b/simpl/synthesis.pyx
index 87a4019..708c210 100644
--- a/simpl/synthesis.pyx
+++ b/simpl/synthesis.pyx
@@ -40,13 +40,13 @@ cdef class Synthesis:
return frame.synth
def synth(self, frames):
- cdef int size = self.thisptr.hop_size()
- cdef np.ndarray[dtype_t, ndim=1] output = np.zeros(len(frames) * size)
+ cdef int hop = self.thisptr.hop_size()
+ cdef np.ndarray[dtype_t, ndim=1] output = np.zeros(len(frames) * hop)
for i in range(len(frames)):
- frames[i].synth = np.zeros(size)
- frames[i].synth_size = size
+ frames[i].synth = np.zeros(hop)
+ frames[i].synth_size = hop
self.synth_frame(frames[i])
- output[i * size:(i + 1) * size] = frames[i].synth
+ output[i * hop:(i + 1) * hop] = frames[i].synth
return output