GNU Radio 3.6.5.1 C++ API
gri_fft_filter_ccc_generic.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2010 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 #ifndef INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H
24 #define INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H
25 
26 #include <gr_core_api.h>
27 #include <gr_complex.h>
28 #include <vector>
29 
30 class gri_fft_complex;
31 
32 /*!
33  * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps
34  */
36 {
37  private:
38  int d_ntaps;
39  int d_nsamples;
40  int d_fftsize; // fftsize = ntaps + nsamples - 1
41  int d_decimation;
42  gri_fft_complex *d_fwdfft; // forward "plan"
43  gri_fft_complex *d_invfft; // inverse "plan"
44  int d_nthreads; // number of FFTW threads to use
45  std::vector<gr_complex> d_tail; // state carried between blocks for overlap-add
46  std::vector<gr_complex> d_new_taps;
47  gr_complex *d_xformed_taps; // Fourier xformed taps
48 
49  void compute_sizes(int ntaps);
50  int tailsize() const { return d_ntaps - 1; }
51 
52  public:
53  /*!
54  * \brief Construct an FFT filter for complex vectors with the given taps and decimation rate.
55  *
56  * This is the basic implementation for performing FFT filter for fast convolution
57  * in other blocks for complex vectors (such as gr_fft_filter_ccc).
58  * \param decimation The decimation rate of the filter (int)
59  * \param taps The filter taps (complex)
60  * \param nthreads The number of threads for the FFT to use (int)
61  */
62  gri_fft_filter_ccc_generic (int decimation, const std::vector<gr_complex> &taps,
63  int nthreads=1);
65 
66  /*!
67  * \brief Set new taps for the filter.
68  *
69  * Sets new taps and resets the class properties to handle different sizes
70  * \param taps The filter taps (complex)
71  */
72  int set_taps (const std::vector<gr_complex> &taps);
73 
74  /*!
75  * \brief Set number of threads to use.
76  */
77  void set_nthreads(int n);
78 
79  /*!
80  * \brief Get number of threads being used.
81  */
82  int nthreads() const;
83 
84  /*!
85  * \brief Perform the filter operation
86  *
87  * \param nitems The number of items to produce
88  * \param input The input vector to be filtered
89  * \param output The result of the filter operation
90  */
91  int filter (int nitems, const gr_complex *input, gr_complex *output);
92 
93 };
94 
95 #endif /* INCLUDED_GRI_FFT_FILTER_CCC_GENERIC_H */