From 635bf1ae4f05937a2a8eaf4b323a21e189d4f162 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sun, 26 May 2019 08:51:26 +0000 Subject: [PATCH] - fixed peaks heights and merge() git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@476 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- gr-jay/lib/peak_detect_impl.cc | 2 +- gr-jay/lib/peak_detect_impl.h | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gr-jay/lib/peak_detect_impl.cc b/gr-jay/lib/peak_detect_impl.cc index c76e791..2382425 100644 --- a/gr-jay/lib/peak_detect_impl.cc +++ b/gr-jay/lib/peak_detect_impl.cc @@ -226,7 +226,7 @@ namespace gr { else { Peak peak(m_peak_id++, pos); - peak.heightUpdate_rel(m_pXds, nitems_per_block); + peak.height_rel = m_pXds[pos]; addToListByPos(peaks, peak); numPeaksClimbed++; break; diff --git a/gr-jay/lib/peak_detect_impl.h b/gr-jay/lib/peak_detect_impl.h index b84095f..28821f0 100644 --- a/gr-jay/lib/peak_detect_impl.h +++ b/gr-jay/lib/peak_detect_impl.h @@ -149,12 +149,14 @@ namespace jay { const Peak& merge(const Peak &other) { - float beta = 0.1f; + float beta = 0.5f; float alpha = (1.f-beta); - pos = alpha*pos + beta*other.pos; - pbh = alpha*pbh + beta*other.pbh; - height_rel = std::max(height_rel, other.height_rel); - height_abs = std::max(height_abs, other.height_abs); + float pos_f = alpha*(float)pos + beta*(float)other.pos; + float pbh_f = alpha*(float)pbh + beta*(float)other.pbh; + pos = (int)(pos_f + 0.5f); + pbh = (int)(pbh_f + 0.5f); + height_rel = other.height_rel; + height_abs = other.height_abs; return *this; }