Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_clock_recovery_mm_ff.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2004 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 2, 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_CLOCK_RECOVERY_MM_FF_H
24 #define INCLUDED_GR_CLOCK_RECOVERY_MM_FF_H
25
26 #include <gr_block.h>
27 #include <stdio.h>
28
29 class gri_mmse_fir_interpolator;
30
31 class gr_clock_recovery_mm_ff;
32 typedef boost::shared_ptr<gr_clock_recovery_mm_ff> gr_clock_recovery_mm_ff_sptr;
33
34 // public constructor
35 gr_clock_recovery_mm_ff_sptr 
36 gr_make_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu,
37                               float omega_relative_limit=0.001);
38
39 /*!
40  * \brief Mueller and Müller (M&M) based clock recovery block with float input, float output.
41  * \ingroup block
42  *
43  * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer.
44  *
45  * See "Digital Communication Receivers: Synchronization, Channel
46  * Estimation and Signal Processing" by Heinrich Meyr, Marc Moeneclaey, & Stefan Fechtel.
47  * ISBN 0-471-50275-8.
48  */
49 class gr_clock_recovery_mm_ff : public gr_block
50 {
51  public:
52   ~gr_clock_recovery_mm_ff ();
53   void forecast(int noutput_items, gr_vector_int &ninput_items_required);
54   int general_work (int noutput_items,
55                     gr_vector_int &ninput_items,
56                     gr_vector_const_void_star &input_items,
57                     gr_vector_void_star &output_items);
58   float mu() const { return d_mu;}
59   float omega() const { return d_omega;}
60   float gain_mu() const { return d_gain_mu;}
61   float gain_omega() const { return d_gain_omega;}
62
63   void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; }
64   void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; }
65   void set_mu (float mu) { d_mu = mu; }
66   void set_omega (float omega){
67     d_omega = omega;
68     d_min_omega = omega*(1.0 - d_omega_relative_limit);
69     d_max_omega = omega*(1.0 + d_omega_relative_limit);
70   }
71
72 protected:
73   gr_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu,
74                            float omega_relative_limit);
75
76  private:
77   float                         d_mu;           // fractional sample position [0.0, 1.0]
78   float                         d_omega;        // nominal frequency
79   float                         d_min_omega;    // minimum allowed omega
80   float                         d_max_omega;    // maximum allowed omega
81   float                         d_gain_omega;   // gain for adjusting omega
82   float                         d_gain_mu;      // gain for adjusting mu
83   float                         d_last_sample;
84   gri_mmse_fir_interpolator     *d_interp;
85   FILE                          *d_logfile;
86   float                         d_omega_relative_limit; // used to compute min and max omega
87
88   friend gr_clock_recovery_mm_ff_sptr
89   gr_make_clock_recovery_mm_ff (float omega, float gain_omega, float mu, float gain_mu,
90                                 float omega_relative_limit);
91 };
92
93 #endif