GNU Radio 3.6.5 C++ API

gr_dc_blocker_ff.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_FF_H
00025 #define INCLUDED_GR_DC_BLOCKER_FF_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_f
00032 {
00033 public:
00034   moving_averager_f(int D);
00035   ~moving_averager_f();
00036 
00037   float filter(float x);
00038   float delayed_sig() { return d_out; }
00039 
00040 private:
00041   int d_length;
00042   float d_out, d_out_d1, d_out_d2;
00043   std::deque<float> d_delay_line;
00044 };
00045 
00046 
00047 class gr_dc_blocker_ff;
00048 typedef boost::shared_ptr<gr_dc_blocker_ff> gr_dc_blocker_ff_sptr;
00049 GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true);
00050 
00051 /*!
00052  * \brief a computationally efficient controllable DC blocker
00053  *
00054  * This block implements a computationally efficient DC blocker that produces
00055  * a tighter notch filter around DC for a smaller group delay than an
00056  * equivalent FIR filter or using a single pole IIR filter (though the IIR
00057  * filter is computationally cheaper).
00058  *
00059  * The block defaults to using a delay line of length 32 and the long form
00060  * of the filter. Optionally, the delay line length can be changed to alter
00061  * the width of the DC notch (longer lines will decrease the width).
00062  *
00063  * The long form of the filter produces a nearly flat response outside of
00064  * the notch but at the cost of a group delay of 2D-2.
00065  *
00066  * The short form of the filter does not have as flat a response in the
00067  * passband but has a group delay of only D-1 and is cheaper to compute.
00068  *
00069  * The theory behind this block can be found in the paper:
00070  *
00071  *    <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine,
00072  *        Mar. 2008, pp 132-134.</EM></B>
00073  */
00074 class GR_CORE_API gr_dc_blocker_ff : public gr_sync_block
00075 {
00076  private:
00077   /*!
00078    * Build the DC blocker.
00079    * \param D          (int) the length of the delay line
00080    * \param long_form  (bool) whether to use long (true, default) or short form
00081    */
00082   friend GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D, bool long_form);
00083 
00084   int d_length;
00085   bool d_long_form;
00086   moving_averager_f *d_ma_0;
00087   moving_averager_f *d_ma_1;
00088   moving_averager_f *d_ma_2;
00089   moving_averager_f *d_ma_3;
00090   std::deque<float> d_delay_line;
00091 
00092   gr_dc_blocker_ff (int D, bool long_form);
00093 
00094 public:
00095   ~gr_dc_blocker_ff ();
00096 
00097   /*!
00098    * Get the blocker's group delay that is based on length of delay lines
00099    */
00100   int get_group_delay();
00101 
00102   //int set_length(int D);
00103 
00104   int work (int noutput_items,
00105             gr_vector_const_void_star &input_items,
00106             gr_vector_void_star &output_items);
00107 };
00108 
00109 #endif