diff options
author | Tom Rondeau <trondeau@vt.edu> | 2012-08-14 00:00:14 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2012-08-14 00:00:14 -0400 |
commit | 48a95b3469febf4929c74f41beac6b33ab77566e (patch) | |
tree | 09fcfa18252f4e629f1bdb280b7ef0a12e1f401b /gr-digital/include | |
parent | 509fddb30a70862b31b0488acfbbdf523b48af0d (diff) |
digital: converted mpsk snr and probes to new style.
Diffstat (limited to 'gr-digital/include')
-rw-r--r-- | gr-digital/include/digital/CMakeLists.txt | 8 | ||||
-rw-r--r-- | gr-digital/include/digital/mpsk_snr_est.h | 287 | ||||
-rw-r--r-- | gr-digital/include/digital/mpsk_snr_est_cc.h | 96 | ||||
-rw-r--r-- | gr-digital/include/digital/probe_density_b.h | 63 | ||||
-rw-r--r-- | gr-digital/include/digital/probe_mpsk_snr_est_c.h | 94 | ||||
-rw-r--r-- | gr-digital/include/digital_impl_mpsk_snr_est.h | 279 | ||||
-rw-r--r-- | gr-digital/include/digital_mpsk_snr_est_cc.h | 115 | ||||
-rw-r--r-- | gr-digital/include/digital_probe_density_b.h | 75 | ||||
-rw-r--r-- | gr-digital/include/digital_probe_mpsk_snr_est_c.h | 113 |
9 files changed, 544 insertions, 586 deletions
diff --git a/gr-digital/include/digital/CMakeLists.txt b/gr-digital/include/digital/CMakeLists.txt index 7d8545b185..2445a6fe37 100644 --- a/gr-digital/include/digital/CMakeLists.txt +++ b/gr-digital/include/digital/CMakeLists.txt @@ -77,7 +77,7 @@ install(FILES ${digital_generated_includes} api.h glfsr.h -# impl_mpsk_snr_est.h + mpsk_snr_est.h additive_scrambler_bb.h binary_slicer_fb.h clock_recovery_mm_cc.h @@ -105,7 +105,7 @@ install(FILES map_bb.h # metric_type.h # mpsk_receiver_cc.h -# mpsk_snr_est_cc.h + mpsk_snr_est_cc.h # ofdm_cyclic_prefixer.h # ofdm_frame_acquisition.h # ofdm_frame_sink.h @@ -116,8 +116,8 @@ install(FILES pfb_clock_sync_ccf.h pfb_clock_sync_fff.h pn_correlator_cc.h -# probe_density_b.h -# probe_mpsk_snr_est_c.h + probe_density_b.h + probe_mpsk_snr_est_c.h scrambler_bb.h # simple_framer.h # simple_framer_sync.h diff --git a/gr-digital/include/digital/mpsk_snr_est.h b/gr-digital/include/digital/mpsk_snr_est.h new file mode 100644 index 0000000000..80dad77ce3 --- /dev/null +++ b/gr-digital/include/digital/mpsk_snr_est.h @@ -0,0 +1,287 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_DIGITAL_MPSK_SNR_EST_H +#define INCLUDED_DIGITAL_MPSK_SNR_EST_H + +#include <digital/api.h> +#include <gr_complex.h> + +namespace gr { + namespace digital { + + //! Enum for the type of SNR estimator to select + /*! \ingroup snr_blk + * \anchor ref_snr_est_types + * + * Below are some ROUGH estimates of what values of SNR each of + * these types of estimators is good for. In general, these offer + * a trade-off between accuracy and performance. + * + * \li SNR_EST_SIMPLE: Simple estimator (>= 7 dB) + * \li SNR_EST_SKEW: Skewness-base est (>= 5 dB) + * \li SNR_EST_M2M4: 2nd & 4th moment est (>= 1 dB) + * \li SNR_EST_SVR: SVR-based est (>= 0dB) + */ + enum snr_est_type_t { + SNR_EST_SIMPLE = 0, // Simple estimator (>= 7 dB) + SNR_EST_SKEW, // Skewness-base est (>= 5 dB) + SNR_EST_M2M4, // 2nd & 4th moment est (>= 1 dB) + SNR_EST_SVR // SVR-based est (>= 0dB) + }; + + /*! \brief A parent class for SNR estimators, specifically for + * M-PSK signals in AWGN channels. + * \ingroup snr_blk + */ + class DIGITAL_API mpsk_snr_est + { + protected: + double d_alpha, d_beta; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est(double alpha); + virtual ~mpsk_snr_est(); + + //! Get the running-average coefficient + double alpha() const; + + //! Set the running-average coefficient + void set_alpha(double alpha); + + //! Update the current registers + virtual int update(int noutput_items, + const gr_complex *input); + + //! Use the register values to compute a new estimate + virtual double snr(); + }; + + + //! \brief SNR Estimator using simple mean/variance estimates. + /*! \ingroup snr_blk + * + * A very simple SNR estimator that just uses mean and variance + * estimates of an M-PSK constellation. This esimator is quick + * and cheap and accurate for high SNR (above 7 dB or so) but + * quickly starts to overestimate the SNR at low SNR. + */ + class DIGITAL_API mpsk_snr_est_simple : + public mpsk_snr_est + { + private: + double d_y1, d_y2; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est_simple(double alpha); + ~mpsk_snr_est_simple() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + + //! \brief SNR Estimator using skewness correction. + /*! \ingroup snr_blk + * + * This is an estimator that came from a discussion between Tom + * Rondeau and fred harris with no known paper reference. The + * idea is that at low SNR, the variance estimations will be + * affected because of fold-over around the decision boundaries, + * which results in a skewness to the samples. We estimate the + * skewness and use this as a correcting term. + */ + class DIGITAL_API mpsk_snr_est_skew : + public mpsk_snr_est + { + private: + double d_y1, d_y2, d_y3; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est_skew(double alpha); + ~mpsk_snr_est_skew() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + + //! \brief SNR Estimator using 2nd and 4th-order moments. + /*! \ingroup snr_blk + * + * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th + * (M4) order moments. This estimator uses knowledge of the + * kurtosis of the signal (k_a) and noise (k_w) to make its + * estimation. We use Beaulieu's approximations here to M-PSK + * signals and AWGN channels such that k_a=1 and k_w=2. These + * approximations significantly reduce the complexity of the + * calculations (and computations) required. + * + * Reference: + * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR + * estimation techniques for the AWGN channel," IEEE + * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. + */ + class DIGITAL_API mpsk_snr_est_m2m4 : + public mpsk_snr_est + { + private: + double d_y1, d_y2; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est_m2m4(double alpha); + ~mpsk_snr_est_m2m4() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + + //! \brief SNR Estimator using 2nd and 4th-order moments. + /*! \ingroup snr_blk + * + * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th + * (M4) order moments. This estimator uses knowledge of the + * kurtosis of the signal (k_a) and noise (k_w) to make its + * estimation. In this case, you can set your own estimations for + * k_a and k_w, the kurtosis of the signal and noise, to fit this + * estimation better to your signal and channel conditions. + * + * A word of warning: this estimator has not been fully tested or + * proved with any amount of rigor. The estimation for M4 in + * particular might be ignoring effectf of when k_a and k_w are + * different. Use this estimator with caution and a copy of the + * reference on hand. + * + * The digital_mpsk_snr_est_m2m4 assumes k_a and k_w to simplify + * the computations for M-PSK and AWGN channels. Use that + * estimator unless you have a way to guess or estimate these + * values here. + * + * Original paper: + * R. Matzner, "An SNR estimation algorithm for complex baseband + * signal using higher order statistics," Facta Universitatis + * (Nis), no. 6, pp. 41-52, 1993. + * + * Reference used in derivation: + * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR + * estimation techniques for the AWGN channel," IEEE + * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. + */ + class DIGITAL_API snr_est_m2m4 : + public mpsk_snr_est + { + private: + double d_y1, d_y2; + double d_ka, d_kw; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + * \param ka: estimate of the signal kurtosis (1 for PSK) + * \param kw: estimate of the channel noise kurtosis (2 for AWGN) + */ + snr_est_m2m4(double alpha, double ka, double kw); + ~snr_est_m2m4() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + + //! \brief Signal-to-Variation Ratio SNR Estimator. + /*! \ingroup snr_blk + * + * This estimator actually comes from an SNR estimator for M-PSK + * signals in fading channels, but this implementation is + * specifically for AWGN channels. The math was simplified to + * assume a signal and noise kurtosis (k_a and k_w) for M-PSK + * signals in AWGN. These approximations significantly reduce the + * complexity of the calculations (and computations) required. + * + * Original paper: + * A. L. Brandao, L. B. Lopes, and D. C. McLernon, "In-service + * monitoring of multipath delay and cochannel interference for + * indoor mobile communication systems," Proc. IEEE + * Int. Conf. Communications, vol. 3, pp. 1458-1462, May 1994. + * + * Reference: + * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR + * estimation techniques for the AWGN channel," IEEE + * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. + */ + class DIGITAL_API mpsk_snr_est_svr : + public mpsk_snr_est + { + private: + double d_y1, d_y2; + + public: + /*! Constructor + * + * Parameters: + * \param alpha: the update rate of internal running average + * calculations. + */ + mpsk_snr_est_svr(double alpha); + ~mpsk_snr_est_svr() {} + + int update(int noutput_items, + const gr_complex *input); + double snr(); + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_H */ diff --git a/gr-digital/include/digital/mpsk_snr_est_cc.h b/gr-digital/include/digital/mpsk_snr_est_cc.h new file mode 100644 index 0000000000..e6cc511dc7 --- /dev/null +++ b/gr-digital/include/digital/mpsk_snr_est_cc.h @@ -0,0 +1,96 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H +#define INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H + +#include <digital/api.h> +#include <digital/mpsk_snr_est.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + //! \brief A block for computing SNR of a signal. + /*! \ingroup snr_blk + * + * This block can be used to monitor and retrieve estimations of + * the signal SNR. It is designed to work in a flowgraph and + * passes all incoming data along to its output. + * + * The block is designed for use with M-PSK signals + * especially. The type of estimator is specified as the \p type + * parameter in the constructor. The estimators tend to trade off + * performance for accuracy, although experimentation should be + * done to figure out the right approach for a given + * implementation. Further, the current set of estimators are + * designed and proven theoretically under AWGN conditions; some + * amount of error should be assumed and/or estimated for real + * channel conditions. + */ + class DIGITAL_API mpsk_snr_est_cc : virtual public gr_sync_block + { + public: + // gr::digital::mpsk_snr_est_cc::sptr + typedef boost::shared_ptr<mpsk_snr_est_cc> sptr; + + /*! Factory function returning shared pointer of this class + * + * Parameters: + * + * \param type: the type of estimator to use \ref ref_snr_est_types + * "snr_est_type_t" for details about the available types. + * \param tag_nsamples: after this many samples, a tag containing + * the SNR (key='snr') will be sent + * \param alpha: the update rate of internal running average + * calculations. + */ + static sptr make(snr_est_type_t type, + int tag_nsamples, + double alpha); + + //! Return the estimated signal-to-noise ratio in decibels + virtual double snr() = 0; + + //! Return the type of estimator in use + virtual snr_est_type_t type() const = 0; + + //! Return how many samples between SNR tags + virtual int tag_nsample() const = 0; + + //! Get the running-average coefficient + virtual double alpha() const = 0; + + //! Set type of estimator to use + virtual void set_type(snr_est_type_t t) = 0; + + //! Set the number of samples between SNR tags + virtual void set_tag_nsample(int n) = 0; + + //! Set the running-average coefficient + virtual void set_alpha(double alpha) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H */ diff --git a/gr-digital/include/digital/probe_density_b.h b/gr-digital/include/digital/probe_density_b.h new file mode 100644 index 0000000000..7459663fe1 --- /dev/null +++ b/gr-digital/include/digital/probe_density_b.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2012 Free Software Foundation, Inc. + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_PROBE_DENSITY_B_H +#define INCLUDED_GR_PROBE_DENSITY_B_H + +#include <digital/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + /*! + * This block maintains a running average of the input stream and + * makes it available as an accessor function. The input stream + * is type unsigned char. + * + * If you send this block a stream of unpacked bytes, it will tell + * you what the bit density is. + * + * \param alpha Average filter constant + * + */ + class DIGITAL_API probe_density_b : virtual public gr_sync_block + { + public: + // gr::digital::probe_density_b::sptr + typedef boost::shared_ptr<probe_density_b> sptr; + + static sptr make(double alpha); + + /*! + * \brief Returns the current density value + */ + virtual double density() const = 0; + + /*! + * \brief Set the average filter constant + */ + virtual void set_alpha(double alpha) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PROBE_DENSITY_B_H */ diff --git a/gr-digital/include/digital/probe_mpsk_snr_est_c.h b/gr-digital/include/digital/probe_mpsk_snr_est_c.h new file mode 100644 index 0000000000..d65e8e1b6e --- /dev/null +++ b/gr-digital/include/digital/probe_mpsk_snr_est_c.h @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H +#define INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H + +#include <digital/api.h> +#include <digital/mpsk_snr_est.h> +#include <gr_sync_block.h> + +namespace gr { + namespace digital { + + //! \brief A probe for computing SNR of a signal. + /*! \ingroup snr_blk + * + * This is a probe block (a sink) that can be used to monitor and + * retrieve estimations of the signal SNR. This probe is designed + * for use with M-PSK signals especially. The type of estimator + * is specified as the \p type parameter in the constructor. The + * estimators tend to trade off performance for accuracy, + * although experimentation should be done to figure out the + * right approach for a given implementation. Further, the + * current set of estimators are designed and proven + * theoretically under AWGN conditions; some amount of error + * should be assumed and/or estimated for real channel + * conditions. + */ + class DIGITAL_API probe_mpsk_snr_est_c : virtual public gr_sync_block + { + public: + // gr::digital::probe_mpsk_snr_est_c::sptr + typedef boost::shared_ptr<probe_mpsk_snr_est_c> sptr; + + /*! Make an MPSK SNR probe. + * + * Parameters: + * + * \param type: the type of estimator to use \ref ref_snr_est_types + * "snr_est_type_t" for details about the available types. + * \param msg_nsamples: [not implemented yet] after this many + * samples, a message containing the SNR (key='snr') will be sent + * \param alpha: the update rate of internal running average + * calculations. + */ + static sptr make(snr_est_type_t type, + int msg_nsamples, + double alpha); + + //! Return the estimated signal-to-noise ratio in decibels + virtual double snr() = 0; + + //! Return the type of estimator in use + virtual snr_est_type_t type() const = 0; + + //! Return how many samples between SNR messages + virtual int msg_nsample() const = 0; + + //! Get the running-average coefficient + virtual double alpha() const = 0; + + //! Set type of estimator to use + virtual void set_type(snr_est_type_t t) = 0; + + //! Set the number of samples between SNR messages + virtual void set_msg_nsample(int n) = 0; + + //! Set the running-average coefficient + virtual void set_alpha(double alpha) = 0; + }; + + } /* namespace digital */ +} /* namespace gr */ + +#endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H */ diff --git a/gr-digital/include/digital_impl_mpsk_snr_est.h b/gr-digital/include/digital_impl_mpsk_snr_est.h deleted file mode 100644 index df7dbadec1..0000000000 --- a/gr-digital/include/digital_impl_mpsk_snr_est.h +++ /dev/null @@ -1,279 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_DIGITAL_IMPL_MPSK_SNR_EST_H -#define INCLUDED_DIGITAL_IMPL_MPSK_SNR_EST_H - -#include <digital_api.h> -#include <gr_sync_block.h> - -//! Enum for the type of SNR estimator to select -/*! \ingroup snr_blk - * \anchor ref_snr_est_types - * - * Below are some ROUGH estimates of what values of SNR each of these - * types of estimators is good for. In general, these offer a - * trade-off between accuracy and performance. - * - * \li SNR_EST_SIMPLE: Simple estimator (>= 7 dB) - * \li SNR_EST_SKEW: Skewness-base est (>= 5 dB) - * \li SNR_EST_M2M4: 2nd & 4th moment est (>= 1 dB) - * \li SNR_EST_SVR: SVR-based est (>= 0dB) -*/ -enum snr_est_type_t { - SNR_EST_SIMPLE = 0, // Simple estimator (>= 7 dB) - SNR_EST_SKEW, // Skewness-base est (>= 5 dB) - SNR_EST_M2M4, // 2nd & 4th moment est (>= 1 dB) - SNR_EST_SVR // SVR-based est (>= 0dB) -}; - -/*! \brief A parent class for SNR estimators, specifically for M-PSK - * signals in AWGN channels. - * \ingroup snr_blk - */ -class DIGITAL_API digital_impl_mpsk_snr_est -{ - protected: - double d_alpha, d_beta; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est(double alpha); - virtual ~digital_impl_mpsk_snr_est(); - - //! Get the running-average coefficient - double alpha() const; - - //! Set the running-average coefficient - void set_alpha(double alpha); - - //! Update the current registers - virtual int update(int noutput_items, - const gr_complex *in); - - //! Use the register values to compute a new estimate - virtual double snr(); -}; - - -//! \brief SNR Estimator using simple mean/variance estimates. -/*! \ingroup snr_blk - * - * A very simple SNR estimator that just uses mean and variance - * estimates of an M-PSK constellation. This esimator is quick and - * cheap and accurate for high SNR (above 7 dB or so) but quickly - * starts to overestimate the SNR at low SNR. - */ -class DIGITAL_API digital_impl_mpsk_snr_est_simple : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est_simple(double alpha); - ~digital_impl_mpsk_snr_est_simple() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - - -//! \brief SNR Estimator using skewness correction. -/*! \ingroup snr_blk - * - * This is an estimator that came from a discussion between Tom - * Rondeau and fred harris with no known paper reference. The idea is - * that at low SNR, the variance estimations will be affected because - * of fold-over around the decision boundaries, which results in a - * skewness to the samples. We estimate the skewness and use this as - * a correcting term. - */ -class DIGITAL_API digital_impl_mpsk_snr_est_skew : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2, d_y3; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est_skew(double alpha); - ~digital_impl_mpsk_snr_est_skew() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - - -//! \brief SNR Estimator using 2nd and 4th-order moments. -/*! \ingroup snr_blk - * - * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th (M4) - * order moments. This estimator uses knowledge of the kurtosis of - * the signal (k_a) and noise (k_w) to make its estimation. We use - * Beaulieu's approximations here to M-PSK signals and AWGN channels - * such that k_a=1 and k_w=2. These approximations significantly - * reduce the complexity of the calculations (and computations) - * required. - * - * Reference: - * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR - * estimation techniques for the AWGN channel," IEEE - * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. - */ -class DIGITAL_API digital_impl_mpsk_snr_est_m2m4 : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est_m2m4(double alpha); - ~digital_impl_mpsk_snr_est_m2m4() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - - -//! \brief SNR Estimator using 2nd and 4th-order moments. -/*! \ingroup snr_blk - * - * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th (M4) - * order moments. This estimator uses knowledge of the kurtosis of - * the signal (k_a) and noise (k_w) to make its estimation. In this - * case, you can set your own estimations for k_a and k_w, the - * kurtosis of the signal and noise, to fit this estimation better to - * your signal and channel conditions. - * - * A word of warning: this estimator has not been fully tested or - * proved with any amount of rigor. The estimation for M4 in - * particular might be ignoring effectf of when k_a and k_w are - * different. Use this estimator with caution and a copy of the - * reference on hand. - * - * The digital_mpsk_snr_est_m2m4 assumes k_a and k_w to simplify the - * computations for M-PSK and AWGN channels. Use that estimator - * unless you have a way to guess or estimate these values here. - * - * Original paper: - * R. Matzner, "An SNR estimation algorithm for complex baseband - * signal using higher order statistics," Facta Universitatis - * (Nis), no. 6, pp. 41-52, 1993. - * - * Reference used in derivation: - * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR - * estimation techniques for the AWGN channel," IEEE - * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. - */ -class DIGITAL_API digital_impl_snr_est_m2m4 : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2; - double d_ka, d_kw; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - * \param ka: estimate of the signal kurtosis (1 for PSK) - * \param kw: estimate of the channel noise kurtosis (2 for AWGN) - */ - digital_impl_snr_est_m2m4(double alpha, double ka, double kw); - ~digital_impl_snr_est_m2m4() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - - -//! \brief Signal-to-Variation Ratio SNR Estimator. -/*! \ingroup snr_blk - * - * This estimator actually comes from an SNR estimator for M-PSK - * signals in fading channels, but this implementation is - * specifically for AWGN channels. The math was simplified to assume - * a signal and noise kurtosis (k_a and k_w) for M-PSK signals in - * AWGN. These approximations significantly reduce the complexity of - * the calculations (and computations) required. - * - * Original paper: - * A. L. Brandao, L. B. Lopes, and D. C. McLernon, "In-service - * monitoring of multipath delay and cochannel interference for - * indoor mobile communication systems," Proc. IEEE - * Int. Conf. Communications, vol. 3, pp. 1458-1462, May 1994. - * - * Reference: - * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR - * estimation techniques for the AWGN channel," IEEE - * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000. - */ -class DIGITAL_API digital_impl_mpsk_snr_est_svr : - public digital_impl_mpsk_snr_est -{ - private: - double d_y1, d_y2; - - public: - /*! Constructor - * - * Parameters: - * \param alpha: the update rate of internal running average - * calculations. - */ - digital_impl_mpsk_snr_est_svr(double alpha); - ~digital_impl_mpsk_snr_est_svr() {} - - int update(int noutput_items, - const gr_complex *in); - double snr(); -}; - -#endif /* INCLUDED_DIGITAL_IMPL_MPSK_SNR_EST_H */ diff --git a/gr-digital/include/digital_mpsk_snr_est_cc.h b/gr-digital/include/digital_mpsk_snr_est_cc.h deleted file mode 100644 index 2cbd98bab8..0000000000 --- a/gr-digital/include/digital_mpsk_snr_est_cc.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H -#define INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <digital_impl_mpsk_snr_est.h> - -class digital_mpsk_snr_est_cc; -typedef boost::shared_ptr<digital_mpsk_snr_est_cc> digital_mpsk_snr_est_cc_sptr; - -DIGITAL_API digital_mpsk_snr_est_cc_sptr -digital_make_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples=10000, - double alpha=0.001); - -//! \brief A block for computing SNR of a signal. -/*! \ingroup snr_blk - * - * This block can be used to monitor and retrieve estimations of the - * signal SNR. It is designed to work in a flowgraph and passes all - * incoming data along to its output. - * - * The block is designed for use with M-PSK signals especially. The - * type of estimator is specified as the \p type parameter in the - * constructor. The estimators tend to trade off performance for - * accuracy, although experimentation should be done to figure out - * the right approach for a given implementation. Further, the - * current set of estimators are designed and proven theoretically - * under AWGN conditions; some amount of error should be assumed - * and/or estimated for real channel conditions. - */ -class DIGITAL_API digital_mpsk_snr_est_cc : public gr_sync_block -{ - private: - snr_est_type_t d_type; - int d_nsamples, d_count; - double d_alpha; - digital_impl_mpsk_snr_est *d_snr_est; - - //d_key is the tag name, 'snr', d_me is the block name + unique ID - pmt::pmt_t d_key, d_me; - - /*! Factory function returning shared pointer of this class - * - * Parameters: - * - * \param type: the type of estimator to use \ref ref_snr_est_types - * "snr_est_type_t" for details about the available types. - * \param tag_nsamples: after this many samples, a tag containing - * the SNR (key='snr') will be sent - * \param alpha: the update rate of internal running average - * calculations. - */ - friend DIGITAL_API digital_mpsk_snr_est_cc_sptr - digital_make_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples, - double alpha); - - // Private constructor - digital_mpsk_snr_est_cc(snr_est_type_t type, - int tag_nsamples, - double alpha); - -public: - - ~digital_mpsk_snr_est_cc(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - //! Return the estimated signal-to-noise ratio in decibels - double snr(); - - //! Return the type of estimator in use - snr_est_type_t type() const; - - //! Return how many samples between SNR tags - int tag_nsample() const; - - //! Get the running-average coefficient - double alpha() const; - - //! Set type of estimator to use - void set_type(snr_est_type_t t); - - //! Set the number of samples between SNR tags - void set_tag_nsample(int n); - - //! Set the running-average coefficient - void set_alpha(double alpha); -}; - -#endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_CC_H */ diff --git a/gr-digital/include/digital_probe_density_b.h b/gr-digital/include/digital_probe_density_b.h deleted file mode 100644 index 271ad2a072..0000000000 --- a/gr-digital/include/digital_probe_density_b.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2012 Free Software Foundation, Inc. - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GR_PROBE_DENSITY_B_H -#define INCLUDED_GR_PROBE_DENSITY_B_H - -#include <digital_api.h> -#include <gr_sync_block.h> - -class digital_probe_density_b; - -typedef boost::shared_ptr<digital_probe_density_b> digital_probe_density_b_sptr; - -DIGITAL_API digital_probe_density_b_sptr -digital_make_probe_density_b(double alpha); - -/*! - * This block maintains a running average of the input stream and - * makes it available as an accessor function. The input stream - * is type unsigned char. - * - * If you send this block a stream of unpacked bytes, it will tell - * you what the bit density is. - * - * \param alpha Average filter constant - * - */ - -class DIGITAL_API digital_probe_density_b : public gr_sync_block -{ -private: - friend DIGITAL_API digital_probe_density_b_sptr - digital_make_probe_density_b(double alpha); - - double d_alpha; - double d_beta; - double d_density; - - digital_probe_density_b(double alpha); - -public: - ~digital_probe_density_b(); - - /*! - * \brief Returns the current density value - */ - double density() const { return d_density; } - - /*! - * \brief Set the average filter constant - */ - void set_alpha(double alpha); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_PROBE_DENSITY_B_H */ diff --git a/gr-digital/include/digital_probe_mpsk_snr_est_c.h b/gr-digital/include/digital_probe_mpsk_snr_est_c.h deleted file mode 100644 index a78e904124..0000000000 --- a/gr-digital/include/digital_probe_mpsk_snr_est_c.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H -#define INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H - -#include <digital_api.h> -#include <gr_sync_block.h> -#include <digital_impl_mpsk_snr_est.h> - -class digital_probe_mpsk_snr_est_c; -typedef boost::shared_ptr<digital_probe_mpsk_snr_est_c> digital_probe_mpsk_snr_est_c_sptr; - -DIGITAL_API digital_probe_mpsk_snr_est_c_sptr -digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, - int msg_nsamples=10000, - double alpha=0.001); - -//! \brief A probe for computing SNR of a signal. -/*! \ingroup snr_blk - * - * This is a probe block (a sink) that can be used to monitor and - * retrieve estimations of the signal SNR. This probe is designed for - * use with M-PSK signals especially. The type of estimator is - * specified as the \p type parameter in the constructor. The - * estimators tend to trade off performance for accuracy, although - * experimentation should be done to figure out the right approach - * for a given implementation. Further, the current set of estimators - * are designed and proven theoretically under AWGN conditions; some - * amount of error should be assumed and/or estimated for real - * channel conditions. - */ -class DIGITAL_API digital_probe_mpsk_snr_est_c : public gr_sync_block -{ - private: - snr_est_type_t d_type; - int d_nsamples, d_count; - double d_alpha; - digital_impl_mpsk_snr_est *d_snr_est; - - //d_key is the message name, 'snr' - pmt::pmt_t d_key; - - /*! Factory function returning shared pointer of this class - * - * Parameters: - * - * \param type: the type of estimator to use \ref ref_snr_est_types - * "snr_est_type_t" for details about the available types. - * \param msg_nsamples: [not implemented yet] after this many - * samples, a message containing the SNR (key='snr') will be sent - * \param alpha: the update rate of internal running average - * calculations. - */ - friend DIGITAL_API digital_probe_mpsk_snr_est_c_sptr - digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, - int msg_nsamples, - double alpha); - - //! Private constructor - digital_probe_mpsk_snr_est_c(snr_est_type_t type, - int msg_nsamples, - double alpha); - -public: - - ~digital_probe_mpsk_snr_est_c(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - //! Return the estimated signal-to-noise ratio in decibels - double snr(); - - //! Return the type of estimator in use - snr_est_type_t type() const; - - //! Return how many samples between SNR messages - int msg_nsample() const; - - //! Get the running-average coefficient - double alpha() const; - - //! Set type of estimator to use - void set_type(snr_est_type_t t); - - //! Set the number of samples between SNR messages - void set_msg_nsample(int n); - - //! Set the running-average coefficient - void set_alpha(double alpha); -}; - -#endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H */ |