GNU Radio C++ API
gri_fft.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2003,2008 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 #ifndef _GRI_FFT_H_
23 #define _GRI_FFT_H_
24 
25 /*
26  * Wrappers for FFTW single precision 1d dft
27  */
28 
29 #include <gr_core_api.h>
30 #include <gr_complex.h>
31 #include <boost/thread.hpp>
32 
33 /*!
34  * \brief Export reference to planner mutex for those apps that
35  * want to use FFTW w/o using the gri_fftw* classes.
36  */
38 public:
40  /*!
41  * Return reference to planner mutex
42  */
43  static boost::mutex &mutex();
44 };
45 
46 /*!
47  * \brief FFT: complex in, complex out
48  * \ingroup misc
49  */
51  int d_fft_size;
52  gr_complex *d_inbuf;
53  gr_complex *d_outbuf;
54  void *d_plan;
55 
56 public:
57  gri_fft_complex (int fft_size, bool forward = true);
58  virtual ~gri_fft_complex ();
59 
60  /*
61  * These return pointers to buffers owned by gri_fft_complex into which
62  * input and output take place. It's done this way in order to
63  * ensure optimal alignment for SIMD instructions.
64  */
65  gr_complex *get_inbuf () const { return d_inbuf; }
66  gr_complex *get_outbuf () const { return d_outbuf; }
67 
68  int inbuf_length () const { return d_fft_size; }
69  int outbuf_length () const { return d_fft_size; }
70 
71  /*!
72  * compute FFT. The input comes from inbuf, the output is placed in outbuf.
73  */
74  void execute ();
75 };
76 
77 /*!
78  * \brief FFT: real in, complex out
79  * \ingroup misc
80  */
82  int d_fft_size;
83  float *d_inbuf;
84  gr_complex *d_outbuf;
85  void *d_plan;
86 
87 public:
88  gri_fft_real_fwd (int fft_size);
89  virtual ~gri_fft_real_fwd ();
90 
91  /*
92  * These return pointers to buffers owned by gri_fft_real_fwd into
93  * which input and output take place. It's done this way in order
94  * to ensure optimal alignment for SIMD instructions.
95  */
96  float *get_inbuf () const { return d_inbuf; }
97  gr_complex *get_outbuf () const { return d_outbuf; }
98 
99  int inbuf_length () const { return d_fft_size; }
100  int outbuf_length () const { return d_fft_size / 2 + 1; }
101 
102  /*!
103  * compute FFT. The input comes from inbuf, the output is placed in outbuf.
104  */
105  void execute ();
106 };
107 
108 /*!
109  * \brief FFT: complex in, float out
110  * \ingroup misc
111  */
113  int d_fft_size;
114  gr_complex *d_inbuf;
115  float *d_outbuf;
116  void *d_plan;
117 
118 public:
119  gri_fft_real_rev (int fft_size);
120  virtual ~gri_fft_real_rev ();
121 
122  /*
123  * These return pointers to buffers owned by gri_fft_real_rev into
124  * which input and output take place. It's done this way in order
125  * to ensure optimal alignment for SIMD instructions.
126  */
127  gr_complex *get_inbuf () const { return d_inbuf; }
128  float *get_outbuf () const { return d_outbuf; }
129 
130  int inbuf_length () const { return d_fft_size / 2 + 1; }
131  int outbuf_length () const { return d_fft_size; }
132 
133  /*!
134  * compute FFT. The input comes from inbuf, the output is placed in outbuf.
135  */
136  void execute ();
137 };
138 
139 #endif