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)
69 samples[i] =
static_cast<FloatType
> (1.0) - std::abs ((
static_cast<FloatType
> (i) - halfSlots) / halfSlots);
75 for (
size_t i = 0; i < size; ++i)
77 auto cos2 = ncos<FloatType> (2, i, size);
78 samples[i] =
static_cast<FloatType
> (0.5 - 0.5 * cos2);
85 for (
size_t i = 0; i < size; ++i)
87 auto cos2 = ncos<FloatType> (2, i, size);
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)
99 auto cos2 = ncos<FloatType> (2, i, size);
100 auto cos4 = ncos<FloatType> (4, i, size);
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)
111 auto cos2 = ncos<FloatType> (2, i, size);
112 auto cos4 = ncos<FloatType> (4, i, size);
113 auto cos6 = ncos<FloatType> (6, i, size);
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)
124 auto cos2 = ncos<FloatType> (2, i, size);
125 auto cos4 = ncos<FloatType> (4, i, size);
126 auto cos6 = ncos<FloatType> (6, i, size);
127 auto cos8 = ncos<FloatType> (8, i, size);
129 samples[i] =
static_cast<FloatType
> (1.0 - 1.93 * cos2 + 1.29 * cos4 - 0.388 * cos6 + 0.028 * cos8);
137 const auto doubleSize = (double) size;
139 for (
size_t i = 0; i < size; ++i)
140 samples[i] =
static_cast<FloatType
> (
SpecialFunctions::besselI0 (beta * std::sqrt (1.0 - std::pow (((
double) i - 0.5 * (doubleSize - 1.0))
141 / ( 0.5 * (doubleSize - 1.0)), 2.0)))
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:
186 default: jassertfalse;
return "";
WindowingFunction(size_t size, WindowingMethod, bool normalise=true, FloatType beta=0)
static const char * getWindowingMethodName(WindowingMethod) noexcept
void multiplyWithWindowingTable(FloatType *samples, size_t size) const noexcept
void fillWindowingTables(size_t size, WindowingMethod type, bool normalise=true, FloatType beta=0) noexcept
static constexpr FloatType pi
static double besselI0(double x) noexcept