GNU Radio 3.4.0 C++ API
gri_fft_filter_fff_generic.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2010 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 #ifndef INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H
00024 #define INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H
00025 
00026 #include <gr_complex.h>
00027 #include <vector>
00028 
00029 class gri_fft_real_fwd;
00030 class gri_fft_real_rev;
00031 
00032 class gri_fft_filter_fff_generic
00033 {
00034  private:
00035   int                      d_ntaps;
00036   int                      d_nsamples;
00037   int                      d_fftsize;           // fftsize = ntaps + nsamples - 1
00038   int                      d_decimation;
00039   gri_fft_real_fwd        *d_fwdfft;            // forward "plan"
00040   gri_fft_real_rev        *d_invfft;            // inverse "plan"
00041   std::vector<float>       d_tail;              // state carried between blocks for overlap-add
00042   std::vector<gr_complex>  d_xformed_taps;      // Fourier xformed taps
00043   std::vector<float>       d_new_taps;
00044 
00045 
00046   void compute_sizes(int ntaps);
00047   int tailsize() const { return d_ntaps - 1; }
00048   
00049  public:
00050   /*!
00051    * \brief Construct a FFT filter for float vectors with the given taps and decimation rate.
00052    *
00053    * This is the basic implementation for performing FFT filter for fast convolution
00054    * in other blocks for floating point vectors (such as gr_fft_filter_fff).
00055    * \param decimation The decimation rate of the filter (int)
00056    * \param taps       The filter taps (float)
00057    */
00058   gri_fft_filter_fff_generic (int decimation, const std::vector<float> &taps);
00059   ~gri_fft_filter_fff_generic ();
00060 
00061   /*!
00062    * \brief Set new taps for the filter.
00063    *
00064    * Sets new taps and resets the class properties to handle different sizes
00065    * \param taps       The filter taps (float)
00066    */
00067   int set_taps (const std::vector<float> &taps);
00068   
00069   /*!
00070    * \brief Perform the filter operation
00071    *
00072    * \param nitems  The number of items to produce
00073    * \param input   The input vector to be filtered
00074    * \param output  The result of the filter operation
00075    */
00076   int filter (int nitems, const float *input, float *output);
00077 
00078 };
00079 
00080 #endif /* INCLUDED_GRI_FFT_FILTER_FFF_GENERIC_H */