JS8Call-Improved master
Loading...
Searching...
No Matches
FrequencyTracker.h
1#pragma once
2
3#include <complex>
4#include <numbers>
5
6namespace js8 {
15 public:
16 void reset(double initial_hz, double sample_rate_hz, double alpha = 0.15,
17 double max_step_hz = 0.3, double max_error_hz = 5.0);
18
19 void disable();
20
21 [[nodiscard]] bool enabled() const noexcept;
22
23 [[nodiscard]] double currentHz() const noexcept;
24
25 [[nodiscard]] double averageStepHz() const noexcept;
26
27 void apply(std::complex<float> *data, int count) const;
28
29 void update(double residual_hz, double weight = 1.0);
30
31 private:
32 bool m_enabled = true;
33 double m_est_hz = 0.0;
34 double m_fs = 0.0;
35 double m_alpha = 0.15;
36 double m_max_step_hz = 0.3;
37 double m_max_error_hz = 5.0;
38 double m_sum_abs = 0.0;
39 int m_updates = 0;
40};
41
43 public:
52
53 void reset(double initial_samples, double alpha = 0.15,
54 double max_step = 0.35, double max_total_error = 2.0);
55
56 void disable();
57
58 [[nodiscard]] bool enabled() const noexcept;
59
60 [[nodiscard]] double currentSamples() const noexcept;
61
62 [[nodiscard]] double averageStepSamples() const noexcept;
63
64 void update(double residual_samples, double weight = 1.0);
65
66 private:
67 bool m_enabled = true;
68 double m_est_samples = 0.0;
69 double m_alpha = 0.15;
70 double m_max_step = 0.35;
71 double m_max_total = 2.0;
72 double m_sum_abs = 0.0;
73 int m_updates = 0;
74};
75} // namespace js8
Lightweight PLL/Kalman-style tracker for residual frequency offset.
Definition FrequencyTracker.h:14
double currentHz() const noexcept
Get the current frequency estimate in Hz.
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)
Reset the FrequencyTracker with initial parameters.
Definition FrequencyTracker.cpp:24
double averageStepHz() const noexcept
Get the average step size in Hz.
Definition FrequencyTracker.cpp:63
void update(double residual_hz, double weight=1.0)
Update the FrequencyTracker with a new residual frequency measurement.
Definition FrequencyTracker.cpp:93
bool enabled() const noexcept
Check if the FrequencyTracker is enabled.
Definition FrequencyTracker.cpp:49
void disable()
Disable the FrequencyTracker.
Definition FrequencyTracker.cpp:41
void apply(std::complex< float > *data, int count) const
Apply frequency correction to the provided data.
Definition FrequencyTracker.cpp:73
Definition FrequencyTracker.h:42
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
Get the average step size in samples.
Definition FrequencyTracker.cpp:155
double currentSamples() const noexcept
Get the current timing estimate in samples.
Definition FrequencyTracker.cpp:148
void disable()
Disable the TimingTracker.
Definition FrequencyTracker.cpp:133
bool enabled() const noexcept
Check if the TimingTracker is enabled.
Definition FrequencyTracker.cpp:141
void update(double residual_samples, double weight=1.0)
Update the TimingTracker with a new residual timing measurement.
Definition FrequencyTracker.cpp:165
JS8 namespace for Kalman filter-based trackers.
Definition FrequencyTracker.cpp:14