LCOV - code coverage report
Current view: top level - ffb - UpSampler.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 16 16
Test Date: 2026-03-16 13:51:44 Functions: 100.0 % 3 3
Branches: 75.0 % 4 3

             Branch data     Line data    Source code
       1                 :             : #include "UpSampler.h"
       2                 :             : #include <algorithm>
       3                 :             : 
       4                 :             : namespace ffb_math {
       5                 :             : 
       6                 :          11 : PolyphaseResampler::PolyphaseResampler() {
       7                 :          11 :     Reset();
       8                 :          11 : }
       9                 :             : 
      10                 :          11 : void PolyphaseResampler::Reset() {
      11                 :          11 :     m_phase = 0;
      12         [ +  - ]:          11 :     m_history.fill(0.0);
      13                 :          11 : }
      14                 :             : 
      15                 :        7902 : double PolyphaseResampler::Process(double latest_physics_sample, bool is_new_physics_tick) {
      16         [ +  + ]:        7902 :     if (is_new_physics_tick) {
      17                 :             :         // Shift history and add new sample
      18                 :        3160 :         m_history[0] = m_history[1];
      19                 :        3160 :         m_history[1] = m_history[2];
      20                 :        3160 :         m_history[2] = latest_physics_sample;
      21                 :             :     }
      22                 :             : 
      23                 :             :     // Apply the 3-tap FIR filter for the current phase
      24                 :        7902 :     const double* c = COEFFS[m_phase];
      25                 :        7902 :     double output = c[0] * m_history[0] + c[1] * m_history[1] + c[2] * m_history[2];
      26                 :             : 
      27                 :             :     // Advance phase (1000Hz ticks)
      28                 :             :     // The phase accumulator in main.cpp handles the 2/5 relationship,
      29                 :             :     // but the resampler itself needs to know which branch of the polyphase filter to use.
      30                 :             :     // Each call to Process is one 1000Hz tick.
      31                 :        7902 :     m_phase = (m_phase + 1) % 5;
      32                 :             : 
      33                 :        7902 :     return output;
      34                 :             : }
      35                 :             : 
      36                 :             : } // namespace ffb_math
        

Generated by: LCOV version 2.0-1