GNU Radio 3.6.0 C++ API
gri_fft_filter_ccc_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_CCC_GENERIC_H
00024 #define INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H
00025 
00026 #include <gr_core_api.h>
00027 #include <gr_complex.h>
00028 #include <vector>
00029 
00030 class gri_fft_complex;
00031 
00032 /*!
00033  * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps
00034  * \ingroup filter_blk
00035  */
00036 class GR_CORE_API gri_fft_filter_ccc_generic
00037 {
00038  private:
00039   int                      d_ntaps;
00040   int                      d_nsamples;
00041   int                      d_fftsize;           // fftsize = ntaps + nsamples - 1
00042   int                      d_decimation;
00043   gri_fft_complex         *d_fwdfft;            // forward "plan"
00044   gri_fft_complex         *d_invfft;            // inverse "plan"
00045   int                      d_nthreads;          // number of FFTW threads to use
00046   std::vector<gr_complex>  d_tail;              // state carried between blocks for overlap-add
00047   std::vector<gr_complex>  d_new_taps;
00048   gr_complex              *d_xformed_taps;      // Fourier xformed taps
00049 
00050   void compute_sizes(int ntaps);
00051   int tailsize() const { return d_ntaps - 1; }
00052 
00053  public:
00054   /*!
00055    * \brief Construct an FFT filter for complex vectors with the given taps and decimation rate.
00056    *
00057    * This is the basic implementation for performing FFT filter for fast convolution
00058    * in other blocks for complex vectors (such as gr_fft_filter_ccc).
00059    * \param decimation The decimation rate of the filter (int)
00060    * \param taps       The filter taps (complex)
00061    * \param nthreads   The number of threads for the FFT to use (int)
00062    */
00063   gri_fft_filter_ccc_generic (int decimation, const std::vector<gr_complex> &taps,
00064                               int nthreads=1);
00065   ~gri_fft_filter_ccc_generic ();
00066 
00067   /*!
00068    * \brief Set new taps for the filter.
00069    *
00070    * Sets new taps and resets the class properties to handle different sizes
00071    * \param taps       The filter taps (complex)
00072    */
00073   int set_taps (const std::vector<gr_complex> &taps);
00074 
00075   /*!
00076    * \brief Set number of threads to use.
00077    */
00078   void set_nthreads(int n);
00079 
00080   /*!
00081    * \brief Get number of threads being used.
00082    */
00083   int nthreads() const;
00084 
00085   /*!
00086    * \brief Perform the filter operation
00087    *
00088    * \param nitems  The number of items to produce
00089    * \param input   The input vector to be filtered
00090    * \param output  The result of the filter operation
00091    */
00092   int filter (int nitems, const gr_complex *input, gr_complex *output);
00093 
00094 };
00095 
00096 #endif /* INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H */