GNU Radio Manual and C++ API Reference
3.7.5
The Free & Open Software Radio Ecosystem
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
34
namespace
gr {
35
namespace
fft {
36
37
38
/*! \brief Helper function for allocating complex* buffers
39
*/
40
FFT_API
gr_complex
*
malloc_complex
(
int
size);
41
42
/*! \brief Helper function for allocating float* buffers
43
*/
44
FFT_API
float
*
malloc_float
(
int
size);
45
46
/*! \brief Helper function for allocating double* buffers
47
*/
48
FFT_API
double
*
malloc_double
(
int
size);
49
50
/*! \brief Helper function for freeing fft buffers
51
*/
52
FFT_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
*/
58
class
FFT_API
planner
{
59
public
:
60
typedef
boost::mutex::scoped_lock
scoped_lock
;
61
/*!
62
* Return reference to planner mutex
63
*/
64
static
boost::mutex
&
mutex
();
65
};
66
67
/*!
68
* \brief FFT: complex in, complex out
69
* \ingroup misc
70
*/
71
class
FFT_API
fft_complex
{
72
int
d_fft_size;
73
int
d_nthreads;
74
gr_complex
*d_inbuf;
75
gr_complex
*d_outbuf;
76
void
*d_plan;
77
78
public
:
79
fft_complex
(
int
fft_size,
bool
forward =
true
,
int
nthreads=1);
80
virtual
~
fft_complex
();
81
82
/*
83
* These return pointers to buffers owned by fft_impl_fft_complex
84
* into which input and output take place. It's done this way in
85
* order to ensure optimal alignment for SIMD instructions.
86
*/
87
gr_complex
*
get_inbuf
()
const
{
return
d_inbuf; }
88
gr_complex
*
get_outbuf
()
const
{
return
d_outbuf; }
89
90
int
inbuf_length
()
const
{
return
d_fft_size; }
91
int
outbuf_length
()
const
{
return
d_fft_size; }
92
93
/*!
94
* Set the number of threads to use for caclulation.
95
*/
96
void
set_nthreads(
int
n);
97
98
/*!
99
* Get the number of threads being used by FFTW
100
*/
101
int
nthreads
()
const
{
return
d_nthreads; }
102
103
/*!
104
* compute FFT. The input comes from inbuf, the output is placed in
105
* outbuf.
106
*/
107
void
execute();
108
};
109
110
/*!
111
* \brief FFT: real in, complex out
112
* \ingroup misc
113
*/
114
class
FFT_API
fft_real_fwd
{
115
int
d_fft_size;
116
int
d_nthreads;
117
float
*d_inbuf;
118
gr_complex
*d_outbuf;
119
void
*d_plan;
120
121
public
:
122
fft_real_fwd
(
int
fft_size,
int
nthreads=1);
123
virtual
~
fft_real_fwd
();
124
125
/*
126
* These return pointers to buffers owned by fft_impl_fft_real_fwd
127
* into which input and output take place. It's done this way in
128
* order to ensure optimal alignment for SIMD instructions.
129
*/
130
float
*
get_inbuf
()
const
{
return
d_inbuf; }
131
gr_complex
*
get_outbuf
()
const
{
return
d_outbuf; }
132
133
int
inbuf_length
()
const
{
return
d_fft_size; }
134
int
outbuf_length
()
const
{
return
d_fft_size / 2 + 1; }
135
136
/*!
137
* Set the number of threads to use for caclulation.
138
*/
139
void
set_nthreads(
int
n);
140
141
/*!
142
* Get the number of threads being used by FFTW
143
*/
144
int
nthreads
()
const
{
return
d_nthreads; }
145
146
/*!
147
* compute FFT. The input comes from inbuf, the output is placed in
148
* outbuf.
149
*/
150
void
execute();
151
};
152
153
/*!
154
* \brief FFT: complex in, float out
155
* \ingroup misc
156
*/
157
class
FFT_API
fft_real_rev
{
158
int
d_fft_size;
159
int
d_nthreads;
160
gr_complex
*d_inbuf;
161
float
*d_outbuf;
162
void
*d_plan;
163
164
public
:
165
fft_real_rev
(
int
fft_size,
int
nthreads=1);
166
virtual
~
fft_real_rev
();
167
168
/*
169
* These return pointers to buffers owned by fft_impl_fft_real_rev
170
* into which input and output take place. It's done this way in
171
* order to ensure optimal alignment for SIMD instructions.
172
*/
173
gr_complex
*
get_inbuf
()
const
{
return
d_inbuf; }
174
float
*
get_outbuf
()
const
{
return
d_outbuf; }
175
176
int
inbuf_length
()
const
{
return
d_fft_size / 2 + 1; }
177
int
outbuf_length
()
const
{
return
d_fft_size; }
178
179
/*!
180
* Set the number of threads to use for caclulation.
181
*/
182
void
set_nthreads(
int
n);
183
184
/*!
185
* Get the number of threads being used by FFTW
186
*/
187
int
nthreads
()
const
{
return
d_nthreads; }
188
189
/*!
190
* compute FFT. The input comes from inbuf, the output is placed in
191
* outbuf.
192
*/
193
void
execute();
194
};
195
196
}
/* namespace fft */
197
}
/*namespace gr */
198
199
#endif
/* _FFT_FFT_H_ */
gr-fft
include
gnuradio
fft
fft.h
Generated on Fri Oct 3 2014 00:33:50 for GNU Radio Manual and C++ API Reference by
1.8.1.2