GNU Radio C++ API
gr_peak_detector_sb.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2007 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 // WARNING: this file is machine generated. Edits will be over written
24 
25 #ifndef INCLUDED_GR_PEAK_DETECTOR_SB_H
26 #define INCLUDED_GR_PEAK_DETECTOR_SB_H
27 
28 #include <gr_core_api.h>
29 #include <gr_sync_block.h>
30 
33 
35  float threshold_factor_fall = 0.40,
36  int look_ahead = 10,
37  float alpha = 0.001);
38 
39 /*!
40  * \brief Detect the peak of a signal
41  * \ingroup level_blk
42  *
43  * If a peak is detected, this block outputs a 1,
44  * or it outputs 0's.
45  *
46  * \param threshold_factor_rise The threshold factor determins when a peak
47  * has started. An average of the signal is calculated and when the
48  * value of the signal goes over threshold_factor_rise*average, we
49  * start looking for a peak.
50  * \param threshold_factor_fall The threshold factor determins when a peak
51  * has ended. An average of the signal is calculated and when the
52  * value of the signal goes bellow threshold_factor_fall*average, we
53  * stop looking for a peak.
54  * \param look_ahead The look-ahead value is used when the threshold is
55  * found to look if there another peak within this step range.
56  * If there is a larger value, we set that as the peak and look ahead
57  * again. This is continued until the highest point is found with
58  * This look-ahead range.
59  * \param alpha The gain value of a moving average filter
60  */
62 {
63  friend GR_CORE_API gr_peak_detector_sb_sptr gr_make_peak_detector_sb (float threshold_factor_rise,
64  float threshold_factor_fall,
65  int look_ahead, float alpha);
66 
67  gr_peak_detector_sb (float threshold_factor_rise,
68  float threshold_factor_fall,
69  int look_ahead, float alpha);
70 
71  private:
72  float d_threshold_factor_rise;
73  float d_threshold_factor_fall;
74  int d_look_ahead;
75  float d_avg_alpha;
76  float d_avg;
77  unsigned char d_found;
78 
79  public:
80 
81  /*! \brief Set the threshold factor value for the rise time
82  * \param thr new threshold factor
83  */
84  void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; }
85 
86  /*! \brief Set the threshold factor value for the fall time
87  * \param thr new threshold factor
88  */
89  void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; }
90 
91  /*! \brief Set the look-ahead factor
92  * \param look new look-ahead factor
93  */
94  void set_look_ahead(int look) { d_look_ahead = look; }
95 
96  /*! \brief Set the running average alpha
97  * \param alpha new alpha for running average
98  */
99  void set_alpha(int alpha) { d_avg_alpha = alpha; }
100 
101  /*! \brief Get the threshold factor value for the rise time
102  * \return threshold factor
103  */
104  float threshold_factor_rise() { return d_threshold_factor_rise; }
105 
106  /*! \brief Get the threshold factor value for the fall time
107  * \return threshold factor
108  */
109  float threshold_factor_fall() { return d_threshold_factor_fall; }
110 
111  /*! \brief Get the look-ahead factor value
112  * \return look-ahead factor
113  */
114  int look_ahead() { return d_look_ahead; }
115 
116  /*! \brief Get the alpha value of the running average
117  * \return alpha
118  */
119  float alpha() { return d_avg_alpha; }
120 
121  int work (int noutput_items,
122  gr_vector_const_void_star &input_items,
123  gr_vector_void_star &output_items);
124 };
125 
126 #endif