3 * Copyright 2007 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
23 #ifndef INCLUDED_gr_peak_detector2_FB_H
24 #define INCLUDED_gr_peak_detector2_FB_H
26 #include <gr_sync_block.h>
28 class gr_peak_detector2_fb;
29 typedef boost::shared_ptr<gr_peak_detector2_fb> gr_peak_detector2_fb_sptr;
31 gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise = 7,
32 int look_ahead = 1000,
36 * \brief Detect the peak of a signal
39 * If a peak is detected, this block outputs a 1,
40 * or it outputs 0's. A separate debug output may be connected, to
41 * view the internal EWMA described below.
43 * \param threshold_factor_rise The threshold factor determins when a peak
44 * is present. An EWMA average of the signal is calculated and when the
45 * value of the signal goes over threshold_factor_rise*average, we
47 * \param look_ahead The look-ahead value is used when the threshold is
48 * found to locate the peak within this range.
49 * \param alpha The gain value of a single-pole moving average filter
52 class gr_peak_detector2_fb : public gr_sync_block
54 friend gr_peak_detector2_fb_sptr
55 gr_make_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha);
57 gr_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha);
60 float d_threshold_factor_rise;
62 int d_look_ahead_remaining;
71 /*! \brief Set the threshold factor value for the rise time
72 * \param thr new threshold factor
74 void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; }
76 /*! \brief Set the look-ahead factor
77 * \param look new look-ahead factor
79 void set_look_ahead(int look) { d_look_ahead = look; }
81 /*! \brief Set the running average alpha
82 * \param alpha new alpha for running average
84 void set_alpha(int alpha) { d_alpha = alpha; }
86 /*! \brief Get the threshold factor value for the rise time
87 * \return threshold factor
89 float threshold_factor_rise() { return d_threshold_factor_rise; }
91 /*! \brief Get the look-ahead factor value
92 * \return look-ahead factor
94 int look_ahead() { return d_look_ahead; }
96 /*! \brief Get the alpha value of the running average
99 float alpha() { return d_alpha; }
101 int work (int noutput_items,
102 gr_vector_const_void_star &input_items,
103 gr_vector_void_star &output_items);