Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_probe_mpsk_snr_c.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008 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_GR_PROBE_MPSK_SNR_C_H
23 #define INCLUDED_GR_PROBE_MPSK_SNR_C_H
24
25 #include <gr_sync_block.h>
26
27 class gr_probe_mpsk_snr_c;
28 typedef boost::shared_ptr<gr_probe_mpsk_snr_c> gr_probe_mpsk_snr_c_sptr;
29
30 gr_probe_mpsk_snr_c_sptr
31 gr_make_probe_mpsk_snr_c(double alpha = 0.0001);
32
33 /*!
34  * Compute the estimate SNR of an MPSK signal using the Squared Signal
35  * to Noise Variance (SNV) technique.
36  *
37  * This technique assumes an AWGN channel.
38  *
39  * \param alpha  Mean and variance smoothing filter constant
40  * \ingroup sink_blk
41  *
42  * Compute the running average of the signal mean and noise variance.
43  * The estimated signal mean, noise variance, and SNR are available
44  * via accessors.
45  *
46  * This SNR estimator is inaccurate below about 7dB SNR.
47  *
48  */
49 class gr_probe_mpsk_snr_c : public gr_sync_block
50 {
51   double d_alpha;
52   double d_beta;
53   double d_signal_mean;
54   double d_noise_variance;
55
56   // Factory function returning shared pointer of this class
57   friend gr_probe_mpsk_snr_c_sptr
58   gr_make_probe_mpsk_snr_c(double alpha);
59
60   // Private constructor
61   gr_probe_mpsk_snr_c(double alpha);
62
63 public:
64   ~gr_probe_mpsk_snr_c();
65
66   int work (int noutput_items,
67             gr_vector_const_void_star &input_items,
68             gr_vector_void_star &output_items);
69
70   // Return the estimated signal mean
71   double signal_mean() const { return d_signal_mean; }
72
73   // Return the estimated noise variance
74   double noise_variance() const { return d_noise_variance; }
75
76   // Return the estimated signal-to-noise ratio in decibels
77   double snr() const;
78
79   void set_alpha(double alpha);
80 };
81
82 #endif /* INCLUDED_GR_PROBE_MPSK_SNR_C_H */