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 28 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 140 of file interpolation_filter.cpp.
141 {
142 if (delay < -1 || delay > 1)
143 {
144 LOG(Level::FATAL,
"Requested delay filter value out of range: {}", delay);
145 throw std::runtime_error("Requested delay filter value out of range");
146 }
147
148 const auto filt =
149 std::min(
static_cast<std::size_t
>((delay + 1.0) * (
static_cast<RealType>(_table_filters) / 2.0)),
150 _table_filters - 1);
151 return std::span{_filter_table.data() + filt * _length, _length};
152 }
double RealType
Type for real numbers.
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 if (kaiser)
89 {
90 return *kaiser *
sinc(x);
91 }
92
93 return std::unexpected(kaiser.error());
94 }
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 70 of file interpolation_filter.cpp.
71 {
72 if (x < 0 || x > _alpha * 2)
73 {
74 return 0;
75 }
76 auto bessel = besselI0(_beta * std::sqrt(1 - std::pow((x - _alpha) / _alpha, 2)));
77 if (bessel)
78 {
79 return *bessel / _bessel_beta;
80 }
81
82 return std::unexpected(bessel.error());
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 43 of file interpolation_filter.h.
44 {
45 return x == 0.0 ? 1.0 : std::sin(x *
PI) / (x *
PI);
46 }
constexpr RealType PI
Mathematical constant π (pi).
References PI.
The documentation for this class was generated from the following files: