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