GNU Radio C++ API Reference gcd20ee2
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 */
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>
48struct fft_inbuf {
49 typedef T type;
50};
51
52template <>
53struct fft_inbuf<float, false> {
55};
56
57
58template <class T, bool forward>
59struct fft_outbuf {
60 typedef T type;
61};
62
63template <>
64struct fft_outbuf<float, true> {
66};
67
68template <class T, bool forward>
70{
71 const int d_fft_size;
72 int d_nthreads;
73 const int d_nffts;
74 volk::vector<typename fft_inbuf<T, forward>::type> d_inbuf;
75 volk::vector<typename fft_outbuf<T, forward>::type> d_outbuf;
76 void* d_plan;
77 gr::logger d_logger;
78 void initialize_plan(int fft_size, int nffts);
79
80public:
81 fft(int fft_size, int nthreads = 1, int nffts = 1);
82 // Copy disabled due to d_plan.
83 fft(const fft&) = delete;
84 fft& operator=(const fft&) = delete;
85 virtual ~fft();
86
87 /*
88 * These return pointers to buffers owned by fft_impl_fft_complex
89 * into which input and output take place. It's done this way in
90 * order to ensure optimal alignment for SIMD instructions.
91 */
92 typename fft_inbuf<T, forward>::type* get_inbuf(int fft_idx = 0)
93 {
94 return &(d_inbuf.data()[d_fft_size * fft_idx]);
95 }
96 typename fft_outbuf<T, forward>::type* get_outbuf(int fft_idx = 0)
97 {
98 return &(d_outbuf.data()[d_fft_size * fft_idx]);
99 }
100
101 int inbuf_length() const { return d_fft_size; }
102 int outbuf_length() const { return d_fft_size; }
103
104 /*!
105 * Set the number of threads to use for calculation.
106 */
107 void set_nthreads(int n);
108
109 /*!
110 * Get the number of threads being used by FFTW
111 */
112 int nthreads() const { return d_nthreads; }
113
114 /*!
115 * compute FFT. The input comes from inbuf, the output is placed in
116 * outbuf.
117 */
118 void execute();
119};
120
125
126} /* namespace fft */
127} /*namespace gr */
128
129#endif /* _FFT_FFT_H_ */
Definition fft.h:70
fft(const fft &)=delete
int inbuf_length() const
Definition fft.h:101
void execute()
fft_outbuf< T, forward >::type * get_outbuf(int fft_idx=0)
Definition fft.h:96
int outbuf_length() const
Definition fft.h:102
virtual ~fft()
fft(int fft_size, int nthreads=1, int nffts=1)
fft_inbuf< T, forward >::type * get_inbuf(int fft_idx=0)
Definition fft.h:92
void set_nthreads(int n)
fft & operator=(const fft &)=delete
int nthreads() const
Definition fft.h:112
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
static std::mutex & mutex()
GR_LOG macros.
Definition logger.h:119
#define FFT_API
Definition gr-fft/include/gnuradio/fft/api.h:18
std::complex< float > gr_complex
Definition gr_complex.h:15
Definition ctrlport_probe_psd.h:18
fft< float, true > fft_real_fwd
Definition fft.h:123
fft< gr_complex, true > fft_complex_fwd
Definition fft.h:121
fft< gr_complex, false > fft_complex_rev
Definition fft.h:122
fft< float, false > fft_real_rev
Definition fft.h:124
GNU Radio logging wrapper.
Definition basic_block.h:29
gr_complex type
Definition fft.h:54
FFT: templated.
Definition fft.h:48
T type
Definition fft.h:49
gr_complex type
Definition fft.h:65
Definition fft.h:59
T type
Definition fft.h:60