GNU Radio 3.5.3.2 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  * \class gr_dc_blocker_cc
52  * \brief a computationally efficient controllable DC blocker
53  *
54  * \ingroup filter_blk
55  *
56  * This block implements a computationally efficient DC blocker that produces
57  * a tighter notch filter around DC for a smaller group delay than an
58  * equivalent FIR filter or using a single pole IIR filter (though the IIR
59  * filter is computationally cheaper).
60  *
61  * The block defaults to using a delay line of length 32 and the long form
62  * of the filter. Optionally, the delay line length can be changed to alter
63  * the width of the DC notch (longer lines will decrease the width).
64  *
65  * The long form of the filter produces a nearly flat response outside of
66  * the notch but at the cost of a group delay of 2D-2.
67  *
68  * The short form of the filter does not have as flat a response in the
69  * passband but has a group delay of only D-1 and is cheaper to compute.
70  *
71  * The theory behind this block can be found in the paper:
72  *
73  * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine,
74  * Mar. 2008, pp 132-134.</EM></B>
75  */
77 {
78  private:
79  /*!
80  * Build the DC blocker.
81  * \param D (int) the length of the delay line
82  * \param long_form (bool) whether to use long (true, default) or short form
83  */
84  friend GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form);
85 
86  int d_length;
87  bool d_long_form;
88  moving_averager_c *d_ma_0;
89  moving_averager_c *d_ma_1;
90  moving_averager_c *d_ma_2;
91  moving_averager_c *d_ma_3;
92  std::deque<gr_complex> d_delay_line;
93 
94  gr_dc_blocker_cc (int D, bool long_form);
95 
96 public:
97  ~gr_dc_blocker_cc ();
98 
99  /*!
100  * Get the blocker's group delay that is based on length of delay lines
101  */
102  int get_group_delay();
103 
104  //int set_length(int D);
105 
106  int work (int noutput_items,
107  gr_vector_const_void_star &input_items,
108  gr_vector_void_star &output_items);
109 };
110 
111 #endif