GNU Radio 3.6.5 C++ API

gr_dc_blocker_cc.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2011 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  *
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 
00024 #ifndef INCLUDED_GR_DC_BLOCKER_CC_H
00025 #define INCLUDED_GR_DC_BLOCKER_CC_H
00026 
00027 #include <gr_core_api.h>
00028 #include <gr_sync_block.h>
00029 #include <deque>
00030 
00031 class GR_CORE_API moving_averager_c
00032 {
00033 public:
00034   moving_averager_c(int D);
00035   ~moving_averager_c();
00036 
00037   gr_complex filter(gr_complex x);
00038   gr_complex delayed_sig() { return d_out; }
00039 
00040 private:
00041   int d_length;
00042   gr_complex d_out, d_out_d1, d_out_d2;
00043   std::deque<gr_complex> d_delay_line;
00044 };
00045 
00046 class gr_dc_blocker_cc;
00047 typedef boost::shared_ptr<gr_dc_blocker_cc> gr_dc_blocker_cc_sptr;
00048 GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true);
00049 
00050 /*!
00051  * \brief a computationally efficient controllable DC blocker
00052  *
00053  * This block implements a computationally efficient DC blocker that produces
00054  * a tighter notch filter around DC for a smaller group delay than an
00055  * equivalent FIR filter or using a single pole IIR filter (though the IIR
00056  * filter is computationally cheaper).
00057  *
00058  * The block defaults to using a delay line of length 32 and the long form
00059  * of the filter. Optionally, the delay line length can be changed to alter
00060  * the width of the DC notch (longer lines will decrease the width).
00061  *
00062  * The long form of the filter produces a nearly flat response outside of
00063  * the notch but at the cost of a group delay of 2D-2.
00064  *
00065  * The short form of the filter does not have as flat a response in the
00066  * passband but has a group delay of only D-1 and is cheaper to compute.
00067  *
00068  * The theory behind this block can be found in the paper:
00069  *
00070  *    <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine,
00071  *        Mar. 2008, pp 132-134.</EM></B>
00072  */
00073 class GR_CORE_API gr_dc_blocker_cc : public gr_sync_block
00074 {
00075  private:
00076   /*!
00077    * Build the DC blocker.
00078    * \param D          (int) the length of the delay line
00079    * \param long_form  (bool) whether to use long (true, default) or short form
00080    */
00081   friend GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D, bool long_form);
00082 
00083   int d_length;
00084   bool d_long_form;
00085   moving_averager_c *d_ma_0;
00086   moving_averager_c *d_ma_1;
00087   moving_averager_c *d_ma_2;
00088   moving_averager_c *d_ma_3;
00089   std::deque<gr_complex> d_delay_line;
00090 
00091   gr_dc_blocker_cc (int D, bool long_form);
00092 
00093 public:
00094   ~gr_dc_blocker_cc ();
00095 
00096   /*!
00097    * Get the blocker's group delay that is based on length of delay lines
00098    */
00099   int get_group_delay();
00100 
00101   //int set_length(int D);
00102 
00103   int work (int noutput_items,
00104             gr_vector_const_void_star &input_items,
00105             gr_vector_void_star &output_items);
00106 };
00107 
00108 #endif