GNU Radio 3.6.5 C++ API

gr_peak_detector_fb.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2007 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  *
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 // WARNING: this file is machine generated. Edits will be overwritten
00024 
00025 #ifndef INCLUDED_GR_GR_PEAK_DETECTOR_FB_H
00026 #define INCLUDED_GR_GR_PEAK_DETECTOR_FB_H
00027 
00028 #include <gr_core_api.h>
00029 #include <gr_sync_block.h>
00030 
00031 class gr_peak_detector_fb;
00032 typedef boost::shared_ptr<gr_peak_detector_fb> gr_peak_detector_fb_sptr;
00033 
00034 GR_CORE_API gr_peak_detector_fb_sptr gr_make_peak_detector_fb (float threshold_factor_rise = 0.25,
00035                                  float threshold_factor_fall = 0.40,
00036                                  int look_ahead = 10,
00037                                  float alpha = 0.001);
00038 
00039 /*!
00040  * \brief Detect the peak of a signal
00041  * \ingroup level_blk
00042  *
00043  * If a peak is detected, this block outputs a 1,
00044  * or it outputs 0's.
00045  *
00046  * \param threshold_factor_rise The threshold factor determins when a peak
00047  *        has started. An average of the signal is calculated and when the
00048  *        value of the signal goes over threshold_factor_rise*average, we
00049  *        start looking for a peak.
00050  * \param threshold_factor_fall The threshold factor determins when a peak
00051  *        has ended. An average of the signal is calculated and when the
00052  *        value of the signal goes bellow threshold_factor_fall*average, we
00053  *        stop looking for a peak.
00054  * \param look_ahead The look-ahead value is used when the threshold is
00055  *        found to look if there another peak within this step range.
00056  *        If there is a larger value, we set that as the peak and look ahead
00057  *        again. This is continued until the highest point is found with
00058  *        This look-ahead range.
00059  * \param alpha The gain value of a moving average filter
00060  */
00061 class GR_CORE_API gr_peak_detector_fb : public gr_sync_block
00062 {
00063   friend GR_CORE_API gr_peak_detector_fb_sptr gr_make_peak_detector_fb (float threshold_factor_rise,
00064                                           float threshold_factor_fall,
00065                                           int look_ahead, float alpha);
00066 
00067   gr_peak_detector_fb (float threshold_factor_rise,
00068           float threshold_factor_fall,
00069           int look_ahead, float alpha);
00070 
00071  private:
00072   float d_threshold_factor_rise;
00073   float d_threshold_factor_fall;
00074   int d_look_ahead;
00075   float d_avg_alpha;
00076   float d_avg;
00077   unsigned char d_found;
00078 
00079  public:
00080 
00081   /*! \brief Set the threshold factor value for the rise time
00082    *  \param thr new threshold factor
00083    */
00084   void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; }
00085 
00086   /*! \brief Set the threshold factor value for the fall time
00087    *  \param thr new threshold factor
00088    */
00089   void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; }
00090 
00091   /*! \brief Set the look-ahead factor
00092    *  \param look new look-ahead factor
00093    */
00094   void set_look_ahead(int look) { d_look_ahead = look; }
00095 
00096   /*! \brief Set the running average alpha
00097    *  \param alpha new alpha for running average
00098    */
00099   void set_alpha(int alpha) { d_avg_alpha = alpha; }
00100 
00101   /*! \brief Get the threshold factor value for the rise time
00102    *  \return threshold factor
00103    */
00104   float threshold_factor_rise() { return d_threshold_factor_rise; }
00105 
00106   /*! \brief Get the threshold factor value for the fall time
00107    *  \return threshold factor
00108    */
00109   float threshold_factor_fall() { return d_threshold_factor_fall; }
00110 
00111   /*! \brief Get the look-ahead factor value
00112    *  \return look-ahead factor
00113    */
00114   int look_ahead() { return d_look_ahead; }
00115 
00116   /*! \brief Get the alpha value of the running average
00117    *  \return alpha
00118    */
00119   float alpha() { return d_avg_alpha; }
00120 
00121   int work (int noutput_items,
00122             gr_vector_const_void_star &input_items,
00123             gr_vector_void_star &output_items);
00124 };
00125 
00126 #endif