Changinging behavior of parameter update for PFB clock recovery alg.
[debian/gnuradio] / gnuradio-core / src / lib / filter / gr_pfb_clock_sync_ccf.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009 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
24 #ifndef INCLUDED_GR_PFB_CLOCK_SYNC_CCF_H
25 #define INCLUDED_GR_PFB_CLOCK_SYNC_CCF_H
26
27 #include <gr_block.h>
28
29 class gr_pfb_clock_sync_ccf;
30 typedef boost::shared_ptr<gr_pfb_clock_sync_ccf> gr_pfb_clock_sync_ccf_sptr;
31 gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
32                                                        const std::vector<float> &taps,
33                                                        unsigned int filter_size=32,
34                                                        float init_phase=0);
35
36 class gr_fir_ccf;
37
38 /*!
39  * \class gr_pfb_clock_sync_ccf
40  *
41  * \brief Timing synchronizer using polyphase filterbanks
42  *
43  * \ingroup filter_blk
44  * 
45  */
46
47 class gr_pfb_clock_sync_ccf : public gr_block
48 {
49  private:
50   /*!
51    * Build the polyphase filterbank timing synchronizer.
52    */
53   friend gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (float sps, float gain,
54                                                                 const std::vector<float> &taps,
55                                                                 unsigned int filter_size,
56                                                                 float init_phase);
57
58   bool                     d_updated;
59   unsigned int             d_sps;
60   float                    d_alpha;
61   float                    d_beta;
62   unsigned int             d_nfilters;
63   std::vector<gr_fir_ccf*> d_filters;
64   std::vector<gr_fir_ccf*> d_diff_filters;
65   std::vector< std::vector<float> > d_taps;
66   std::vector< std::vector<float> > d_dtaps;
67   float                    d_k;
68   float                    d_rate;
69   unsigned int             d_start_count;
70   unsigned int             d_taps_per_filter;
71
72   /*!
73    * Build the polyphase filterbank timing synchronizer.
74    */
75   gr_pfb_clock_sync_ccf (float sps, float gain,
76                          const std::vector<float> &taps,
77                          unsigned int filter_size,
78                          float init_phase);
79   
80   void create_diff_taps(const std::vector<float> &newtaps,
81                         std::vector<float> &difftaps);
82
83 public:
84   ~gr_pfb_clock_sync_ccf ();
85   
86   /*!
87    * Resets the filterbank's filter taps with the new prototype filter
88    */
89   void set_taps (const std::vector<float> &taps,
90                  std::vector< std::vector<float> > &ourtaps,
91                  std::vector<gr_fir_ccf*> &ourfilter);
92   std::vector<float> channel_taps(int channel);
93   std::vector<float> diff_channel_taps(int channel);
94
95   /*!
96    * Print all of the filterbank taps to screen.
97    */
98   void print_taps();
99   void print_diff_taps();
100
101   void set_gain(float gain)
102   { 
103     d_alpha = gain;
104     d_beta = 0.25*d_alpha*d_alpha;
105   }
106   
107   int general_work (int noutput_items,
108                     gr_vector_int &ninput_items,
109                     gr_vector_const_void_star &input_items,
110                     gr_vector_void_star &output_items);
111 };
112
113 #endif