29template <
typename NumericType>
30double FIR::Coefficients<NumericType>::Coefficients::getMagnitudeForFrequency (
double frequency,
double theSampleRate)
const noexcept
36 auto order = getFilterOrder();
41 const auto*
coefs = coefficients.begin();
43 for (
size_t n = 0; n <= order; ++n)
45 numerator +=
static_cast<double> (
coefs[n]) * factor;
49 return std::abs (numerator);
53template <
typename NumericType>
54void FIR::Coefficients<NumericType>::Coefficients::getMagnitudeForFrequencyArray (
double*
frequencies,
double*
magnitudes,
60 const auto*
coefs = coefficients.begin();
61 auto order = getFilterOrder();
63 for (
size_t i = 0; i < numSamples; ++i)
71 for (
size_t n = 0; n <= order; ++n)
73 numerator +=
static_cast<double> (
coefs[n]) * factor;
82template <
typename NumericType>
83double FIR::Coefficients<NumericType>::Coefficients::getPhaseForFrequency (
double frequency,
double theSampleRate)
const noexcept
94 const auto*
coefs = coefficients.begin();
95 auto order = getFilterOrder();
97 for (
size_t n = 0; n <= order; ++n)
99 numerator +=
static_cast<double> (
coefs[n]) * factor;
103 return std::arg (numerator);
107template <
typename NumericType>
108void FIR::Coefficients<NumericType>::Coefficients::getPhaseForFrequencyArray (
double*
frequencies,
double*
phases,
114 const auto*
coefs = coefficients.begin();
115 auto order = getFilterOrder();
117 for (
size_t i = 0; i < numSamples; ++i)
124 for (
size_t n = 0; n <= order; ++n)
126 numerator +=
static_cast<double> (
coefs[n]) * factor;
130 phases[i] = std::arg (numerator);
135template <
typename NumericType>
136void FIR::Coefficients<NumericType>::Coefficients::normalise() noexcept
140 auto*
coefs = coefficients.getRawDataPointer();
141 auto n =
static_cast<size_t> (coefficients.size());
143 for (
size_t i = 0; i < n; ++i)
155template struct FIR::Coefficients<float>;
156template struct FIR::Coefficients<double>;
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 twoPi
A predefined value for 2 * Pi.