#pragma once #include "fdaf.h" #include class AEC { public: void do_sample(float mic, float hp, bool maybevoice); void do_buffer(float* res, float* mic, float* hp, bool maybevoice); bool inject_noise(); std::array lookback; int lb_index; /* By chunks of 8 samples We expect to have >= 1024 samples delay, or 128 chunks delay. */ std::array lookback_power; float mic_acc = 0.0f; float hp_acc = 0.0f; int lookback_phase = 0; std::array weighted_xcorr; static constexpr float xcorr_decay = (1.0f)/(48000/8); // 100ms int current_delay = 0; // We expect sudden drifts enum {LOST, LEARNING, ONLINE} status = LOST; int cnt = 0; FDAF fd = FDAF(1024); private: void find_delay(float mic, float hp); };