32 template <
typename FloatType>
33 static inline FloatType ncos (
size_t order,
size_t i,
size_t size) noexcept
35 return std::cos (static_cast<FloatType> (order * i)
39 template <
typename FloatType>
42 fillWindowingTables (size, type, normalise, beta);
45 template <
typename FloatType>
47 bool normalise, FloatType beta) noexcept
49 windowTable.resize (static_cast<int> (size));
50 fillWindowingTables (windowTable.getRawDataPointer(), size, type, normalise, beta);
53 template <
typename FloatType>
56 FloatType beta) noexcept
62 for (
size_t i = 0; i < size; ++i)
63 samples[i] = static_cast<FloatType> (1);
69 auto halfSlots =
static_cast<FloatType
> (0.5) *
static_cast<FloatType
> (size - 1);
71 for (
size_t i = 0; i < size; ++i)
72 samples[i] = static_cast<FloatType> (1.0) - std::abs ((static_cast<FloatType> (i) - halfSlots) / halfSlots);
78 for (
size_t i = 0; i < size; ++i)
80 auto cos2 = ncos<FloatType> (2, i, size);
81 samples[i] =
static_cast<FloatType
> (0.5 - 0.5 * cos2);
88 for (
size_t i = 0; i < size; ++i)
90 auto cos2 = ncos<FloatType> (2, i, size);
91 samples[i] =
static_cast<FloatType
> (0.54 - 0.46 * cos2);
98 constexpr FloatType alpha = 0.16f;
100 for (
size_t i = 0; i < size; ++i)
102 auto cos2 = ncos<FloatType> (2, i, size);
103 auto cos4 = ncos<FloatType> (4, i, size);
105 samples[i] =
static_cast<FloatType
> (0.5 * (1 - alpha) - 0.5 * cos2 + 0.5 * alpha * cos4);
112 for (
size_t i = 0; i < size; ++i)
114 auto cos2 = ncos<FloatType> (2, i, size);
115 auto cos4 = ncos<FloatType> (4, i, size);
116 auto cos6 = ncos<FloatType> (6, i, size);
118 samples[i] =
static_cast<FloatType
> (0.35875 - 0.48829 * cos2 + 0.14128 * cos4 - 0.01168 * cos6);
125 for (
size_t i = 0; i < size; ++i)
127 auto cos2 = ncos<FloatType> (2, i, size);
128 auto cos4 = ncos<FloatType> (4, i, size);
129 auto cos6 = ncos<FloatType> (6, i, size);
130 auto cos8 = ncos<FloatType> (8, i, size);
132 samples[i] =
static_cast<FloatType
> (1.0 - 1.93 * cos2 + 1.29 * cos4 - 0.388 * cos6 + 0.028 * cos8);
141 for (
size_t i = 0; i < size; ++i)
143 / ( 0.5 * (size - 1.0)), 2.0)))
158 for (
size_t i = 0; i < size; ++i)
161 auto factor =
static_cast<FloatType
> (size) / sum;
167 template <
typename FloatType>
173 template <
typename FloatType>
178 case rectangular:
return "Rectangular";
179 case triangular:
return "Triangular";
180 case hann:
return "Hann";
181 case hamming:
return "Hamming";
182 case blackman:
return "Blackman";
183 case blackmanHarris:
return "Blackman-Harris";
184 case flatTop:
return "Flat Top";
185 case kaiser:
return "Kaiser";
186 default: jassertfalse;
return "";
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 double besselI0(double x) noexcept
Computes the modified Bessel function of the first kind I0 for a given double value x...
WindowingMethod
The windowing methods available.
static void JUCE_CALLTYPE multiply(float *dest, const float *src, int numValues) noexcept
Multiplies the destination values by the source values.
static const FloatType pi
A predefined value for Pi.
static const char * getWindowingMethodName(WindowingMethod) noexcept
Returns the name of a given windowing method.
void multiplyWithWindowingTable(FloatType *samples, size_t size) noexcept
Multiplies the content of a buffer with the given window.
A class which provides multiple windowing functions useful for filter design and spectrum analyzers...
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.