GNU Radio 3.6.5.1 C++ API
gr_dc_blocker_cc.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2011 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_DC_BLOCKER_CC_H
25 #define INCLUDED_GR_DC_BLOCKER_CC_H
26 
27 #include <gr_core_api.h>
28 #include <gr_sync_block.h>
29 #include <deque>
30 
32 {
33 public:
34  moving_averager_c(int D);
36 
37  gr_complex filter(gr_complex x);
38  gr_complex delayed_sig() { return d_out; }
39 
40 private:
41  int d_length;
42  gr_complex d_out, d_out_d1, d_out_d2;
43  std::deque<gr_complex> d_delay_line;
44 };
45 
46 class gr_dc_blocker_cc;
48 GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true);
49 
50 /*!
51  * \brief a computationally efficient controllable DC blocker
52  *
53  * This block implements a computationally efficient DC blocker that produces
54  * a tighter notch filter around DC for a smaller group delay than an
55  * equivalent FIR filter or using a single pole IIR filter (though the IIR
56  * filter is computationally cheaper).
57  *
58  * The block defaults to using a delay line of length 32 and the long form
59  * of the filter. Optionally, the delay line length can be changed to alter
60  * the width of the DC notch (longer lines will decrease the width).
61  *
62  * The long form of the filter produces a nearly flat response outside of
63  * the notch but at the cost of a group delay of 2D-2.
64  *
65  * The short form of the filter does not have as flat a response in the
66  * passband but has a group delay of only D-1 and is cheaper to compute.
67  *
68  * The theory behind this block can be found in the paper:
69  *
70  * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine,
71  * Mar. 2008, pp 132-134.</EM></B>
72  */
74 {
75  private:
76  /*!
77  * Build the DC blocker.
78  * \param D (int) the length of the delay line
79  * \param long_form (bool) whether to use long (true, default) or short form
80  */
81  friend GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form);
82 
83  int d_length;
84  bool d_long_form;
85  moving_averager_c *d_ma_0;
86  moving_averager_c *d_ma_1;
87  moving_averager_c *d_ma_2;
88  moving_averager_c *d_ma_3;
89  std::deque<gr_complex> d_delay_line;
90 
91  gr_dc_blocker_cc (int D, bool long_form);
92 
93 public:
94  ~gr_dc_blocker_cc ();
95 
96  /*!
97  * Get the blocker's group delay that is based on length of delay lines
98  */
99  int get_group_delay();
100 
101  //int set_length(int D);
102 
103  int work (int noutput_items,
104  gr_vector_const_void_star &input_items,
105  gr_vector_void_star &output_items);
106 };
107 
108 #endif