Prevent invalid C/N0 smoother initialization

This commit is contained in:
Carles Fernandez
2026-07-27 20:26:58 +02:00
parent a8c76ce0b4
commit bd2d002a97
2 changed files with 1 additions and 11 deletions
@@ -63,7 +63,6 @@ void Exponential_Smoother::reset()
{
initializing_ = true;
init_counter_ = 0;
init_attempts_ = 0;
init_buffer_.clear();
}
@@ -93,10 +92,9 @@ float Exponential_Smoother::smooth(float raw)
if (init_counter_ >= samples_for_initialization_)
{
old_value_ = std::accumulate(std::begin(init_buffer_), std::end(init_buffer_), 0.0F) / static_cast<float>(init_buffer_.size());
if (old_value_ < (min_value_ + offset_) && init_attempts_ < max_init_attempts_)
if (old_value_ < (min_value_ + offset_))
{
// flush buffer and start again
init_attempts_++;
init_counter_ = 0;
init_buffer_.clear();
}
@@ -35,12 +35,6 @@
*
* The length of the initialization can be controlled with
* set_samples_for_initialization(int num_samples)
*
* If the average of an initialization window falls below
* min_value + offset, the window is discarded and initialization
* starts again, up to a maximum number of attempts; after that, the
* smoother engages with the last window average so that weak but valid
* signals still get smoothed.
*/
class Exponential_Smoother
{
@@ -68,8 +62,6 @@ private:
float offset_{12.0};
int samples_for_initialization_{200};
int init_counter_{0};
int init_attempts_{0};
int max_init_attempts_{3};
bool initializing_{true};
};