summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2013-01-24 16:18:13 +0100
committerJohn Glover <j@johnglover.net>2013-01-24 16:18:13 +0100
commitc010347e4f84647ad33dde4df7be09ec74239a58 (patch)
tree6eef07e02b4820b6e91aaf6f256c342c0ff9f6c0
parent0fbfa61da91408154b49d38834f8e5e51d7da54f (diff)
downloadsimpl-c010347e4f84647ad33dde4df7be09ec74239a58.tar.gz
simpl-c010347e4f84647ad33dde4df7be09ec74239a58.tar.bz2
simpl-c010347e4f84647ad33dde4df7be09ec74239a58.zip
[tests] Fix bug in peak detection tests.
-rw-r--r--src/simpl/peak_detection.cpp10
-rw-r--r--tests/test_peak_detection.cpp6
2 files changed, 5 insertions, 11 deletions
diff --git a/src/simpl/peak_detection.cpp b/src/simpl/peak_detection.cpp
index b0d4829..41d395d 100644
--- a/src/simpl/peak_detection.cpp
+++ b/src/simpl/peak_detection.cpp
@@ -135,15 +135,15 @@ Peaks PeakDetection::find_peaks_in_frame(Frame* frame) {
Frames PeakDetection::find_peaks(int audio_size, sample* audio) {
clear();
unsigned int pos = 0;
+ bool alloc_memory_in_frame = true;
while(pos <= audio_size - _hop_size) {
- // get the next frame size
if(!_static_frame_size) {
_frame_size = next_frame_size();
}
- // get the next frame
- Frame* f = new Frame(_frame_size, true);
+ Frame* f = new Frame(_frame_size, alloc_memory_in_frame);
+ f->max_peaks(_max_peaks);
if((int)pos <= (audio_size - _frame_size)) {
f->audio(&(audio[pos]), _frame_size);
@@ -152,11 +152,7 @@ Frames PeakDetection::find_peaks(int audio_size, sample* audio) {
f->audio(&(audio[pos]), audio_size - pos);
}
- f->max_peaks(_max_peaks);
-
- // find peaks
find_peaks_in_frame(f);
-
_frames.push_back(f);
pos += _hop_size;
}
diff --git a/tests/test_peak_detection.cpp b/tests/test_peak_detection.cpp
index 2f668bc..3cb9c1a 100644
--- a/tests/test_peak_detection.cpp
+++ b/tests/test_peak_detection.cpp
@@ -63,8 +63,7 @@ void TestMQPeakDetection::test_find_peaks_change_hop_frame_size() {
_pd.frame_size(256);
_pd.hop_size(256);
- Frames frames = _pd.find_peaks(num_samples,
- &(audio[(int)_sf.frames() / 2]));
+ Frames frames = _pd.find_peaks(num_samples, &audio[0]);
CPPUNIT_ASSERT(frames.size() == 4);
for(int i = 0; i < frames.size(); i++) {
CPPUNIT_ASSERT(frames[i]->num_peaks() == 0);
@@ -133,8 +132,7 @@ void TestLorisPeakDetection::test_find_peaks_change_hop_frame_size() {
_pd.frame_size(256);
_pd.hop_size(256);
- Frames frames = _pd.find_peaks(num_samples,
- &(audio[(int)_sf.frames() / 2]));
+ Frames frames = _pd.find_peaks(num_samples, &audio[0]);
CPPUNIT_ASSERT(frames.size() == 4);
for(int i = 0; i < frames.size(); i++) {
CPPUNIT_ASSERT(frames[i]->num_peaks() == 0);