mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-21 23:55:13 -05:00
M17: Golay24 code cleanup
This commit is contained in:
parent
b5b6bdf825
commit
06a0f051e9
@ -14,27 +14,12 @@ namespace modemm17
|
||||
template <size_t N = 32>
|
||||
struct FrequencyError
|
||||
{
|
||||
using float_type = float;
|
||||
using array_t = std::array<float, N>;
|
||||
using filter_type = BaseIirFilter<3>;
|
||||
|
||||
static constexpr std::array<float, 3> evm_b{0.02008337, 0.04016673, 0.02008337};
|
||||
static constexpr std::array<float, 3> evm_a{1.0, -1.56101808, 0.64135154};
|
||||
|
||||
array_t samples_{0};
|
||||
size_t index_ = 0;
|
||||
float_type accum_ = 0.0;
|
||||
filter_type filter_{makeIirFilter(evm_b, evm_a)};
|
||||
|
||||
|
||||
const float_type ZERO = 0.0;
|
||||
|
||||
FrequencyError()
|
||||
FrequencyError() :
|
||||
{
|
||||
samples_.fill(0.0);
|
||||
samples_.fill(0.0f);
|
||||
}
|
||||
|
||||
auto operator()(float_type sample)
|
||||
auto operator()(float sample)
|
||||
{
|
||||
float evm = 0;
|
||||
bool use = true;
|
||||
@ -61,6 +46,17 @@ struct FrequencyError
|
||||
|
||||
return filter_(accum_ / N);
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr std::array<float, 3> evm_b{0.02008337, 0.04016673, 0.02008337};
|
||||
static constexpr std::array<float, 3> evm_a{1.0, -1.56101808, 0.64135154};
|
||||
|
||||
std::array<float, N> samples_;
|
||||
size_t index_ = 0;
|
||||
float accum_ = 0.0f;
|
||||
BaseIirFilter<3> filter_{makeIirFilter(evm_b, evm_a)};
|
||||
|
||||
const float ZERO = 0.0f;
|
||||
};
|
||||
|
||||
} // modemm17
|
||||
|
@ -22,7 +22,7 @@ namespace Golay24_detail
|
||||
// Need a constexpr sort.
|
||||
// https://stackoverflow.com/a/40030044/854133
|
||||
template<class T>
|
||||
constexpr void swap(T& l, T& r)
|
||||
static void swap(T& l, T& r)
|
||||
{
|
||||
T tmp = std::move(l);
|
||||
l = std::move(r);
|
||||
@ -52,7 +52,7 @@ struct array
|
||||
};
|
||||
|
||||
template <typename T, size_t N>
|
||||
constexpr void sort_impl(array<T, N> &array, size_t left, size_t right)
|
||||
static void sort_impl(array<T, N> &array, size_t left, size_t right)
|
||||
{
|
||||
if (left < right)
|
||||
{
|
||||
@ -70,7 +70,7 @@ constexpr void sort_impl(array<T, N> &array, size_t left, size_t right)
|
||||
}
|
||||
|
||||
template <typename T, size_t N>
|
||||
constexpr array<T, N> sort(array<T, N> array)
|
||||
static array<T, N> sort(array<T, N> array)
|
||||
{
|
||||
auto sorted = array;
|
||||
sort_impl(sorted, 0, N);
|
||||
|
Loading…
Reference in New Issue
Block a user