GNU Radio's DAB Package
peak_detector_fb.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2017 <+YOU OR YOUR COMPANY+>.
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21
22#ifndef INCLUDED_DAB_PEAK_DETECTOR_FB_H
23#define INCLUDED_DAB_PEAK_DETECTOR_FB_H
24
25#include <dab/api.h>
26#include <gnuradio/sync_block.h>
27
28namespace gr {
29 namespace dab {
30
31 /*!
32 * \brief Detect the peak of a signal
33 * \ingroup peak_detectors_blk
34 *
35 * \details
36 * If a peak is detected, this block outputs a 1,
37 * or it outputs 0's.
38 */
39 class DAB_API peak_detector_fb : virtual public gr::sync_block
40 {
41 public:
42 typedef std::shared_ptr<peak_detector_fb> sptr;
43
44 /*!
45 * Make a peak detector block.
46 *
47 * \param threshold_factor_rise The threshold factor determines
48 * when a peak has started. An average of the signal is
49 * calculated and when the value of the signal goes over
50 * threshold_factor_rise*average, we start looking for a
51 * peak.
52 * \param threshold_factor_fall The threshold factor determines
53 * when a peak has ended. An average of the signal is
54 * calculated and when the value of the signal goes
55 * below threshold_factor_fall*average, we stop looking
56 * for a peak.
57 * \param look_ahead The look-ahead value is used when the
58 * threshold is found to look if there another peak
59 * within this step range. If there is a larger value,
60 * we set that as the peak and look ahead again. This is
61 * continued until the highest point is found with This
62 * look-ahead range.
63 * \param alpha The gain value of a moving average filter
64 */
65 static sptr make(float threshold_factor_rise = 0.25,
66 float threshold_factor_fall = 0.40,
67 int look_ahead = 10,
68 float alpha = 0.001);
69
70 /*! \brief Set the threshold factor value for the rise time
71 * \param thr new threshold factor
72 */
73 virtual void set_threshold_factor_rise(float thr) = 0;
74
75 /*! \brief Set the threshold factor value for the fall time
76 * \param thr new threshold factor
77 */
78 virtual void set_threshold_factor_fall(float thr) = 0;
79
80 /*! \brief Set the look-ahead factor
81 * \param look new look-ahead factor
82 */
83 virtual void set_look_ahead(int look) = 0;
84
85 /*! \brief Set the running average alpha
86 * \param alpha new alpha for running average
87 */
88 virtual void set_alpha(float alpha) = 0;
89
90 /*! \brief Get the threshold factor value for the rise time
91 * \return threshold factor
92 */
93 virtual float threshold_factor_rise() = 0;
94
95 /*! \brief Get the threshold factor value for the fall time
96 * \return threshold factor
97 */
98 virtual float threshold_factor_fall() = 0;
99
100 /*! \brief Get the look-ahead factor value
101 * \return look-ahead factor
102 */
103 virtual int look_ahead() = 0;
104
105 /*! \brief Get the alpha value of the running average
106 * \return alpha
107 */
108 virtual float alpha() = 0;
109 };
110
111 } // namespace dab
112} // namespace gr
113
114#endif /* INCLUDED_DAB_PEAK_DETECTOR_FB_H */
115
#define DAB_API
Definition api.h:19
Detect the peak of a signal.
Definition peak_detector_fb.h:40
virtual float threshold_factor_fall()=0
Get the threshold factor value for the fall time.
virtual float threshold_factor_rise()=0
Get the threshold factor value for the rise time.
static sptr make(float threshold_factor_rise=0.25, float threshold_factor_fall=0.40, int look_ahead=10, float alpha=0.001)
virtual float alpha()=0
Get the alpha value of the running average.
virtual void set_alpha(float alpha)=0
Set the running average alpha.
virtual int look_ahead()=0
Get the look-ahead factor value.
virtual void set_threshold_factor_fall(float thr)=0
Set the threshold factor value for the fall time.
std::shared_ptr< peak_detector_fb > sptr
Definition peak_detector_fb.h:42
virtual void set_threshold_factor_rise(float thr)=0
Set the threshold factor value for the rise time.
virtual void set_look_ahead(int look)=0
Set the look-ahead factor.
Definition complex_to_interleaved_float_vcf.h:28