Loading...
Searching...
No Matches
fft.h
Go to the documentation of this file.
/* -*- c++ -*- */
/*
* Copyright 2003,2008,2012,2020 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef _FFT_FFT_H_
#define _FFT_FFT_H_
/*
* Wrappers for FFTW single precision 1d dft
*/
#include <gnuradio/fft/api.h>
#include <gnuradio/gr_complex.h>
#include <gnuradio/logger.h>
#include <volk/volk_alloc.hh>
#include <mutex>
namespace gr {
namespace fft {
/*!
* \brief Export reference to planner mutex for those apps that
* want to use FFTW w/o using the fft_impl_fftw* classes.
*/
class FFT_API planner
{
public:
/*!
* Return reference to planner mutex
*/
static std::mutex& mutex();
};
/*!
\brief FFT: templated
\ingroup misc
*/
template <class T, bool forward>
struct fft_inbuf {
typedef T type;
};
template <>
struct fft_inbuf<float, false> {
typedef gr_complex type;
};
template <class T, bool forward>
struct fft_outbuf {
typedef T type;
};
template <>
struct fft_outbuf<float, true> {
typedef gr_complex type;
};
template <class T, bool forward>
class FFT_API fft
{
int d_nthreads;
volk::vector<typename fft_inbuf<T, forward>::type> d_inbuf;
volk::vector<typename fft_outbuf<T, forward>::type> d_outbuf;
void* d_plan;
gr::logger d_logger;
void initialize_plan(int fft_size);
public:
fft(int fft_size, int nthreads = 1);
// Copy disabled due to d_plan.
fft(const fft&) = delete;
fft& operator=(const fft&) = delete;
virtual ~fft();
/*
* These return pointers to buffers owned by fft_impl_fft_complex
* into which input and output take place. It's done this way in
* order to ensure optimal alignment for SIMD instructions.
*/
typename fft_inbuf<T, forward>::type* get_inbuf() { return d_inbuf.data(); }
typename fft_outbuf<T, forward>::type* get_outbuf() { return d_outbuf.data(); }
int inbuf_length() const { return d_inbuf.size(); }
int outbuf_length() const { return d_outbuf.size(); }
/*!
* Set the number of threads to use for calculation.
*/
void set_nthreads(int n);
/*!
* Get the number of threads being used by FFTW
*/
int nthreads() const { return d_nthreads; }
/*!
* compute FFT. The input comes from inbuf, the output is placed in
* outbuf.
*/
void execute();
};
using fft_complex_fwd = fft<gr_complex, true>;
using fft_complex_rev = fft<gr_complex, false>;
using fft_real_fwd = fft<float, true>;
using fft_real_rev = fft<float, false>;
} /* namespace fft */
} /*namespace gr */
#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