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