GNU Radio Manual and C++ API Reference 3.8.5.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
fft.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2003,2008,2012 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 _FFT_FFT_H_
24#define _FFT_FFT_H_
25
26/*
27 * Wrappers for FFTW single precision 1d dft
28 */
29
30#include <gnuradio/fft/api.h>
31#include <gnuradio/gr_complex.h>
32#include <boost/thread.hpp>
33
34namespace gr {
35namespace fft {
36
37
38/*! \brief Helper function for allocating complex* buffers
39 */
41
42/*! \brief Helper function for allocating float* buffers
43 */
44FFT_API float* malloc_float(int size);
45
46/*! \brief Helper function for allocating double* buffers
47 */
48FFT_API double* malloc_double(int size);
49
50/*! \brief Helper function for freeing fft buffers
51 */
52FFT_API void free(void* b);
53
54/*!
55 * \brief Export reference to planner mutex for those apps that
56 * want to use FFTW w/o using the fft_impl_fftw* classes.
57 */
59{
60public:
61 typedef boost::mutex::scoped_lock scoped_lock;
62 /*!
63 * Return reference to planner mutex
64 */
65 static boost::mutex& mutex();
66};
67
68/*!
69 * \brief FFT: complex in, complex out
70 * \ingroup misc
71 */
73{
74 int d_fft_size;
75 int d_nthreads;
76 gr_complex* d_inbuf;
77 gr_complex* d_outbuf;
78 void* d_plan;
79
80public:
81 fft_complex(int fft_size, bool forward = true, int nthreads = 1);
82 virtual ~fft_complex();
83
84 /*
85 * These return pointers to buffers owned by fft_impl_fft_complex
86 * into which input and output take place. It's done this way in
87 * order to ensure optimal alignment for SIMD instructions.
88 */
89 gr_complex* get_inbuf() const { return d_inbuf; }
90 gr_complex* get_outbuf() const { return d_outbuf; }
91
92 int inbuf_length() const { return d_fft_size; }
93 int outbuf_length() const { return d_fft_size; }
94
95 /*!
96 * Set the number of threads to use for caclulation.
97 */
98 void set_nthreads(int n);
99
100 /*!
101 * Get the number of threads being used by FFTW
102 */
103 int nthreads() const { return d_nthreads; }
104
105 /*!
106 * compute FFT. The input comes from inbuf, the output is placed in
107 * outbuf.
108 */
109 void execute();
110};
111
112/*!
113 * \brief FFT: real in, complex out
114 * \ingroup misc
115 */
117{
118 int d_fft_size;
119 int d_nthreads;
120 float* d_inbuf;
121 gr_complex* d_outbuf;
122 void* d_plan;
123
124public:
125 fft_real_fwd(int fft_size, int nthreads = 1);
126 virtual ~fft_real_fwd();
127
128 /*
129 * These return pointers to buffers owned by fft_impl_fft_real_fwd
130 * into which input and output take place. It's done this way in
131 * order to ensure optimal alignment for SIMD instructions.
132 */
133 float* get_inbuf() const { return d_inbuf; }
134 gr_complex* get_outbuf() const { return d_outbuf; }
135
136 int inbuf_length() const { return d_fft_size; }
137 int outbuf_length() const { return d_fft_size / 2 + 1; }
138
139 /*!
140 * Set the number of threads to use for caclulation.
141 */
142 void set_nthreads(int n);
143
144 /*!
145 * Get the number of threads being used by FFTW
146 */
147 int nthreads() const { return d_nthreads; }
148
149 /*!
150 * compute FFT. The input comes from inbuf, the output is placed in
151 * outbuf.
152 */
153 void execute();
154};
155
156/*!
157 * \brief FFT: complex in, float out
158 * \ingroup misc
159 */
161{
162 int d_fft_size;
163 int d_nthreads;
164 gr_complex* d_inbuf;
165 float* d_outbuf;
166 void* d_plan;
167
168public:
169 fft_real_rev(int fft_size, int nthreads = 1);
170 virtual ~fft_real_rev();
171
172 /*
173 * These return pointers to buffers owned by fft_impl_fft_real_rev
174 * into which input and output take place. It's done this way in
175 * order to ensure optimal alignment for SIMD instructions.
176 */
177 gr_complex* get_inbuf() const { return d_inbuf; }
178 float* get_outbuf() const { return d_outbuf; }
179
180 int inbuf_length() const { return d_fft_size / 2 + 1; }
181 int outbuf_length() const { return d_fft_size; }
182
183 /*!
184 * Set the number of threads to use for caclulation.
185 */
186 void set_nthreads(int n);
187
188 /*!
189 * Get the number of threads being used by FFTW
190 */
191 int nthreads() const { return d_nthreads; }
192
193 /*!
194 * compute FFT. The input comes from inbuf, the output is placed in
195 * outbuf.
196 */
197 void execute();
198};
199
200} /* namespace fft */
201} /*namespace gr */
202
203#endif /* _FFT_FFT_H_ */
FFT: complex in, complex out.
Definition fft.h:73
int inbuf_length() const
Definition fft.h:92
int nthreads() const
Definition fft.h:103
gr_complex * get_inbuf() const
Definition fft.h:89
fft_complex(int fft_size, bool forward=true, int nthreads=1)
int outbuf_length() const
Definition fft.h:93
void set_nthreads(int n)
gr_complex * get_outbuf() const
Definition fft.h:90
FFT: real in, complex out.
Definition fft.h:117
gr_complex * get_outbuf() const
Definition fft.h:134
float * get_inbuf() const
Definition fft.h:133
void set_nthreads(int n)
int inbuf_length() const
Definition fft.h:136
int nthreads() const
Definition fft.h:147
fft_real_fwd(int fft_size, int nthreads=1)
int outbuf_length() const
Definition fft.h:137
FFT: complex in, float out.
Definition fft.h:161
float * get_outbuf() const
Definition fft.h:178
int nthreads() const
Definition fft.h:191
fft_real_rev(int fft_size, int nthreads=1)
gr_complex * get_inbuf() const
Definition fft.h:177
int inbuf_length() const
Definition fft.h:180
int outbuf_length() const
Definition fft.h:181
void set_nthreads(int n)
Export reference to planner mutex for those apps that want to use FFTW w/o using the fft_impl_fftw* c...
Definition fft.h:59
static boost::mutex & mutex()
boost::mutex::scoped_lock scoped_lock
Definition fft.h:61
#define FFT_API
Definition gr-fft/include/gnuradio/fft/api.h:30
std::complex< float > gr_complex
Definition gr_complex.h:27
FFT_API double * malloc_double(int size)
Helper function for allocating double* buffers.
FFT_API gr_complex * malloc_complex(int size)
Helper function for allocating complex* buffers.
FFT_API float * malloc_float(int size)
Helper function for allocating float* buffers.
FFT_API void free(void *b)
Helper function for freeing fft buffers.
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition basic_block.h:46