JS8Call-Improved master
Loading...
Searching...
No Matches
FrequencyTracker.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <complex>
13#include <numbers>
14
15namespace js8 {
24 public:
33 void reset(double initial_hz, double sample_rate_hz, double alpha = 0.15,
34 double max_step_hz = 0.3, double max_error_hz = 5.0);
35
39 void disable();
40
45 [[nodiscard]] bool enabled() const noexcept;
46
51 [[nodiscard]] double currentHz() const noexcept;
52
57 [[nodiscard]] double averageStepHz() const noexcept;
58
64 void apply(std::complex<float> *data, int count) const;
65
71 void update(double residual_hz, double weight = 1.0);
72
73 private:
74 bool m_enabled = true;
75 double m_est_hz = 0.0;
76 double m_fs = 0.0;
77 double m_alpha = 0.15;
78 double m_max_step_hz = 0.3;
79 double m_max_error_hz = 5.0;
80 double m_sum_abs = 0.0;
81 int m_updates = 0;
82};
83
85 public:
94
102 void reset(double initial_samples, double alpha = 0.15,
103 double max_step = 0.35, double max_total_error = 2.0);
104
106 void disable();
107
112 [[nodiscard]] bool enabled() const noexcept;
113
118 [[nodiscard]] double currentSamples() const noexcept;
119
124 [[nodiscard]] double averageStepSamples() const noexcept;
125
131 void update(double residual_samples, double weight = 1.0);
132
133 private:
134 bool m_enabled = true;
135 double m_est_samples = 0.0;
136 double m_alpha = 0.15;
137 double m_max_step = 0.35;
138 double m_max_total = 2.0;
139 double m_sum_abs = 0.0;
140 int m_updates = 0;
141};
142} // namespace js8
Lightweight PLL/Kalman-style tracker for residual frequency offset.
Definition FrequencyTracker.h:23
double currentHz() const noexcept
Current estimated residual frequency.
Definition FrequencyTracker.cpp:56
void reset(double initial_hz, double sample_rate_hz, double alpha=0.15, double max_step_hz=0.3, double max_error_hz=5.0)
Initialize or reconfigure the tracker.
Definition FrequencyTracker.cpp:24
double averageStepHz() const noexcept
Average step size applied by the tracker (Hz).
Definition FrequencyTracker.cpp:63
void update(double residual_hz, double weight=1.0)
Update the tracker estimate using a measured residual.
Definition FrequencyTracker.cpp:93
bool enabled() const noexcept
Whether the tracker is enabled.
Definition FrequencyTracker.cpp:49
void disable()
Disable the tracker (subsequent apply() calls become no-ops).
Definition FrequencyTracker.cpp:41
void apply(std::complex< float > *data, int count) const
Rotate an array of complex samples by the tracked frequency.
Definition FrequencyTracker.cpp:73
Definition FrequencyTracker.h:84
void reset(double initial_samples, double alpha=0.15, double max_step=0.35, double max_total_error=2.0)
Tracks residual timing (sample) offset between the symbol clock and the signal.
Definition FrequencyTracker.cpp:118
double averageStepSamples() const noexcept
Average timing step applied per update (samples).
Definition FrequencyTracker.cpp:155
double currentSamples() const noexcept
Current estimated residual timing offset in samples.
Definition FrequencyTracker.cpp:148
void disable()
Disable the TimingTracker.
Definition FrequencyTracker.cpp:133
bool enabled() const noexcept
Whether the timing tracker is enabled.
Definition FrequencyTracker.cpp:141
void update(double residual_samples, double weight=1.0)
Update timing estimate using a measured residual (samples).
Definition FrequencyTracker.cpp:165
JS8 namespace for Kalman filter-based trackers.
Definition FrequencyTracker.cpp:14