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