Merge commit 'v3.3.0' into upstream
[debian/gnuradio] / gr-atsc / src / lib / GrAtscBitTimingLoop2.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002 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 _GRATSCBITTIMINGLOOP2_H_
24 #define _GRATSCBITTIMINGLOOP2_H_
25
26 #include <gr_nco.h>
27 #include <VrSigProc.h>
28 #include <VrHistoryProc.h>
29 #include <VrDecimatingSigProc.h>
30 #include <interleaver_fifo.h>
31 #include <gr_single_pole_iir.h>
32 #include <gr_mmse_fir_interpolator.h>
33
34 /*!
35  * \brief ATSC BitTimingLoop
36  *
37  * This class accepts a single real input and produces a single real output
38  */
39
40 class GrAtscBitTimingLoop2 : public VrDecimatingSigProc<float,float> {
41
42  public:
43
44   GrAtscBitTimingLoop2 ();
45   virtual ~GrAtscBitTimingLoop2 () { };
46
47   virtual const char *name () { return "GrAtscBitTimingLoop2"; }
48
49   virtual int forecast (VrSampleRange output,
50                         VrSampleRange inputs[]);
51
52   virtual int work (VrSampleRange output, void *o[],
53                     VrSampleRange inputs[], void *i[]);
54
55   // debug
56   void set_mu (float a_mu) {
57     assert (0 <= a_mu && a_mu <= 1.9);
58     use_right_p = a_mu < 1.0;
59     mu = a_mu - floor (a_mu);
60     cerr << "BTL2:  mu: " << mu << " use_right_p: " << use_right_p << endl;
61   }
62
63  protected:
64
65   typedef float iType;
66   typedef float oType;
67
68   iType produce_sample (const iType *in, unsigned int &index);
69   float filter_error (float e);
70
71   VrSampleIndex                         next_input;
72   gr_single_pole_iir<float,float,float> dc;             // used to estimate DC component
73   gr_mmse_fir_interpolator              intr;
74   float                                 mu;             // fractional delay
75   iType                                 last_right;     // last right hand sample
76
77   bool                                  use_right_p;    // ...else middle
78 };
79
80 #endif // _GRATSCBITTIMINGLOOP2_H_