30#ifndef APF_FFTWTOOLS_H
31#define APF_FFTWTOOLS_H
44template<
typename T>
struct fftw {};
47#define APF_FFTW_TRAITS(longtype, shorttype) \
51struct fftw<longtype> { \
52 using plan = fftw ## shorttype ## plan; \
53 static void* malloc(size_t n) { return fftw ## shorttype ## malloc(n); } \
54 static void free(void* p) { fftw ## shorttype ## free(p); } \
55 static void destroy_plan(plan p) { \
56 fftw ## shorttype ## destroy_plan(p); p = nullptr; } \
57 static void execute(const plan p) { fftw ## shorttype ## execute(p); } \
58 static void execute_r2r(const plan p, longtype *in, longtype *out) { \
59 fftw ## shorttype ## execute_r2r(p, in, out); } \
60 static plan plan_r2r_1d(int n, longtype* in, longtype* out \
61 , fftw_r2r_kind kind, unsigned flags) { \
62 return fftw ## shorttype ## plan_r2r_1d(n, in, out, kind, flags); } \
65 template<typename Func, typename... Args> \
66 scoped_plan(Func func, Args... args) \
67 : _plan(func(std::forward<Args>(args)...)), _owning(true) {} \
68 scoped_plan(scoped_plan&& other) \
69 : _plan(std::move(other._plan)), _owning(true) { \
70 other._owning = false; } \
71 ~scoped_plan() { if (_owning) destroy_plan(_plan); } \
72 operator const plan&() { return _plan; } \
74 plan _plan; bool _owning; }; \
87 using size_type = size_t;
88 using difference_type = ptrdiff_t;
90 using const_pointer =
const T*;
92 using const_reference =
const T&;
95 pointer allocate(size_type n,
const void* hint =
nullptr)
101 void deallocate(pointer p, size_type n)
107 void construct(pointer p,
const T& t) {
new (p) T(t); }
108 void destroy(pointer p) { p->~T(); }
110 size_type max_size()
const
112 return std::numeric_limits<size_type>::max() /
sizeof(T);
124 pointer address(reference value) {
return &value; }
125 const_pointer address(const_reference value) {
return &value; }
Audio Processing Framework.
Traits class to select float/double/long double versions of FFTW functions.