GNU Radio C++ API Reference: fft.h Source File

| GNU Radio C++ API Reference 3.10.12.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,2020 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef _FFT_FFT_H_
12#define _FFT_FFT_H_
13
14/*
15 * Wrappers for FFTW single precision 1d dft
16 */
17
18#include <gnuradio/fft/api.h>
19#include <gnuradio/gr_complex.h>
20#include <gnuradio/logger.h>
21#include <volk/volk_alloc.hh>
22#include <mutex>
23
24namespace gr {
25namespace fft {
26
27/*!
28 * \brief Export reference to planner mutex for those apps that
29 * want to use FFTW w/o using the fft_impl_fftw* classes.
30 */
31 class FFT_API planner
32{
33public:
34 /*!
35 * Return reference to planner mutex
36 */
37 static std::mutex& mutex();
38};
39
40
41/*!
42 \brief FFT: templated
43 \ingroup misc
44 */
45
46
47template <class T, bool forward>
48 struct fft_inbuf {
49 typedef T type;
50};
51
52template <>
53 struct fft_inbuf<float, false> {
54 typedef gr_complex type;
55};
56
57
58template <class T, bool forward>
59 struct fft_outbuf {
60 typedef T type;
61};
62
63template <>
64 struct fft_outbuf<float, true> {
65 typedef gr_complex type;
66};
67
68template <class T, bool forward>
69 class FFT_API fft
70{
71 int d_nthreads;
72 volk::vector<typename fft_inbuf<T, forward>::type> d_inbuf;
73 volk::vector<typename fft_outbuf<T, forward>::type> d_outbuf;
74 void* d_plan;
75 gr::logger d_logger;
76 void initialize_plan(int fft_size);
77
78public:
79 fft(int fft_size, int nthreads = 1);
80 // Copy disabled due to d_plan.
81 fft(const fft&) = delete;
82 fft& operator=(const fft&) = delete;
83 virtual ~fft();
84
85 /*
86 * These return pointers to buffers owned by fft_impl_fft_complex
87 * into which input and output take place. It's done this way in
88 * order to ensure optimal alignment for SIMD instructions.
89 */
90 typename fft_inbuf<T, forward>::type* get_inbuf() { return d_inbuf.data(); }
91 typename fft_outbuf<T, forward>::type* get_outbuf() { return d_outbuf.data(); }
92
93 int inbuf_length() const { return d_inbuf.size(); }
94 int outbuf_length() const { return d_outbuf.size(); }
95
96 /*!
97 * Set the number of threads to use for calculation.
98 */
99 void set_nthreads(int n);
100
101 /*!
102 * Get the number of threads being used by FFTW
103 */
104 int nthreads() const { return d_nthreads; }
105
106 /*!
107 * compute FFT. The input comes from inbuf, the output is placed in
108 * outbuf.
109 */
110 void execute();
111};
112
113 using fft_complex_fwd = fft<gr_complex, true>;
114 using fft_complex_rev = fft<gr_complex, false>;
115 using fft_real_fwd = fft<float, true>;
116 using fft_real_rev = fft<float, false>;
117
118} /* namespace fft */
119} /*namespace gr */
120
121#endif /* _FFT_FFT_H_ */
gr::fft::fft
Definition fft.h:70
gr::fft::fft::fft
fft(const fft &)=delete
gr::fft::fft::inbuf_length
int inbuf_length() const
Definition fft.h:93
gr::fft::fft::get_outbuf
fft_outbuf< T, forward >::type * get_outbuf()
Definition fft.h:91
gr::fft::fft::execute
void execute()
gr::fft::fft::fft
fft(int fft_size, int nthreads=1)
gr::fft::fft::get_inbuf
fft_inbuf< T, forward >::type * get_inbuf()
Definition fft.h:90
gr::fft::fft::outbuf_length
int outbuf_length() const
Definition fft.h:94
gr::fft::fft::~fft
virtual ~fft()
gr::fft::fft::set_nthreads
void set_nthreads(int n)
gr::fft::fft::operator=
fft & operator=(const fft &)=delete
gr::fft::fft< gr_complex, true >::nthreads
int nthreads() const
Definition fft.h:104
gr::fft::planner
Export reference to planner mutex for those apps that want to use FFTW w/o using the fft_impl_fftw* c...
Definition fft.h:32
gr::fft::planner::mutex
static std::mutex & mutex()
gr::logger
GR_LOG macros.
Definition logger.h:121
api.h
FFT_API
#define FFT_API
Definition gr-fft/include/gnuradio/fft/api.h:18
gr_complex.h
gr_complex
std::complex< float > gr_complex
Definition gr_complex.h:15
logger.h
gr::fft
Definition ctrlport_probe_psd.h:18
gr::fft::fft_real_fwd
fft< float, true > fft_real_fwd
Definition fft.h:115
gr::fft::fft_complex_fwd
fft< gr_complex, true > fft_complex_fwd
Definition fft.h:113
gr::fft::fft_complex_rev
fft< gr_complex, false > fft_complex_rev
Definition fft.h:114
gr::fft::fft_real_rev
fft< float, false > fft_real_rev
Definition fft.h:116
gr
GNU Radio logging wrapper.
Definition basic_block.h:29
gr::fft::fft_inbuf< float, false >::type
gr_complex type
Definition fft.h:54
gr::fft::fft_inbuf
FFT: templated.
Definition fft.h:48
gr::fft::fft_inbuf::type
T type
Definition fft.h:49
gr::fft::fft_outbuf< float, true >::type
gr_complex type
Definition fft.h:65
gr::fft::fft_outbuf
Definition fft.h:59
gr::fft::fft_outbuf::type
T type
Definition fft.h:60