29template <
typename FloatType>
30static FloatType ncos (
size_t order,
size_t i,
size_t size)
noexcept
32 return std::cos (
static_cast<FloatType
> (order * i)
36template <
typename FloatType>
39 fillWindowingTables (size, type, normalise, beta);
42template <
typename FloatType>
44 bool normalise, FloatType beta)
noexcept
46 windowTable.resize (
static_cast<int> (size));
47 fillWindowingTables (windowTable.getRawDataPointer(), size, type, normalise, beta);
50template <
typename FloatType>
53 FloatType beta)
noexcept
59 for (
size_t i = 0; i < size; ++i)
60 samples[i] =
static_cast<FloatType
> (1);
66 auto halfSlots =
static_cast<FloatType
> (0.5) *
static_cast<FloatType
> (size - 1);
68 for (
size_t i = 0; i < size; ++i)
75 for (
size_t i = 0; i < size; ++i)
78 samples[i] =
static_cast<FloatType
> (0.5 - 0.5 *
cos2);
85 for (
size_t i = 0; i < size; ++i)
88 samples[i] =
static_cast<FloatType
> (0.54 - 0.46 *
cos2);
95 constexpr FloatType alpha = 0.16f;
97 for (
size_t i = 0; i < size; ++i)
102 samples[i] =
static_cast<FloatType
> (0.5 * (1 - alpha) - 0.5 *
cos2 + 0.5 * alpha *
cos4);
109 for (
size_t i = 0; i < size; ++i)
115 samples[i] =
static_cast<FloatType
> (0.35875 - 0.48829 *
cos2 + 0.14128 *
cos4 - 0.01168 *
cos6);
122 for (
size_t i = 0; i < size; ++i)
139 for (
size_t i = 0; i < size; ++i)
146 case numWindowingMethods:
157 for (
size_t i = 0; i < size; ++i)
160 auto factor =
static_cast<FloatType
> (size) / sum;
162 FloatVectorOperations::multiply (
samples, factor,
static_cast<int> (size));
166template <
typename FloatType>
169 FloatVectorOperations::multiply (
samples, windowTable.getRawDataPointer(),
jmin (
static_cast<int> (size), windowTable.size()));
172template <
typename FloatType>
177 case rectangular:
return "Rectangular";
178 case triangular:
return "Triangular";
179 case hann:
return "Hann";
180 case hamming:
return "Hamming";
181 case blackman:
return "Blackman";
182 case blackmanHarris:
return "Blackman-Harris";
183 case flatTop:
return "Flat Top";
184 case kaiser:
return "Kaiser";
185 case numWindowingMethods:
A class which provides multiple windowing functions useful for filter design and spectrum analyzers.
WindowingMethod
The windowing methods available.
WindowingFunction(size_t size, WindowingMethod, bool normalise=true, FloatType beta=0)
This constructor automatically fills a buffer of the specified size using the fillWindowingTables fun...
static const char * getWindowingMethodName(WindowingMethod) noexcept
Returns the name of a given windowing method.
void multiplyWithWindowingTable(FloatType *samples, size_t size) const noexcept
Multiplies the content of a buffer with the given window.
void fillWindowingTables(size_t size, WindowingMethod type, bool normalise=true, FloatType beta=0) noexcept
Fills the content of the object array with a given windowing method table.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
static constexpr FloatType pi
A predefined value for Pi.
static double besselI0(double x) noexcept
Computes the modified Bessel function of the first kind I0 for a given double value x.