Provides methods to generate interpolation filters using Kaiser windows.
More...
#include "interpolation_filter.h"
Provides methods to generate interpolation filters using Kaiser windows.
Definition at line 27 of file interpolation_filter.h.
◆ InterpFilter() [1/2]
◆ InterpFilter() [2/2]
◆ ~InterpFilter()
| interp::InterpFilter::~InterpFilter |
( |
| ) |
|
|
default |
◆ getFilter()
| std::span< const RealType > interp::InterpFilter::getFilter |
( |
RealType |
delay | ) |
const |
Retrieves a span of precomputed filter values for a given delay.
- Parameters
-
| delay | The delay value for which the filter is retrieved. |
- Returns
- A span of precomputed filter values.
- Exceptions
-
| std::runtime_error | If the delay value is out of range. |
Definition at line 138 of file interpolation_filter.cpp.
139 {
140 if (delay < -1 || delay > 1)
141 {
142 LOG(Level::FATAL,
"Requested delay filter value out of range: {}", delay);
143 throw std::runtime_error("Requested delay filter value out of range");
144 }
145
146 const auto filt = static_cast<unsigned>((delay + 1) * (_table_filters / 2.0));
147 return std::span{&_filter_table[filt * _length], static_cast<size_t>(_length)};
148 }
References LOG.
◆ getInstance()
◆ interpFilter()
| std::expected< RealType, std::string > interp::InterpFilter::interpFilter |
( |
RealType |
x | ) |
const |
|
noexcept |
Computes the interpolation filter value for a given input.
- Parameters
-
| x | The input value for which the interpolation filter is computed. |
- Returns
- The computed filter value, or an error message if computation fails.
Definition at line 85 of file interpolation_filter.cpp.
86 {
88 {
89 return *kaiser *
sinc(x);
90 }
91 else
92 {
93 return std::unexpected(kaiser.error());
94 }
95 }
static constexpr RealType sinc(const RealType x) noexcept
Computes the sinc function for a given input.
std::expected< RealType, std::string > kaiserWinCompute(RealType x) const noexcept
Computes the Kaiser window function for a given input.
◆ kaiserWinCompute()
| std::expected< RealType, std::string > interp::InterpFilter::kaiserWinCompute |
( |
RealType |
x | ) |
const |
|
noexcept |
Computes the Kaiser window function for a given input.
- Parameters
-
| x | The input value for the Kaiser window calculation. |
- Returns
- The computed window value, or an error message if computation fails.
Definition at line 69 of file interpolation_filter.cpp.
70 {
71 if (x < 0 || x > _alpha * 2)
72 {
73 return 0;
74 }
75 if (auto bessel = besselI0(_beta * std::sqrt(1 - std::pow((x - _alpha) / _alpha, 2))); bessel)
76 {
77 return *bessel / _bessel_beta;
78 }
79 else
80 {
81 return std::unexpected(bessel.error());
82 }
83 }
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ sinc()
Computes the sinc function for a given input.
- Parameters
-
| x | The input value for which the sinc function is computed. |
- Returns
- The computed sinc value.
Definition at line 42 of file interpolation_filter.h.
43 {
44 return x == 0.0 ? 1.0 : std::sin(x *
PI) / (x *
PI);
45 }
constexpr RealType PI
Mathematical constant π (pi).
References PI.
The documentation for this class was generated from the following files: