GNU Radio 3.5.3.2 C++ API
digital_probe_mpsk_snr_est_c.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2011 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 #ifndef INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H
23 #define INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H
24 
25 #include <digital_api.h>
26 #include <gr_sync_block.h>
28 
31 
34  int msg_nsamples=10000,
35  double alpha=0.001);
36 
37 //! \brief A probe for computing SNR of a signal.
38 /*! \ingroup snr_blk
39  *
40  * This is a probe block (a sink) that can be used to monitor and
41  * retrieve estimations of the signal SNR. This probe is designed for
42  * use with M-PSK signals especially. The type of estimator is
43  * specified as the \p type parameter in the constructor. The
44  * estimators tend to trade off performance for accuracy, although
45  * experimentation should be done to figure out the right approach
46  * for a given implementation. Further, the current set of estimators
47  * are designed and proven theoretically under AWGN conditions; some
48  * amount of error should be assumed and/or estimated for real
49  * channel conditions.
50  */
52 {
53  private:
54  snr_est_type_t d_type;
55  int d_nsamples, d_count;
56  double d_alpha;
57  digital_impl_mpsk_snr_est *d_snr_est;
58 
59  //d_key is the message name, 'snr'
60  pmt::pmt_t d_key;
61 
62  /*! Factory function returning shared pointer of this class
63  *
64  * Parameters:
65  *
66  * \param type: the type of estimator to use \ref ref_snr_est_types
67  * "snr_est_type_t" for details about the available types.
68  * \param msg_nsamples: [not implemented yet] after this many
69  * samples, a message containing the SNR (key='snr') will be sent
70  * \param alpha: the update rate of internal running average
71  * calculations.
72  */
75  int msg_nsamples,
76  double alpha);
77 
78  //! Private constructor
80  int msg_nsamples,
81  double alpha);
82 
83 public:
84 
86 
87  int work (int noutput_items,
88  gr_vector_const_void_star &input_items,
89  gr_vector_void_star &output_items);
90 
91  //! Return the estimated signal-to-noise ratio in decibels
92  double snr();
93 
94  //! Return the type of estimator in use
95  snr_est_type_t type() const;
96 
97  //! Return how many samples between SNR messages
98  int msg_nsample() const;
99 
100  //! Get the running-average coefficient
101  double alpha() const;
102 
103  //! Set type of estimator to use
104  void set_type(snr_est_type_t t);
105 
106  //! Set the number of samples between SNR messages
107  void set_msg_nsample(int n);
108 
109  //! Set the running-average coefficient
110  void set_alpha(double alpha);
111 };
112 
113 #endif /* INCLUDED_DIGITAL_PROBE_MPSK_SNR_EST_C_H */