2#include <ossia/detail/config.hpp>
4#include <ossia/detail/pod_vector.hpp>
10#if defined(OSSIA_FFT_FFTW)
11#if defined(OSSIA_FFTW_SINGLE_ONLY)
12using fftw_plan =
struct fftw_plan_s*;
13using fftwf_plan =
struct fftwf_plan_s*;
16using fft_plan = fftwf_plan;
17using fft_real = float;
18using fft_complex =
float[2];
19struct fft_temp_storage
23#elif defined(OSSIA_FFTW_DOUBLE_ONLY)
24using fftw_plan =
struct fftw_plan_s*;
25using fftwf_plan =
struct fftwf_plan_s*;
28using fft_plan = fftw_plan;
29using fft_real = double;
30using fft_complex =
double[2];
31struct fft_temp_storage
36#elif defined(OSSIA_FFT_KFR)
39using fft_plan =
void*;
40using fft_real = double;
41using fft_complex =
double[2];
42using fft_temp_storage = ossia::pod_vector<uint8_t>;
47using fft_plan =
void*;
48using fft_real = double;
49using fft_complex =
double[2];
50struct fft_temp_storage
61 explicit fft(std::size_t newSize)
noexcept;
69 static constexpr double norm(std::size_t sz)
noexcept {
return 1. / sz; }
73 void reset(std::size_t newSize);
76 void prepare(std::size_t newSize);
78 fft_complex* execute(
float* input, std::size_t sz)
noexcept;
79 fft_complex* execute() noexcept;
81 [[nodiscard]] fft_real* input() const noexcept {
return m_input; }
83 [[nodiscard]] std::size_t size() const noexcept {
return m_size; }
84 [[nodiscard]] std::size_t storage_size() const noexcept {
return m_storage_size; }
87 void build(std::size_t newSize,
bool measure)
noexcept;
88 void release() noexcept;
89 void use(std::
size_t newSize,
bool measure);
92 std::size_t m_size = 0;
93 std::size_t m_storage_size = 0;
95 fft_complex* m_output{};
96 fft_temp_storage m_storage;
103 std::size_t size = 0;
104 std::size_t storage_size = 0;
106 fft_complex* output{};
107 fft_temp_storage storage;
108 std::size_t used = 0;
110 void swap(spare& s)
noexcept;
111 std::array<spare, 3> m_spares{};
112 std::size_t m_uses = 0;
115class OSSIA_EXPORT rfft
118 explicit rfft(std::size_t newSize)
noexcept;
121 static constexpr double norm(std::size_t sz)
noexcept {
return 1. / sz; }
123 void reset(std::size_t newSize);
125 fft_real* execute(fft_complex* input)
noexcept;
126 fft_real* execute() noexcept;
128 [[nodiscard]] fft_complex* input() const noexcept {
return m_input; }
132 std::size_t m_size = 0;
133 std::size_t m_storage_size = 0;
134 fft_complex* m_input{};
135 fft_real* m_output{};
136 fft_temp_storage m_storage;