4ffcd3771b4b3c69e964d7edc1fd13da944febdb
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_dd_mpsk_sync_cc.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004,2006 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
23 #ifndef INCLUDED_GR_DD_MPSK_SYNC_CC_H
24 #define INCLUDED_GR_DD_MPSK_SYNC_CC_H
25
26 #include <gr_sync_block.h>
27
28 class gri_mmse_fir_interpolator_cc;
29
30 class gr_dd_mpsk_sync_cc;
31 typedef boost::shared_ptr<gr_dd_mpsk_sync_cc> gr_dd_mpsk_sync_cc_sptr;
32
33 gr_dd_mpsk_sync_cc_sptr 
34 gr_make_dd_mpsk_sync_cc (float alpha, float beta,
35                          float max_freq, float min_freq, float ref_phase,
36                          float omega, float gain_omega, float mu, float gain_mu);
37
38 /*!
39  * \brief Decision directed M-PSK synchronous demod 
40  * \ingroup sync_blk
41  * This block performs joint carrier tracking and symbol timing recovery.
42  *
43  * input: complex baseband; output: properly timed complex samples ready for slicing.
44  *
45  * N.B, at this point, it handles only QPSK.
46  */
47
48 class gr_dd_mpsk_sync_cc : public gr_block
49 {
50   friend gr_dd_mpsk_sync_cc_sptr gr_make_dd_mpsk_sync_cc (float alpha, float beta,
51                                                           float max_freq, float min_freq, float ref_phase,
52                                                           float omega, float gain_omega, float mu, float gain_mu);
53 public:
54   ~gr_dd_mpsk_sync_cc ();
55   void forecast(int noutput_items, gr_vector_int &ninput_items_required);
56   float mu() const { return d_mu;}
57   float omega() const { return d_omega;}
58   float gain_mu() const { return d_gain_mu;}
59   float gain_omega() const { return d_gain_omega;}
60   
61   void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; }
62   void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; }
63   void set_mu (float mu) { d_mu = mu; }
64   void set_omega (float omega) { d_omega = omega; }
65
66 protected:
67   gr_dd_mpsk_sync_cc (float alpha, float beta, float max_freq, float min_freq, float ref_phase,
68                       float omega, float gain_omega, float mu, float gain_mu);
69   
70   int general_work (int noutput_items,
71                     gr_vector_int &ninput_items,
72                     gr_vector_const_void_star &input_items,
73                     gr_vector_void_star &output_items);
74   
75 private:
76   static const unsigned int DLLEN = 8;  // delay line length.
77
78   float d_alpha,d_beta,d_max_freq,d_min_freq,d_ref_phase;
79   float d_omega, d_gain_omega, d_mu, d_gain_mu;
80   float d_phase, d_freq;
81   gr_complex slicer_45deg (gr_complex sample);
82   gr_complex slicer_0deg (gr_complex sample);
83   gr_complex d_last_sample;
84   gri_mmse_fir_interpolator_cc  *d_interp;
85   
86   gr_complex d_dl[2 * DLLEN];   // Holds post carrier tracking samples.
87                                 // double length delay line to avoid wraps.
88   unsigned int d_dl_idx;        // indexes oldest sample in delay line.
89
90   float phase_detector(gr_complex sample,float ref_phase);
91 };
92
93 #endif