GNU Radio 3.6.5 C++ API

peak_detector2_fb.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2007,2013 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 #ifndef INCLUDED_GR_PEAK_DETECTOR2_FB_H
00024 #define INCLUDED_GR_PEAK_DETECTOR2_FB_H
00025 
00026 #include <blocks/api.h>
00027 #include <gr_sync_block.h>
00028 
00029 namespace gr {
00030   namespace blocks {
00031 
00032     /*!
00033      * \brief Detect the peak of a signal
00034      * \ingroup peak_detectors_blk
00035      *
00036      * \details
00037      * If a peak is detected, this block outputs a 1, or it outputs
00038      * 0's. A separate debug output may be connected, to view the
00039      * internal EWMA described below.
00040      */
00041     class BLOCKS_API peak_detector2_fb : virtual public gr_sync_block
00042     {
00043     public:
00044       // gr::blocks::peak_detector2_fb::sptr
00045       typedef boost::shared_ptr<peak_detector2_fb> sptr;
00046 
00047       /*!
00048        * Build a peak detector block with float in, byte out.
00049        *
00050        * \param threshold_factor_rise The threshold factor determins
00051        *        when a peak is present. An EWMA average of the signal is
00052        *        calculated and when the value of the signal goes over
00053        *        threshold_factor_rise*average, we call the peak.
00054        * \param look_ahead The look-ahead value is used when the
00055        *        threshold is found to locate the peak within this range.
00056        * \param alpha The gain value of a single-pole moving average filter.
00057        */
00058       static sptr make(float threshold_factor_rise=7,
00059                        int look_ahead=1000, float alpha=0.001);
00060 
00061       /*! \brief Set the threshold factor value for the rise time
00062        *  \param thr new threshold factor
00063        */
00064       virtual void set_threshold_factor_rise(float thr) = 0;
00065 
00066       /*! \brief Set the look-ahead factor
00067        *  \param look new look-ahead factor
00068        */
00069       virtual void set_look_ahead(int look) = 0;
00070 
00071       /*! \brief Set the running average alpha
00072        *  \param alpha new alpha for running average
00073        */
00074       virtual void set_alpha(int alpha) = 0;
00075 
00076       /*! \brief Get the threshold factor value for the rise time
00077        *  \return threshold factor
00078        */
00079       virtual float threshold_factor_rise() = 0;
00080 
00081       /*! \brief Get the look-ahead factor value
00082        *  \return look-ahead factor
00083        */
00084       virtual int look_ahead() = 0;
00085 
00086       /*! \brief Get the alpha value of the running average
00087        *  \return alpha
00088        */
00089       virtual float alpha() = 0;
00090     };
00091 
00092   } /* namespace blocks */
00093 } /* namespace gr */
00094 
00095 #endif /* INCLUDED_GR_PEAK_DETECTOR2_FB_H */